Skip to content

Commit

Permalink
CI: Use a separate script to run integration tests
Browse files Browse the repository at this point in the history
In preparation for using the `run_task.sh` script from
`rust-bitcoin-maintainer-tools` pull the integration stuff out of
`test.sh` and into a separate script. Update the CI job to use the new
script.

Includes switch to the dtolnay runner (maintaining use of stable toolchain).
  • Loading branch information
tcharding committed May 2, 2024
1 parent d01f129 commit 1cc036b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 13 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
env: ${{ matrix.env }}
run: ./contrib/test.sh

integrations-tests:
name: Integration Tests
Integration:
name: Integration tests - stable toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable]
bitcoinversion:
[
"0.18.0",
Expand All @@ -48,15 +48,11 @@ jobs:
"0.21.0",
]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running test script
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
- name: "Run integration tests"
env:
BITCOINVERSION: ${{ matrix.bitcoinversion }}
run: ./contrib/test.sh
run: ./contrib/integration_test.sh
45 changes: 45 additions & 0 deletions contrib/integration_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Run the integration test optionally downloading Bitcoin Core binary if BITCOINVERSION is set.

set -euo pipefail

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

# Make all cargo invocations verbose.
export CARGO_TERM_VERBOSE=true

main() {
# If a specific version of Bitcoin Core is set then download the binary.
if [ -n "${BITCOINVERSION+x}" ]; then
download_binary
fi

need_cmd bitcoind

cd integration_test
./run.sh
}

download_binary() {
wget https://bitcoincore.org/bin/bitcoin-core-$BITCOINVERSION/bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
tar -xzvf bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
export PATH=$PATH:$(pwd)/bitcoin-$BITCOINVERSION/bin
}

err() {
echo "$1" >&2
exit 1
}

need_cmd() {
if ! command -v "$1" > /dev/null 2>&1
then err "need '$1' (command not found)"
fi
}

#
# Main script
#
main "$@"
exit 0

0 comments on commit 1cc036b

Please sign in to comment.