From a9646ce7418daa3ad9e732c93842876090a3c22e Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 2 May 2024 15:35:14 +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 | 24 ++++ .github/workflows/rust.yml | 225 ++++++++++++++++++++++++++++-------- contrib/crates.sh | 4 + contrib/pin.sh | 7 ++ contrib/test_vars.sh | 15 +++ contrib/whitelist_deps.sh | 4 + 6 files changed, 228 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/README.md create mode 100755 contrib/crates.sh create mode 100755 contrib/pin.sh create mode 100644 contrib/test_vars.sh create mode 100644 contrib/whitelist_deps.sh diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 000000000..df332f741 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,24 @@ +# 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. `Lint` +7. `Docs` +8. `Docsrs` +9. `Bench` +10. `Format` +10. `Int-tests` +11. `Embedded` diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bb5b9b704..033cc6d93 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,64 +1,190 @@ -on: [push, pull_request] +--- # rust-miniscript 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: - Nightly: - name: Nightly - Bench + Docs + Fmt + 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 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: nightly - override: true - - name: Install clippy + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + 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 + + 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 + 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: # 1 jobs, minimal lock file only. + name: Test - 1.56.1 toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [minimal] + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Checkout maintainer tools" + uses: actions/checkout@v4 + with: + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + 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 + + Lint: + name: Lint - nightly toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [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 + path: maintainer-tools + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@nightly + - name: "Install clippy" run: rustup component add clippy - - name: Running benchmarks - env: - DO_BENCH: true - run: ./contrib/test.sh - - name: Building docs - env: - DO_DOCS: true - run: ./contrib/test.sh - - name: Running formatter - env: - DO_FMT: true - run: ./contrib/test.sh - - name: Running linter - env: - DO_LINT: true - run: ./contrib/test.sh + - name: "Set dependencies" + run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock + - name: "Run test script" + run: ./maintainer-tools/ci/run_task.sh lint - Int-tests: - name: Integration tests + Docs: + name: Docs - stable toolchain runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [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: stable - override: true - - name: Running integration tests - run: ./contrib/integration_test.sh + repository: rust-bitcoin/rust-bitcoin-maintainer-tools + 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 docs + + Docsrs: + name: Docs - nightly toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + dep: [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 + 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 docsrs - Tests: - name: Tests + Bench: + name: Bench - nightly toolchain runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - include: - - rust: stable - - rust: beta - - rust: nightly - - rust: "1.56.1" + dep: [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 + 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 bench + + Format: # 1 jobs, run cargo fmt directly. + name: Format - nightly toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@nightly + - name: "Install rustfmt" + run: rustup component add rustfmt + - name: "Check formatting" + run: cargo +nightly fmt --all -- --check + + Int-tests: + name: Integration tests + runs-on: ubuntu-latest steps: - name: Checkout Crate uses: actions/checkout@v2 @@ -66,13 +192,10 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: stable override: true - - name: Running cargo - env: - DO_FEATURE_MATRIX: true - DO_NO_STD: true - run: ./contrib/test.sh + - name: Running integration tests + run: ./contrib/integration_test.sh Embedded: runs-on: ubuntu-latest diff --git a/contrib/crates.sh b/contrib/crates.sh new file mode 100755 index 000000000..31a886cfb --- /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=(".") # Non-workspaces don't have crates. diff --git a/contrib/pin.sh b/contrib/pin.sh new file mode 100755 index 000000000..dd7c2227e --- /dev/null +++ b/contrib/pin.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# +# Do pinning as required for current MSRV. + +set -euo pipefail + +cargo update -p cc --precise 1.0.79 diff --git a/contrib/test_vars.sh b/contrib/test_vars.sh new file mode 100644 index 000000000..45df21f29 --- /dev/null +++ b/contrib/test_vars.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Test all these features with "std" enabled. +FEATURES_WITH_STD="compiler trace serde rand base64" + +# Test all these features with "no-std" enabled. +# rust-miniscript only: https://github.com/rust-bitcoin/rust-miniscript/issues/681 +FEATURES_WITH_NO_STD="compiler trace serde rand base64" + +# Test all these features without "std" enabled. +FEATURES_WITHOUT_STD="" + +# Run these examples. +# Note `examples/big` should not be run. +EXAMPLES="htlc:std,compiler parse:std sign_multisig:std verify_tx:std xpub_descriptors:std taproot:std,compiler psbt_sign_finalize:std,base64" diff --git a/contrib/whitelist_deps.sh b/contrib/whitelist_deps.sh new file mode 100644 index 000000000..2b699fdad --- /dev/null +++ b/contrib/whitelist_deps.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Remove once we upgrade to `bitcoin v0.32.0`. +DUPLICATE_DEPS=("bech32")