Skip to content

Commit 7058539

Browse files
committed
Merge #632: CI: test with commited lock files
3da39c6 Run test with recent/minimal lock files (Tobin C. Harding) 4b9168c Run WASM tests from test wrapper script (Tobin C. Harding) 637d08f Add a layer of indirection to the test script (Tobin C. Harding) d9b70d2 Remove trailing whitespace (Tobin C. Harding) 461bae9 Move recent/minimal lock files (Tobin C. Harding) Pull request description: A while back we added two lock files, one for testing with recent dependency versions and one for testing with minimal dependency versions but at the time we never used them in CI. Move the two current lock files and use them in CI (mirroring what is done in `rust-bitcoin`). ACKs for top commit: apoelstra: ACK 3da39c6 Tree-SHA512: 5d293689e8a67373cbf0d6b04894c38e636bb7da19db62ac2cc1b83f1dc8184e92169a834d9adf4de3c61c34d5f6f443a1be1d0c2503bb03f08fc486d68beb71
2 parents 6f05b57 + 3da39c6 commit 7058539

File tree

4 files changed

+150
-119
lines changed

4 files changed

+150
-119
lines changed
File renamed without changes.
File renamed without changes.

contrib/_test.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
REPO_DIR=$(git rev-parse --show-toplevel)
6+
FEATURES="bitcoin-hashes global-context lowmemory rand recovery serde std alloc bitcoin-hashes-std rand-std"
7+
8+
cargo --version
9+
rustc --version
10+
11+
# Work out if we are using a nightly toolchain.
12+
NIGHTLY=false
13+
if cargo --version | grep nightly; then
14+
NIGHTLY=true
15+
fi
16+
17+
# Pin dependencies as required if we are using MSRV toolchain.
18+
if cargo --version | grep "1\.48"; then
19+
cargo update -p wasm-bindgen-test --precise 0.3.34
20+
cargo update -p serde_test --precise 1.0.175
21+
fi
22+
23+
# Test if panic in C code aborts the process (either with a real panic or with SIGILL)
24+
cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 \
25+
| tee /dev/stderr \
26+
| grep "SIGILL\\|\[libsecp256k1] illegal argument. !rustsecp256k1_v0_._._fe_is_zero(&ge->x)"
27+
28+
# Make all cargo invocations verbose
29+
export CARGO_TERM_VERBOSE=true
30+
31+
# Defaults / sanity checks
32+
cargo build --locked --all
33+
cargo test --locked --all
34+
35+
if [ "$DO_FEATURE_MATRIX" = true ]; then
36+
cargo build --locked --all --no-default-features
37+
cargo test --locked --all --no-default-features
38+
39+
# All features
40+
cargo build --locked --all --no-default-features --features="$FEATURES"
41+
cargo test --locked --all --no-default-features --features="$FEATURES"
42+
# Single features
43+
for feature in ${FEATURES}
44+
do
45+
cargo build --locked --all --no-default-features --features="$feature"
46+
cargo test --locked --all --no-default-features --features="$feature"
47+
done
48+
# Features tested with 'std' feature enabled.
49+
for feature in ${FEATURES}
50+
do
51+
cargo build --locked --all --no-default-features --features="std,$feature"
52+
cargo test --locked --all --no-default-features --features="std,$feature"
53+
done
54+
# Other combos
55+
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all
56+
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all --features="$FEATURES"
57+
cargo test --locked --all --features="rand serde"
58+
59+
if [ "$NIGHTLY" = true ]; then
60+
cargo test --locked --all --all-features
61+
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all --all-features
62+
fi
63+
64+
# Examples
65+
cargo run --locked --example sign_verify --features=bitcoin-hashes-std
66+
cargo run --locked --example sign_verify_recovery --features=recovery,bitcoin-hashes-std
67+
cargo run --locked --example generate_keys --features=rand-std
68+
fi
69+
70+
if [ "$DO_LINT" = true ]
71+
then
72+
cargo clippy --locked --all-features --all-targets -- -D warnings
73+
cargo clippy --locked --example sign_verify --features=bitcoin-hashes-std -- -D warnings
74+
cargo clippy --locked --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
75+
cargo clippy --locked --example generate_keys --features=rand-std -- -D warnings
76+
fi
77+
78+
# Build the docs if told to (this only works with the nightly toolchain)
79+
if [ "$DO_DOCSRS" = true ]; then
80+
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
81+
fi
82+
83+
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
84+
# above this checks that we feature guarded docs imports correctly.
85+
if [ "$DO_DOCS" = true ]; then
86+
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
87+
fi
88+
89+
# Address Sanitizer
90+
if [ "$DO_ASAN" = true ]; then
91+
clang --version
92+
cargo clean
93+
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
94+
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
95+
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
96+
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
97+
cargo clean
98+
# The -Cllvm-args=-msan-eager-checks=0 flag was added to overcome this issue:
99+
# https://github.com/rust-bitcoin/rust-secp256k1/pull/573#issuecomment-1399465995
100+
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
101+
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \
102+
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
103+
104+
pushd "$REPO_DIR/no_std_test" > /dev/null || exit 1
105+
# See https://github.com/rust-bitcoin/rust-secp256k1/pull/641#issuecomment-1671598914
106+
cargo update -p cc --precise 1.0.79
107+
popd > /dev/null || exit 1
108+
109+
cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
110+
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
111+
fi
112+
113+
# Run formatter if told to.
114+
if [ "$DO_FMT" = true ]; then
115+
if [ "$NIGHTLY" = false ]; then
116+
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
117+
exit 1
118+
fi
119+
rustup component add rustfmt
120+
cargo fmt --check || exit 1
121+
fi
122+
123+
# Bench if told to, only works with non-stable toolchain (nightly, beta).
124+
if [ "$DO_BENCH" = true ]
125+
then
126+
RUSTFLAGS='--cfg=bench' cargo bench --features=recovery,rand-std
127+
fi
128+
129+
exit 0

