Skip to content

Commit

Permalink
CI: Run test with recent/minimal lock files
Browse files Browse the repository at this point in the history
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.

Update the CI scripts to use the two lockfiles, requires using `--lock`
for various `cargo` incantations.

While we are at it move the lock files to the crate root to be uniform
with `rust-bitcoin` and make them more obvious.
  • Loading branch information
tcharding committed Jul 20, 2023
1 parent b586df6 commit 5218af7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 28 deletions.
File renamed without changes.
File renamed without changes.
54 changes: 27 additions & 27 deletions contrib/_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,56 @@ if cargo --version | grep "1\.48"; then
fi

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

# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true

# Defaults / sanity checks
cargo build --all
cargo test --all
cargo build --locked --all
cargo test --locked --all

if [ "$DO_FEATURE_MATRIX" = true ]; then
cargo build --all --no-default-features
cargo test --all --no-default-features
cargo build --locked --all --no-default-features
cargo test --locked --all --no-default-features

# All features
cargo build --all --no-default-features --features="$FEATURES"
cargo test --all --no-default-features --features="$FEATURES"
cargo build --locked --all --no-default-features --features="$FEATURES"
cargo test --locked --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"
cargo build --locked --all --no-default-features --features="$feature"
cargo test --locked --all --no-default-features --features="$feature"
done
# Features tested with 'std' feature enabled.
for feature in ${FEATURES}
do
cargo build --all --no-default-features --features="std,$feature"
cargo test --all --no-default-features --features="std,$feature"
cargo build --locked --all --no-default-features --features="std,$feature"
cargo test --locked --all --no-default-features --features="std,$feature"
done
# Other combos
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --features="$FEATURES"
cargo test --all --features="rand serde"
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all --features="$FEATURES"
cargo test --locked --all --features="rand serde"

if [ "$NIGHTLY" = true ]; then
cargo test --all --all-features
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --all-features
cargo test --locked --all --all-features
RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --locked --all --all-features
fi

# Examples
cargo run --example sign_verify --features=bitcoin-hashes-std
cargo run --example sign_verify_recovery --features=recovery,bitcoin-hashes-std
cargo run --example generate_keys --features=rand-std
cargo run --locked --example sign_verify --features=bitcoin-hashes-std
cargo run --locked --example sign_verify_recovery --features=recovery,bitcoin-hashes-std
cargo run --locked --example generate_keys --features=rand-std
fi

if [ "$DO_LINT" = true ]
then
cargo clippy --all-features --all-targets -- -D warnings
cargo clippy --example sign_verify --features=bitcoin-hashes-std -- -D warnings
cargo clippy --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
cargo clippy --example generate_keys --features=rand-std -- -D warnings
cargo clippy --locked --all-features --all-targets -- -D warnings
cargo clippy --locked --example sign_verify --features=bitcoin-hashes-std -- -D warnings
cargo clippy --locked --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings
cargo clippy --locked --example generate_keys --features=rand-std -- -D warnings
fi

# Build the docs if told to (this only works with the nightly toolchain)
Expand Down Expand Up @@ -99,15 +99,15 @@ if [ "$DO_ASAN" = true ]; then
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
cargo test --locked --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
cargo clean
# The -Cllvm-args=-msan-eager-checks=0 flag was added to overcome this issue:
# https://github.com/rust-bitcoin/rust-secp256k1/pull/573#issuecomment-1399465995
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
cargo test --locked --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
cargo run --locked --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
cargo run --locked --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
fi

# Run formatter if told to.
Expand Down
22 changes: 21 additions & 1 deletion contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,24 @@ set -ex

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

$REPO_DIR/contrib/_test.sh
DEPS="recent minimal"

for dep in $DEPS
do
cp "Cargo-$dep.lock" Cargo.lock
$REPO_DIR/contrib/_test.sh

if [ "$dep" = recent ];
then
# We always test committed dependencies but we want to warn if they could've been updated
cargo update
if diff Cargo-recent.lock Cargo.lock;
then
echo Dependencies are up to date
else
echo "::warning file=Cargo-recent.lock::Dependencies could be updated"
fi
fi
done

exit 0

0 comments on commit 5218af7

Please sign in to comment.