From 9c9d622b0ee26a3de2d43de298ded822245520a4 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Sat, 19 Mar 2022 10:16:52 +1100 Subject: [PATCH 1/9] Remove trailing whitespace Remove single character of trailing whitespace. --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 145bdacfe..516a5e91f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,7 +11,7 @@ jobs: rust: - nightly steps: - - name: Checkout Crate + - name: Checkout Crate uses: actions/checkout@v2 - name: Checkout Toolchain uses: actions-rs/toolchain@v1 From a8a679ed7dbfa4871270de779aee78b3cdaeebd6 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Sat, 19 Mar 2022 10:22:28 +1100 Subject: [PATCH 2/9] Re-name nightly CI job to Nightly In line with the `Tests` job and for the fact that this job does stuff with the nightly toolchain other than bench. Re-name nightly CI job from `bench_nightly`to `Nightly`. --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 516a5e91f..c9930e3a1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,7 +3,7 @@ on: [push, pull_request] name: Continuous integration jobs: - bench_nightly: + Nightly: name: Nightly - ASan + Bench runs-on: ubuntu-latest strategy: From 96685c571da4f3c64d178e0f0d3a02ce99de9136 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Sat, 19 Mar 2022 10:24:00 +1100 Subject: [PATCH 3/9] Remove unnecessary matrix We use a matrix with a single element, this is unnecessary. --- .github/workflows/rust.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c9930e3a1..9060001e6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -6,10 +6,6 @@ jobs: Nightly: name: Nightly - ASan + Bench runs-on: ubuntu-latest - strategy: - matrix: - rust: - - nightly steps: - name: Checkout Crate uses: actions/checkout@v2 @@ -17,7 +13,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: nightly override: true components: rust-src - name: Running address sanitizer From f7bc7d3728326e6de0d2462dfba9705b93a1f55e Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Sat, 19 Mar 2022 10:24:57 +1100 Subject: [PATCH 4/9] Install clang to run adress sanitizer The address sanitizer job is silently failing at the moment because we do not install clang. Install clang so the address sanitizer job can run. Do not fix the silent failure, that will be done later on. --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9060001e6..855fc82f1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,6 +9,8 @@ jobs: steps: - 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: From 946ac3b51ebb8191b051c8d80bd27bee1656993e Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Sat, 19 Mar 2022 10:27:48 +1100 Subject: [PATCH 5/9] Do docs build in Nightly job We have a separate CI job for things that require a nightly toolchain. Building the docs requires a nightly toolchain (because of `--cfg docsrc` flag). It makes more sense to run the docs build in the `Nightly` job instead of hidden in the `Tests` job. Do the docs build in the `Nightly` job instead of in the `Tests` job. --- .github/workflows/rust.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 855fc82f1..ead504f67 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -4,7 +4,7 @@ name: Continuous integration jobs: Nightly: - name: Nightly - ASan + Bench + name: Nightly - ASan + Bench + Docs runs-on: ubuntu-latest steps: - name: Checkout Crate @@ -26,6 +26,10 @@ jobs: env: DO_BENCH: true run: ./contrib/test.sh + - name: Building docs + env: + DO_DOCS: true + run: ./contrib/test.sh Tests: name: Tests @@ -43,7 +47,6 @@ jobs: - rust: nightly env: DO_FEATURE_MATRIX: true - DO_DOCS: true - rust: 1.29.0 env: DO_FEATURE_MATRIX: true From 58db1b67536794b24cdc0bf8149460509a247b31 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Sat, 19 Mar 2022 10:40:19 +1100 Subject: [PATCH 6/9] Run WASM for multiple toolchains WASM is supported by Rust 1.30. We can therefore run the WASM tests on any all the toolchains except MSRV (1.29.0). This has benefit of catching nightly/beta issues before they get to stable. Done as a separate CI job since it is conceptually different to the `Tests` job. Run WASM for nightly, beta, and stable toolchains. --- .github/workflows/rust.yml | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ead504f67..ef99eb610 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -36,20 +36,7 @@ jobs: 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 - - rust: 1.29.0 - env: - DO_FEATURE_MATRIX: true + rust: [stable, beta, nightly, 1.29.0] steps: - name: Checkout Crate uses: actions/checkout@v2 @@ -63,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 From 7bec31c3a6eb43068f0b28db5f351b079751b2e2 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 17 Mar 2022 10:30:36 +1100 Subject: [PATCH 7/9] test.sh: explicitly return 0 As per UNIX convention a Bash script should exit with status code 0 if it completes successfully. --- contrib/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/test.sh b/contrib/test.sh index a892a78d2..413115b63 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -94,3 +94,4 @@ if [ "$DO_BENCH" = true ]; then cargo bench --all --features="unstable" fi +exit 0 From a3582ff77dec8f4c5855fa38f4b8ff6bef700169 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 17 Mar 2022 10:57:30 +1100 Subject: [PATCH 8/9] test.sh: Use set -e to exit on failure Currently the `test.sh` script is silently failing because we do not exit if a command fails. We can achieve this by using the Bash builtin `set -e`. For some reason I cannot explain a chain of commands that fails does not fail the script. Instead of working out _why_ just remove the chain and run each command on its own. This is functionally the same and, I hazard a guess, is what the original author hoped to achieve with the chaining. --- contrib/test.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/contrib/test.sh b/contrib/test.sh index 413115b63..e093e4310 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -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 @@ -64,11 +66,11 @@ 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 --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 @@ -77,11 +79,11 @@ 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 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 From 97dc0ea9acdc308cc2cadc11e4787d07ec9b2c79 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 22 Mar 2022 10:12:30 +1100 Subject: [PATCH 9/9] Run correct clang --version For the test that uses `clang-9` do the sanity call using `clang-9` instead of `clang`. For the test that uses `clang` add a sanity call to `clang --version`. --- contrib/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/test.sh b/contrib/test.sh index e093e4310..f5f83632a 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -66,7 +66,7 @@ fi # Webassembly stuff if [ "$DO_WASM" = true ]; then - clang --version + 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 @@ -75,6 +75,7 @@ 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' \