contrib/test.sh

Lines changed: 21 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -3,136 +3,38 @@
33
set -ex
44

55
REPO_DIR=$(git rev-parse --show-toplevel)
6-
FEATURES="bitcoin-hashes global-context lowmemory rand recovery serde std alloc bitcoin-hashes-std rand-std"
7-
8-
cargo --version
9-
rustc --version
10-
11-
# Work out if we are using a nightly toolchain.
12-
NIGHTLY=false
13-
if cargo --version | grep nightly; then
14-
NIGHTLY=true
15-
fi
16-
17-
# Pin dependencies as required if we are using MSRV toolchain.
18-
if cargo --version | grep "1\.48"; then
19-
cargo update -p wasm-bindgen-test --precise 0.3.34
20-
cargo update -p serde_test --precise 1.0.175
21-
fi
22-
23-
# Test if panic in C code aborts the process (either with a real panic or with SIGILL)
24-
cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 \
25-
| tee /dev/stderr \
26-
| grep "SIGILL\\|\[libsecp256k1] illegal argument. !rustsecp256k1_v0_._._fe_is_zero(&ge->x)"
27-
28-
# Make all cargo invocations verbose
29-
export CARGO_TERM_VERBOSE=true
30-
31-
# Defaults / sanity checks
32-
cargo build --all
33-
cargo test --all
34-
35-
if [ "$DO_FEATURE_MATRIX" = true ]; then
36-
cargo build --all --no-default-features
37-
cargo test --all --no-default-features
38-
39-
# All features
40-
cargo build --all --no-default-features --features="$FEATURES"
41-
cargo test --all --no-default-features --features="$FEATURES"
42-
# Single features
43-
for feature in ${FEATURES}
44-
do
45-
cargo build --all --no-default-features --features="$feature"
46-
cargo test --all --no-default-features --features="$feature"
47-
done
48-
# Features tested with 'std' feature enabled.
49-
for feature in ${FEATURES}
50-
do
51-
cargo build --all --no-default-features --features="std,$feature"
52-
cargo test --all --no-default-features --features="std,$feature"
53-
done
54-
# Other combos
55-
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all
56-
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --features="$FEATURES"
57-
cargo test --all --features="rand serde"
58-
59-
if [ "$NIGHTLY" = true ]; then
60-
cargo test --all --all-features
61-
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --all-features
62-
fi
63-
64-
# Examples
65-
cargo run --example sign_verify --features=bitcoin-hashes-std
66-
cargo run --example sign_verify_recovery --features=recovery,bitcoin-hashes-std
67-
cargo run --example generate_keys --features=rand-std
68-
fi
69-
70-
if [ "$DO_LINT" = true ]
71-
then
72-
cargo clippy --all-features --all-targets -- -D warnings
73-
cargo clippy --example sign_verify --features=bitcoin-hashes-std -- -D warnings
74-
cargo clippy --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
75-
cargo clippy --example generate_keys --features=rand-std -- -D warnings
76-
fi
77-
78-
# Build the docs if told to (this only works with the nightly toolchain)
79-
if [ "$DO_DOCSRS" = true ]; then
80-
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
81-
fi
82-
83-
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
84-
# above this checks that we feature guarded docs imports correctly.
85-
if [ "$DO_DOCS" = true ]; then
86-
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
87-
fi
6+
DEPS="recent minimal"
887

