From 1cc036b82a62dfb8a4f362440faaf965408ed13f Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 2 May 2024 12:28:35 +1000 Subject: [PATCH] CI: Use a separate script to run integration tests 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). --- .github/workflows/rust.yml | 22 ++++++++---------- contrib/integration_test.sh | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 13 deletions(-) create mode 100755 contrib/integration_test.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 377f3ff2..eb4c0f40 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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", @@ -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 diff --git a/contrib/integration_test.sh b/contrib/integration_test.sh new file mode 100755 index 00000000..1522d404 --- /dev/null +++ b/contrib/integration_test.sh @@ -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