Skip to content

Re-work the CI pipeline and test script #370

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

Closed
wants to merge 6 commits into from
Closed
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
80 changes: 40 additions & 40 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,93 +3,93 @@ on: [push, pull_request]
name: Continuous integration

jobs:
lint_fuzz_stable:
name: Lint + Fuzz
Sanity:
name: Sanity + Fmt
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Running cargo fmt
env:
DO_FMT: true
run: ./contrib/test.sh
- name: Running integration tests
env:
BITCOINVERSION: '22.0'
run: ./contrib/test.sh

Tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.58.0
rust: [stable, beta, nightly, 1.41.1]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Install hongfuzz dependancies
run: sudo apt install build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running fuzzer
- name: Running cargo
env:
DO_FUZZ: true
DO_LINT: true
DO_FEATURE_MATRIX: true
run: ./contrib/test.sh

bench_nightly:
name: Bench + Tests
Bench:
name: Bench
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: nightly
override: true
- name: Running cargo test
- name: Running benchmarks
env:
DO_BENCH: true
run: ./contrib/test.sh

UnitTests:
name: Tests
Fuzz:
name: Fuzz
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.29.0
- beta
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Install hongfuzz dependencies
run: sudo apt install build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: stable
override: true
- name: Pin deps if rust 1.29
if: matrix.rust == '1.29.0'
run: |
cargo generate-lockfile --verbose && \
cargo update --verbose --package "cc" --precise "1.0.41" && \
cargo update --verbose --package "serde" --precise "1.0.98" && \
cargo update --verbose --package "serde_derive" --precise "1.0.98"
- name: Running cargo
- name: Running fuzzer
env:
DO_FUZZ: true
run: ./contrib/test.sh

AllTests:
name: Unit + Int tests
Integration:
name: Integration tests against bitcoind
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: 38 additions & 21 deletions contrib/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh -ex

set -e

FEATURES="compiler use-serde rand"

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

cargo --version
rustc --version

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

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

if [ "$DO_FEATURE_MATRIX" = true ]
then
# All features
cargo build --all --no-default-features --features="$FEATURES"
cargo test --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"
done

# Also build and run each example to catch regressions
cargo build --examples

cargo run --example htlc --features=compiler
for example in "parse psbt sign_multisig verify_tx xpub_descriptors"
do
cargo run --example $example
done
fi

# Bench if told to
if [ "$DO_BENCH" = true ]
then
cargo bench --features="unstable compiler"
fi

# Fuzz if told to
if [ "$DO_FUZZ" = true ]
then
Expand All @@ -30,26 +67,6 @@ then
)
fi

# Test without any features first
cargo test --verbose

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

# Also build and run each example to catch regressions
cargo build --examples
# run all examples
run-parts ./target/debug/examples

# Bench if told to
if [ "$DO_BENCH" = true ]
then
cargo bench --features="unstable compiler"
fi

# Run Integration tests if told so
if [ -n "$BITCOINVERSION" ]; then
set -e
Expand Down