898
# Webassembly stuff
9+
#
10+
# The wasm-pack command does not correctly pass args to cargo so we cannot use --locked and test
11+
# with per-commited lockfiles (recent/minimal). Just run the WASM tests from here instead.
9012
if [ "$DO_WASM" = true ]; then
9113
clang --version
9214
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack
9315
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml
9416
CC=clang wasm-pack build
9517
CC=clang wasm-pack test --node
96-
fi
9718

98-
# Address Sanitizer
99-
if [ "$DO_ASAN" = true ]; then
100-
clang --version
101-
cargo clean
102-
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
103-
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
104-
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
105-
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
106-
cargo clean
107-
# The -Cllvm-args=-msan-eager-checks=0 flag was added to overcome this issue:
108-
# https://github.com/rust-bitcoin/rust-secp256k1/pull/573#issuecomment-1399465995
109-
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
110-
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \
111-
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
112-
113-
pushd "$REPO_DIR/no_std_test" > /dev/null || exit 1
114-
# See https://github.com/rust-bitcoin/rust-secp256k1/pull/641#issuecomment-1671598914
115-
cargo update -p cc --precise 1.0.79
116-
popd > /dev/null || exit 1
117-
118-
cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
119-
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
19+
exit 0
12020
fi
12121

122-
# Run formatter if told to.
123-
if [ "$DO_FMT" = true ]; then
124-
if [ "$NIGHTLY" = false ]; then
125-
echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)"
126-
exit 1
127-
fi
128-
rustup component add rustfmt
129-
cargo fmt --check || exit 1
130-
fi
22+
for dep in $DEPS
23+
do
24+
cp "Cargo-$dep.lock" Cargo.lock
25+
$REPO_DIR/contrib/_test.sh
13126

132-
# Bench if told to, only works with non-stable toolchain (nightly, beta).
133-
if [ "$DO_BENCH" = true ]
134-
then
135-
RUSTFLAGS='--cfg=bench' cargo bench --features=recovery,rand-std
136-
fi
27+
if [ "$dep" = recent ];
28+
then
29+
# We always test committed dependencies but we want to warn if they could've been updated
30+
cargo update
31+
if diff Cargo-recent.lock Cargo.lock;
32+
then
33+
echo "Dependencies are up to date"
34+
else
35+
echo "::warning file=Cargo-recent.lock::Dependencies could be updated"
36+
fi
37+
fi
38+
done
13739

13840
exit 0

0 commit comments

Comments
 (0)