Skip to content

Commit e4364fe

Browse files
committed
Merge rust-bitcoin/rust-miniscript#405: Improve the test script and CI pipeline
ed51323a0bb3257b09abfb5eb51ca21815b815af Rename and simplify integration test job (Tobin C. Harding) 27df8630e5c7f419d5f1a3d0d7b2095f3731ab82 Run feature matrix tests (Tobin C. Harding) ca9988de6cb441c5b4293d78fc0b3b10920d5333 Add additional information to nightly job (Tobin C. Harding) a5718f76a9885a1e2c0d51992527bc3ed115fb94 Explicitly exit test script with 0 (Tobin C. Harding) 3913a08dfb3d55fd7b0153f66bb8c6d36fca0f6f Improve test coverage (Tobin C. Harding) 04577224f72bf66e24de7c5d0d0137797a706ed3 Do not run formatter in subprocess (Tobin C. Harding) b072a5f8122fdc0ed162fb61b4cb748b46286d24 Do not run fuzzer in subprocess (Tobin C. Harding) 62d5169f210907d1bfe11085f1601fde50ede304 Fail script if command fails (Tobin C. Harding) Pull request description: Make an effort to improve the test script, taking inspiration for the test script in `rust-secp256k1`. Since Bash can, at times, be a bit obscure, I made extra effort to do very simple discreet patches. First part of the PR is fixes to the test script, second part is improvements to the CI pipeline. ACKs for top commit: sanket1729: ACK ed51323a0bb3257b09abfb5eb51ca21815b815af apoelstra: ACK ed51323a0bb3257b09abfb5eb51ca21815b815af Tree-SHA512: 9e150b1faebc0d5ae73f7779129c1e8ec5c48bb5e73380793266f02b73636427a45aa378db6cbab8f815f655fd3ead2fffab6000bdb92cf7c443de507c72d261
2 parents 3bde42a + 5ababc5 commit e4364fe

File tree

2 files changed

+44
-35
lines changed

2 files changed

+44
-35
lines changed

.github/workflows/rust.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: ./contrib/test.sh
2828

2929
Nightly:
30-
name: Bench + Docs + Fmt
30+
name: Nightly - Bench + Docs + Fmt
3131
runs-on: ubuntu-latest
3232
steps:
3333
- name: Checkout Crate
@@ -51,14 +51,12 @@ jobs:
5151
DO_FMT: true
5252
run: ./contrib/test.sh
5353

54-
UnitTests:
54+
Tests:
5555
name: Tests
5656
runs-on: ubuntu-latest
5757
strategy:
5858
matrix:
59-
rust:
60-
- 1.41.1
61-
- beta
59+
rust: [stable, beta, nightly, 1.41.1]
6260
steps:
6361
- name: Checkout Crate
6462
uses: actions/checkout@v2
@@ -69,23 +67,21 @@ jobs:
6967
toolchain: ${{ matrix.rust }}
7068
override: true
7169
- name: Running cargo
70+
env:
71+
DO_FEATURE_MATRIX: true
7272
run: ./contrib/test.sh
7373

74-
AllTests:
75-
name: Unit + Int tests
74+
IntTests:
75+
name: Integration tests
7676
runs-on: ubuntu-latest
77-
strategy:
78-
matrix:
79-
rust:
80-
- stable
8177
steps:
8278
- name: Checkout Crate
8379
uses: actions/checkout@v2
8480
- name: Checkout Toolchain
8581
uses: actions-rs/toolchain@v1
8682
with:
8783
profile: minimal
88-
toolchain: ${{ matrix.rust }}
84+
toolchain: stable
8985
override: true
9086
- name: Running cargo
9187
env:

contrib/test.sh

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh -ex
22

3+
set -e
4+
35
FEATURES="compiler use-serde rand"
46

57
# Use toolchain if explicitly specified
@@ -8,41 +10,50 @@ then
810
alias cargo="cargo +$TOOLCHAIN"
911
fi
1012

13+
cargo --version
14+
rustc --version
15+
1116
# Format if told to
1217
if [ "$DO_FMT" = true ]
1318
then
14-
(
15-
rustup component add rustfmt
16-
cargo fmt --all -- --check
17-
)
19+
rustup component add rustfmt
20+
cargo fmt --all -- --check
1821
fi
1922

2023
# Fuzz if told to
2124
if [ "$DO_FUZZ" = true ]
2225
then
23-
(
24-
cd fuzz
25-
cargo test --verbose
26-
./travis-fuzz.sh
27-
# Exit out of the fuzzer,
28-
# run stable tests in other CI vms
29-
exit 0
30-
)
26+
cd fuzz
27+
cargo test --verbose
28+
./travis-fuzz.sh
29+
30+
# Exit out of the fuzzer, do not run other tests.
31+
exit 0
3132
fi
3233

33-
# Test without any features first
34-
cargo test --verbose
34+
# Defaults / sanity checks
35+
cargo test
3536

36-
# Test each feature
37-
for feature in ${FEATURES}
38-
do
39-
cargo test --verbose --features="$feature"
40-
done
37+
if [ "$DO_FEATURE_MATRIX" = true ]
38+
then
39+
# All features
40+
cargo test --features="$FEATURES"
41+
42+
# Single features
43+
for feature in ${FEATURES}
44+
do
45+
cargo test --features="$feature"
46+
done
4147

42-
# Also build and run each example to catch regressions
43-
cargo build --examples
44-
# run all examples
45-
run-parts ./target/debug/examples
48+
# Run all the examples
49+
cargo build --examples
50+
cargo run --example htlc --features=compiler
51+
cargo run --example parse
52+
cargo run --example sign_multisig
53+
cargo run --example verify_tx > /dev/null
54+
cargo run --example psbt
55+
cargo run --example xpub_descriptors
56+
fi
4657

4758
# Bench if told to (this only works with the nightly toolchain)
4859
if [ "$DO_BENCH" = true ]
@@ -67,3 +78,5 @@ if [ -n "$BITCOINVERSION" ]; then
6778
rm -rf bitcoin-$BITCOINVERSION
6879
exit 0
6980
fi
81+
82+
exit 0

0 commit comments

Comments
 (0)