diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7d163918a..2a47c458f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,37 +3,49 @@ on: [push, pull_request] name: Continuous integration jobs: - lint_fuzz_stable: - name: Lint + Fuzz + Sanity: + name: Sanity + Fmt + steps: + - name: Checkout Crate + uses: actions/checkout@v2 + - name: Checkout Toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Running cargo fmt + env: + DO_FMT: true + run: ./contrib/test.sh + - name: Running integration tests + env: + BITCOINVERSION: '22.0' + run: ./contrib/test.sh + + Tests: + name: Tests runs-on: ubuntu-latest strategy: matrix: - rust: - - 1.58.0 + rust: [stable, beta, nightly, 1.41.1] steps: - name: Checkout Crate uses: actions/checkout@v2 - - name: Install hongfuzz dependancies - run: sudo apt install build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev - name: Checkout Toolchain uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.rust }} override: true - - name: Running fuzzer + - name: Running cargo env: - DO_FUZZ: true - DO_LINT: true + DO_FEATURE_MATRIX: true run: ./contrib/test.sh - bench_nightly: - name: Bench + Tests + Bench: + name: Bench runs-on: ubuntu-latest - strategy: - matrix: - rust: - - nightly steps: - name: Checkout Crate uses: actions/checkout@v2 @@ -41,47 +53,35 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: nightly override: true - - name: Running cargo test + - name: Running benchmarks env: DO_BENCH: true run: ./contrib/test.sh - UnitTests: - name: Tests + Fuzz: + name: Fuzz runs-on: ubuntu-latest - strategy: - matrix: - rust: - - 1.29.0 - - beta steps: - name: Checkout Crate uses: actions/checkout@v2 + - name: Install hongfuzz dependencies + run: sudo apt install build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev - name: Checkout Toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: stable override: true - - name: Pin deps if rust 1.29 - if: matrix.rust == '1.29.0' - run: | - cargo generate-lockfile --verbose && \ - cargo update --verbose --package "cc" --precise "1.0.41" && \ - cargo update --verbose --package "serde" --precise "1.0.98" && \ - cargo update --verbose --package "serde_derive" --precise "1.0.98" - - name: Running cargo + - name: Running fuzzer + env: + DO_FUZZ: true run: ./contrib/test.sh - AllTests: - name: Unit + Int tests + Integration: + name: Integration tests against bitcoind runs-on: ubuntu-latest - strategy: - matrix: - rust: - - stable steps: - name: Checkout Crate uses: actions/checkout@v2 @@ -89,7 +89,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: stable override: true - name: Running cargo env: diff --git a/contrib/test.sh b/contrib/test.sh index 6b5403380..8c028720c 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -1,5 +1,7 @@ #!/bin/sh -ex +set -e + FEATURES="compiler use-serde rand" # Use toolchain if explicitly specified @@ -8,8 +10,11 @@ then alias cargo="cargo +$TOOLCHAIN" fi +cargo --version +rustc --version + # Lint if told to -if [ "$DO_LINT" = true ] +if [ "$DO_FMT" = true ] then ( rustup component add rustfmt @@ -17,6 +22,38 @@ then ) fi +# Defaults / sanity checks +cargo build --all +cargo test --all + +if [ "$DO_FEATURE_MATRIX" = true ] +then + # All features + cargo build --all --no-default-features --features="$FEATURES" + cargo test --all --no-default-features --features="$FEATURES" + # Single features + for feature in ${FEATURES} + do + cargo build --all --no-default-features --features="$feature" + cargo test --all --no-default-features --features="$feature" + done + + # Also build and run each example to catch regressions + cargo build --examples + + cargo run --example htlc --features=compiler + for example in "parse psbt sign_multisig verify_tx xpub_descriptors" + do + cargo run --example $example + done +fi + +# Bench if told to +if [ "$DO_BENCH" = true ] +then + cargo bench --features="unstable compiler" +fi + # Fuzz if told to if [ "$DO_FUZZ" = true ] then @@ -30,26 +67,6 @@ then ) fi -# Test without any features first -cargo test --verbose - -# Test each feature -for feature in ${FEATURES} -do - cargo test --verbose --features="$feature" -done - -# Also build and run each example to catch regressions -cargo build --examples -# run all examples -run-parts ./target/debug/examples - -# Bench if told to -if [ "$DO_BENCH" = true ] -then - cargo bench --features="unstable compiler" -fi - # Run Integration tests if told so if [ -n "$BITCOINVERSION" ]; then set -e