Skip to content

Commit c6b103a

Browse files
committed
CI: Run test with recent/minimal lock files
Update the CI scripts to use the minimal/recent lockfiles, requires using `--lock` for various `cargo` incantations.
1 parent 48d7fd8 commit c6b103a

File tree

3 files changed

+52
-25
lines changed

3 files changed

+52
-25
lines changed

.github/workflows/rust.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ jobs:
115115
- name: Running WASM tests
116116
env:
117117
DO_WASM: true
118-
run: ./contrib/test.sh
118+
# We do not control the cargo commands so cannot us --locked to lock the manifest.
119+
run: ./contrib/_test.sh

contrib/_test.sh

+29-23
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,56 @@ if cargo --version | grep "1\.48"; then
2020
fi
2121

2222
# Test if panic in C code aborts the process (either with a real panic or with SIGILL)
23-
cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 | tee /dev/stderr | grep "SIGILL\\|panicked at '\[libsecp256k1\]"
23+
cargo test --locked -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 | tee /dev/stderr | grep "SIGILL\\|panicked at '\[libsecp256k1\]"
2424

2525
# Make all cargo invocations verbose
2626
export CARGO_TERM_VERBOSE=true
2727

2828
# Defaults / sanity checks
29-
cargo build --all
30-
cargo test --all
29+
cargo build --locked --all
30+
cargo test --locked --all
3131

3232
if [ "$DO_FEATURE_MATRIX" = true ]; then
33-
cargo build --all --no-default-features
34-
cargo test --all --no-default-features
33+
cargo build --locked --all --no-default-features
34+
cargo test --locked --all --no-default-features
3535

3636
# All features
37-
cargo build --all --no-default-features --features="$FEATURES"
38-
cargo test --all --no-default-features --features="$FEATURES"
37+
cargo build --locked --all --no-default-features --features="$FEATURES"
38+
cargo test --locked --all --no-default-features --features="$FEATURES"
3939
# Single features
4040
for feature in ${FEATURES}
4141
do
42-
cargo build --all --no-default-features --features="$feature"
43-
cargo test --all --no-default-features --features="$feature"
42+
cargo build --locked --all --no-default-features --features="$feature"
43+
cargo test --locked --all --no-default-features --features="$feature"
4444
done
4545
# Features tested with 'std' feature enabled.
4646
for feature in ${FEATURES}
4747
do
48-
cargo build --all --no-default-features --features="std,$feature"
49-
cargo test --all --no-default-features --features="std,$feature"
48+
cargo build --locked --all --no-default-features --features="std,$feature"
49+
cargo test --locked --all --no-default-features --features="std,$feature"
5050
done
5151
# Other combos
52-
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all
53-
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --features="$FEATURES"
54-
cargo test --all --features="rand serde"
52+
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all
53+
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all --features="$FEATURES"
54+
cargo test --locked --all --features="rand serde"
5555

5656
if [ "$NIGHTLY" = true ]; then
57-
cargo test --all --all-features
58-
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --all-features
57+
cargo test --locked --all --all-features
58+
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all --all-features
5959
fi
6060

6161
# Examples
62-
cargo run --example sign_verify --features=bitcoin-hashes-std
63-
cargo run --example sign_verify_recovery --features=recovery,bitcoin-hashes-std
64-
cargo run --example generate_keys --features=rand-std
62+
cargo run --locked --example sign_verify --features=bitcoin-hashes-std
63+
cargo run --locked --example sign_verify_recovery --features=recovery,bitcoin-hashes-std
64+
cargo run --locked --example generate_keys --features=rand-std
6565
fi
6666

6767
if [ "$DO_LINT" = true ]
6868
then
69-
cargo clippy --all-features --all-targets -- -D warnings
70-
cargo clippy --example sign_verify --features=bitcoin-hashes-std -- -D warnings
71-
cargo clippy --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
72-
cargo clippy --example generate_keys --features=rand-std -- -D warnings
69+
cargo clippy --locked --all-features --all-targets -- -D warnings
70+
cargo clippy --locked --example sign_verify --features=bitcoin-hashes-std -- -D warnings
71+
cargo clippy --locked --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
72+
cargo clippy --locked --example generate_keys --features=rand-std -- -D warnings
7373
fi
7474

7575
# Build the docs if told to (this only works with the nightly toolchain)
@@ -87,9 +87,15 @@ fi
8787
if [ "$DO_WASM" = true ]; then
8888
clang --version
8989
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack
90+
91+
cp Cargo.toml orig-Cargo.toml
9092
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml
93+
9194
CC=clang wasm-pack build
9295
CC=clang wasm-pack test --node
96+
97+
rm Cargo.toml
98+
mv orig-Cargo.toml Cargo.toml
9399
fi
94100

95101
# Address Sanitizer

contrib/test.sh

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,24 @@ set -ex
44

55
REPO_DIR=$(git rev-parse --show-toplevel)
66

7-
$REPO_DIR/contrib/_test.sh
7+
DEPS="recent minimal"
8+
9+
for dep in $DEPS
10+
do
11+
cp "Cargo-$dep.lock" Cargo.lock
12+
$REPO_DIR/contrib/_test.sh
13+
14+
if [ "$dep" = recent ];
15+
then
16+
# We always test committed dependencies but we want to warn if they could've been updated
17+
cargo update
18+
if diff Cargo-recent.lock Cargo.lock;
19+
then
20+
echo Dependencies are up to date
21+
else
22+
echo "::warning file=Cargo-recent.lock::Dependencies could be updated"
23+
fi
24+
fi
25+
done
26+
27+
exit 0

0 commit comments

Comments
 (0)