Skip to content

Fix test script silent failure #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ on: [push, pull_request]
name: Continuous integration

jobs:
bench_nightly:
name: Nightly - ASan + Bench
Nightly:
name: Nightly - ASan + Bench + Docs
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- name: Checkout Crate
- name: Checkout Crate
uses: actions/checkout@v2
- name: Install clang for ASan
run: sudo apt-get install -y clang
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: nightly
override: true
components: rust-src
- name: Running address sanitizer
Expand All @@ -28,27 +26,17 @@ jobs:
env:
DO_BENCH: true
run: ./contrib/test.sh
- name: Building docs
env:
DO_DOCS: true
run: ./contrib/test.sh

Tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
include:
- rust: stable
env:
DO_FEATURE_MATRIX: true
DO_WASM: true
- rust: beta
env:
DO_FEATURE_MATRIX: true
- rust: nightly
env:
DO_FEATURE_MATRIX: true
DO_DOCS: true
- rust: 1.29.0
env:
DO_FEATURE_MATRIX: true
rust: [stable, beta, nightly, 1.29.0]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
Expand All @@ -62,6 +50,29 @@ jobs:
if: matrix.rust == '1.29.0'
run: cargo generate-lockfile --verbose && cargo update -p cc --precise "1.0.41" --verbose
- name: Running cargo
env: ${{ matrix.env }}
env:
DO_FEATURE_MATRIX: true
run: ./contrib/test.sh

WASM:
name: WASM
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta, nightly] # No 1.29 because WASM requires Rust 1.30
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Install clang
run: sudo apt-get install -y clang-9
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rust-src
- name: Running WASM tests
env:
DO_WASM: true
run: ./contrib/test.sh
20 changes: 12 additions & 8 deletions contrib/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh -ex

set -e

# TODO: Add "alloc" once we bump MSRV to past 1.29
FEATURES="bitcoin_hashes global-context lowmemory rand recovery serde std"
# These features are typically enabled along with the 'std' feature, so we test
Expand Down Expand Up @@ -64,24 +66,25 @@ fi

# Webassembly stuff
if [ "$DO_WASM" = true ]; then
clang --version &&
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack &&
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
CC=clang-9 wasm-pack build &&
CC=clang-9 wasm-pack test --node;
clang-9 --version
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml
CC=clang-9 wasm-pack build
CC=clang-9 wasm-pack test --node
fi

# Address Sanitizer
if [ "$DO_ASAN" = true ]; then
clang --version
cargo clean
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 clean &&
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
cargo clean
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
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"
fi
Expand All @@ -94,3 +97,4 @@ if [ "$DO_BENCH" = true ]; then
cargo bench --all --features="unstable"
fi

exit 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of explicitly saying exit 0? Isn't that the default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default exit status is the exit status of the last command, because we use set -e to exit the script early if any command fails then it is going to be 0. I like to do it explicitly though.