From 7ce2abf976eabc5a0a435c4ba8d8a19a43ef9957 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 2 May 2024 10:24:52 +1000 Subject: [PATCH] WIP: CI: Use script from rust-bitcoin-maintainer-tools WIP remember to fix integration test job. We have a CI script in the `rust-bitcoin-maintainer-tools` repository, lets use it. --- .github/workflows/rust.yml | 138 +++++++++++++++++++++--------------- client/contrib/test_vars.sh | 10 +++ contrib/crates.sh | 4 ++ contrib/pin.sh | 12 ++++ contrib/test.sh | 35 --------- json/contrib/test_vars.sh | 10 +++ 6 files changed, 117 insertions(+), 92 deletions(-) create mode 100644 client/contrib/test_vars.sh create mode 100755 contrib/crates.sh create mode 100755 contrib/pin.sh delete mode 100755 contrib/test.sh create mode 100644 json/contrib/test_vars.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2e7d3d3a..fd888f01 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,62 +1,86 @@ -on: [push, pull_request] +on: + push: + branches: + - master + - 'test-ci/**' + pull_request: name: Continuous integration jobs: - tests: - name: Tests - runs-on: ubuntu-latest - strategy: - matrix: - include: - - rust: stable - env: - RUSTFMTCHK: true - - rust: nightly - env: - RUSTFMTCHK: false - - rust: 1.56.1 - env: - RUSTFMTCHK: false - 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 - env: ${{ matrix.env }} - run: ./contrib/test.sh + Stable: # 2 jobs, one per lock file. + name: Test - stable 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: tcharding/rust-bitcoin-maintainer-tools + ref: 05-02-ci + path: maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Copy lock file" + 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 - runs-on: ubuntu-latest - strategy: - matrix: - rust: [stable] - bitcoinversion: - [ - "0.18.0", - "0.18.1", - "0.19.0.1", - "0.19.1", - "0.20.0", - "0.20.1", - "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 - env: - BITCOINVERSION: ${{ matrix.bitcoinversion }} - run: ./contrib/test.sh + 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: "Select toolchain" + uses: dtolnay/rust-toolchain@nightly + - name: "Copy lock file" + 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: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.56.1" + - name: "Copy lock file" + run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh msrv + + Format: # 1 jobs, uses recent lock file. + needs: Prepare + name: Format - stable toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [recent] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Copy lock file" + run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock + - name: "Check formatting" + run: ./maintainer-tools/ci/run_task.sh fmt diff --git a/client/contrib/test_vars.sh b/client/contrib/test_vars.sh new file mode 100644 index 00000000..0c25edc7 --- /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="" + +# Run these examples. +EXAMPLES="" 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/pin.sh b/contrib/pin.sh new file mode 100755 index 00000000..7dc93144 --- /dev/null +++ b/contrib/pin.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Do pinning as required for current MSRV. + +set -euo pipefail + +cargo update -p tempfile --precise 3.6.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 + diff --git a/contrib/test.sh b/contrib/test.sh deleted file mode 100755 index e308ce3c..00000000 --- a/contrib/test.sh +++ /dev/null @@ -1,35 +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 log --precise 0.4.18 -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/contrib/test_vars.sh b/json/contrib/test_vars.sh new file mode 100644 index 00000000..aac6abd2 --- /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="retry_client"