Skip to content

Improve the test script and CI pipeline #405

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 8 commits into from
May 15, 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
20 changes: 8 additions & 12 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: ./contrib/test.sh

Nightly:
name: Bench + Docs + Fmt
name: Nightly - Bench + Docs + Fmt
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
Expand All @@ -51,14 +51,12 @@ jobs:
DO_FMT: true
run: ./contrib/test.sh

UnitTests:
Tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.41.1
- beta
rust: [stable, beta, nightly, 1.41.1]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
Expand All @@ -69,23 +67,21 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true
- name: Running cargo
env:
DO_FEATURE_MATRIX: true
run: ./contrib/test.sh

AllTests:
name: Unit + Int tests
IntTests:
name: Integration tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: stable
override: true
- name: Running cargo
env:
Expand Down
59 changes: 36 additions & 23 deletions contrib/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh -ex

set -e
Copy link
Member

Choose a reason for hiding this comment

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

This is a big bug! I wonder how it ever worked till now

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we were getting some false positives in the CI runs. rust-bitcoin/contrib/test.sh doesn't have this either :)


FEATURES="compiler use-serde rand"

# Use toolchain if explicitly specified
Expand All @@ -8,41 +10,50 @@ then
alias cargo="cargo +$TOOLCHAIN"
fi

cargo --version
rustc --version

# Format if told to
if [ "$DO_FMT" = true ]
then
(
rustup component add rustfmt
cargo fmt --all -- --check
)
rustup component add rustfmt
cargo fmt --all -- --check
fi

# Fuzz if told to
if [ "$DO_FUZZ" = true ]
then
(
cd fuzz
cargo test --verbose
./travis-fuzz.sh
# Exit out of the fuzzer,
# run stable tests in other CI vms
exit 0
)
cd fuzz
cargo test --verbose
./travis-fuzz.sh

# Exit out of the fuzzer, do not run other tests.
exit 0
fi

# Test without any features first
cargo test --verbose
# Defaults / sanity checks
cargo test

# Test each feature
for feature in ${FEATURES}
do
cargo test --verbose --features="$feature"
done
if [ "$DO_FEATURE_MATRIX" = true ]
then
# All features
cargo test --features="$FEATURES"

# Single features
for feature in ${FEATURES}
do
cargo test --features="$feature"
done

# Also build and run each example to catch regressions
cargo build --examples
# run all examples
run-parts ./target/debug/examples
# Run all the examples
cargo build --examples
cargo run --example htlc --features=compiler
Copy link
Member

Choose a reason for hiding this comment

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

nit: There is a white space at the end of this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

ooo, means I did not read the diff before pushing, bad Tobin. Thanks man, I'll fix it.

Copy link
Member

Choose a reason for hiding this comment

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

I read the diff and I missed this too, oops! Thanks Sanket.

cargo run --example parse
cargo run --example sign_multisig
cargo run --example verify_tx > /dev/null
cargo run --example psbt
cargo run --example xpub_descriptors
Copy link
Member

Choose a reason for hiding this comment

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

Why manually list examples instead of run-parts? Is it because of the extra args to each example? We need to remember to add examples here every time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Its so the script can be run locally, but yes as you say there is a maintenance cost. Is it worth it, I don't know? I configure target-dir to be a global build cache so there is no target directory when I build so the examples don't run.

fi

# Bench if told to (this only works with the nightly toolchain)
if [ "$DO_BENCH" = true ]
Expand All @@ -67,3 +78,5 @@ if [ -n "$BITCOINVERSION" ]; then
rm -rf bitcoin-$BITCOINVERSION
exit 0
fi

exit 0