From dafeae0cf9562353c7a8afb1a6369b4845d78ab8 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 2 May 2024 12:28:35 +1000 Subject: [PATCH] CI: Use script from rust-bitcoin-maintainer-tools We have a CI script in the `rust-bitcoin-maintainer-tools` repository, lets use it. --- .github/workflows/README.md | 23 +++++++ .github/workflows/rust.yml | 117 +++++++++++++++++++++++++----------- client/contrib/test_vars.sh | 10 +++ contrib/crates.sh | 4 ++ contrib/integration_test.sh | 45 ++++++++++++++ contrib/test.sh | 38 ------------ json/Cargo.toml | 1 + json/contrib/test_vars.sh | 10 +++ 8 files changed, 174 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/README.md create mode 100644 client/contrib/test_vars.sh create mode 100755 contrib/crates.sh create mode 100755 contrib/integration_test.sh delete mode 100755 contrib/test.sh create mode 100644 json/contrib/test_vars.sh diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..c56be3f2 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,23 @@ +# rust-miniscript workflow notes + +We are attempting to run max 20 parallel jobs using GitHub actions (usage limit for free tier). + +ref: https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration + +The minimal/recent lock files are handled by CI (`rust.yml`). + +## Jobs + +Run from `rust.yml` unless stated otherwise. Total 11 jobs. + +1. `Stable - minimal` +2. `Stable - recent` +3. `Nightly - minimal` +4. `Nightly - recent` +5. `MSRV - minimal` +6. `Integration - 0.18.0` +7. `Integration - 0.18.1` +8. `Integration - 0.19.0.1` +9. `Integration - 0.19.1` +10. `Integration - 0.20.0` +11. `Integration - 0.21.0` diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 377f3ff2..d75c33fa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,42 +1,91 @@ -on: [push, pull_request] +--- # rust-bitcoincore-rpc CI: If you edit this file please update README.md +on: # yamllint disable-line rule:truthy + push: + branches: + - master + - 'test-ci/**' + pull_request: name: Continuous integration jobs: - tests: - name: Tests + Stable: # 2 jobs, one per lock file. + name: Test - stable toolchain runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - include: - - rust: stable - env: - RUSTFMTCHK: true - - rust: nightly - env: - RUSTFMTCHK: false - - rust: 1.56.1 - env: - RUSTFMTCHK: false + dep: [minimal, recent] steps: - - name: Checkout Crate - uses: actions/checkout@v2 - - name: Checkout Toolchain - uses: actions-rs/toolchain@v1 + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: actions/checkout@v4 with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - name: Running test script - env: ${{ matrix.env }} - run: ./contrib/test.sh + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + rev: b2ac115 + path: maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Set dependencies" + run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh stable - integrations-tests: - name: Integration Tests + Nightly: # 2 jobs, one per lock file. + name: Test - nightly toolchain runs-on: ubuntu-latest strategy: + fail-fast: false + matrix: + dep: [minimal, recent] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: actions/checkout@v4 + with: + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + rev: b2ac115 + path: maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@nightly + - name: "Set dependencies" + run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh nightly + + MSRV: # 2 jobs, one per lock file. + name: Test - 1.56.1 toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [minimal, recent] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: actions/checkout@v4 + with: + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + rev: b2ac115 + path: maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.56.1" + - name: "Set dependencies" + run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh msrv + + Integration: # 1 job for each Bitcoin Core version. + name: Integration tests - stable toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false matrix: - rust: [stable] bitcoinversion: [ "0.18.0", @@ -48,15 +97,11 @@ jobs: "0.21.0", ] steps: - - name: Checkout Crate - uses: actions/checkout@v2 - - name: Checkout Toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - name: Running test script + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Run integration tests" env: BITCOINVERSION: ${{ matrix.bitcoinversion }} - run: ./contrib/test.sh + run: ./contrib/integration_test.sh diff --git a/client/contrib/test_vars.sh b/client/contrib/test_vars.sh new file mode 100644 index 00000000..6ff05eab --- /dev/null +++ b/client/contrib/test_vars.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Test all these features with "std" enabled. +FEATURES_WITH_STD="" + +# Test all these features without "std" enabled. +FEATURES_WITHOUT_STD="verifymessage" + +# Run these examples. +EXAMPLES="retry_client:verifymessage" diff --git a/contrib/crates.sh b/contrib/crates.sh new file mode 100755 index 00000000..88955c6b --- /dev/null +++ b/contrib/crates.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Crates in this workspace to test (excl. fuzz an integration-tests). +CRATES=("json" "client") diff --git a/contrib/integration_test.sh b/contrib/integration_test.sh new file mode 100755 index 00000000..1522d404 --- /dev/null +++ b/contrib/integration_test.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Run the integration test optionally downloading Bitcoin Core binary if BITCOINVERSION is set. + +set -euo pipefail + +REPO_DIR=$(git rev-parse --show-toplevel) + +# Make all cargo invocations verbose. +export CARGO_TERM_VERBOSE=true + +main() { + # If a specific version of Bitcoin Core is set then download the binary. + if [ -n "${BITCOINVERSION+x}" ]; then + download_binary + fi + + need_cmd bitcoind + + cd integration_test + ./run.sh +} + +download_binary() { + wget https://bitcoincore.org/bin/bitcoin-core-$BITCOINVERSION/bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz + tar -xzvf bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz + export PATH=$PATH:$(pwd)/bitcoin-$BITCOINVERSION/bin +} + +err() { + echo "$1" >&2 + exit 1 +} + +need_cmd() { + if ! command -v "$1" > /dev/null 2>&1 + then err "need '$1' (command not found)" + fi +} + +# +# Main script +# +main "$@" +exit 0 diff --git a/contrib/test.sh b/contrib/test.sh deleted file mode 100755 index 2aa5a279..00000000 --- a/contrib/test.sh +++ /dev/null @@ -1,38 +0,0 @@ - -set -xe - -MSRV="1\.56" - -# Just echo all the relevant env vars to help debug Travis. -echo "RUSTFMTCHECK: \"$RUSTFMTCHECK\"" -echo "BITCOINVERSION: \"$BITCOINVERSION\"" -echo "PATH: \"$PATH\"" - -if [ -n "$RUSTFMTCHECK" ]; then - rustup component add rustfmt - cargo fmt --all -- --check -fi - -# Test pinned versions. -if cargo --version | grep ${MSRV}; then - cargo update -p tempfile --precise 3.3.0 - cargo update -p cc --precise 1.0.79 - cargo update -p log --precise 0.4.18 - cargo update -p serde_json --precise 1.0.96 - cargo update -p serde --precise 1.0.156 -fi - -# Integration test. -if [ -n "$BITCOINVERSION" ]; then - wget https://bitcoincore.org/bin/bitcoin-core-$BITCOINVERSION/bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz - tar -xzvf bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz - export PATH=$PATH:$(pwd)/bitcoin-$BITCOINVERSION/bin - cd integration_test - ./run.sh - exit 0 -else - # Regular build/unit test. - cargo build --verbose - cargo test --verbose - cargo build --verbose --examples -fi diff --git a/json/Cargo.toml b/json/Cargo.toml index 8f3d67cc..0bb6b4d6 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -24,3 +24,4 @@ serde = { version = "1", features = [ "derive" ] } serde_json = "1" bitcoin = { version = "0.31.0", features = ["serde", "rand-std"]} + diff --git a/json/contrib/test_vars.sh b/json/contrib/test_vars.sh new file mode 100644 index 00000000..0c25edc7 --- /dev/null +++ b/json/contrib/test_vars.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Test all these features with "std" enabled. +FEATURES_WITH_STD="" + +# Test all these features without "std" enabled. +FEATURES_WITHOUT_STD="" + +# Run these examples. +EXAMPLES=""