-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-write CI in a similar manner to what we did in `rust-bitcoin` recently. Some benefits: - The `contrib/run_task.sh` can be used from the command line. - GitHub action is dumber i.e., all the logic is in the shell script instead of spread between the action and the script. - The action yaml is [hopefully] a bit cleaner. Covearge is the same, three toolchains, linter, integration tests for various Core versions. Includes a bunch of pinning for MSRV that seems to currently be broken, I'm not exactly sure when it broke.
- Loading branch information
Showing
5 changed files
with
236 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,87 @@ | ||
on: [push, pull_request] | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- 'test-ci/**' | ||
pull_request: | ||
|
||
name: Continuous integration | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- rust: stable | ||
env: | ||
RUSTFMTCHK: true | ||
- rust: nightly | ||
env: | ||
RUSTFMTCHK: false | ||
- rust: 1.56.1 | ||
env: | ||
RUSTFMTCHK: false | ||
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 | ||
env: ${{ matrix.env }} | ||
run: ./contrib/test.sh | ||
Stable: | ||
name: Test - stable toolchain | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Select toolchain" | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: "Run test script" | ||
run: ./contrib/run_task.sh stable | ||
|
||
integrations-tests: | ||
name: Integration Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: [stable] | ||
bitcoinversion: | ||
[ | ||
"0.18.0", | ||
"0.18.1", | ||
"0.19.0.1", | ||
"0.19.1", | ||
"0.20.0", | ||
"0.20.1", | ||
"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 | ||
env: | ||
BITCOINVERSION: ${{ matrix.bitcoinversion }} | ||
run: ./contrib/test.sh | ||
Nightly: | ||
name: Test - nightly toolchain | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Select toolchain" | ||
uses: dtolnay/rust-toolchain@nightly | ||
- name: "Run test script" | ||
run: ./contrib/run_task.sh nightly | ||
|
||
MSRV: | ||
name: Test - 1.56.1 toolchain | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Select toolchain" | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: "1.56.1" | ||
- name: "Run test script" | ||
run: ./contrib/run_task.sh msrv | ||
|
||
Format: | ||
name: Format - nightly toolchain | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Select toolchain" | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: "Check formatting" | ||
run: cargo fmt --all -- --check | ||
|
||
Integration: | ||
name: Integration Tests - stable toolchain | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
bitcoin_version: | ||
[ | ||
"0.18.0", | ||
"0.18.1", | ||
"0.19.0.1", | ||
"0.19.1", | ||
"0.20.0", | ||
"0.20.1", | ||
"0.21.0", | ||
] | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Select toolchain" | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Running test script | ||
run: ./contrib/run_task.sh integration ${{ matrix.bitcoin_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Run CI task, called by the `rust.yml` GitHub action. | ||
|
||
set -euo pipefail | ||
|
||
REPO_DIR=$(git rev-parse --show-toplevel) | ||
MSRV="1.56.1" | ||
|
||
usage() { | ||
cat <<EOF | ||
Usage: | ||
./run_task.sh TASK | ||
TASK | ||
- stable Run stable toolchain tests. | ||
- nightly Run nightly toolchain tests. | ||
- msrv Run MSRV toolchain tests. | ||
- fmt Run the formatter (rustfmt). | ||
- integration Run integration test for specific Bitcoin Core version. | ||
./run_task.sh integration BITCOIN_CORE_VERSION [DOWNLOAD_CORE] | ||
Example | ||
./run_task.sh integration # Runs integration tests against bitcoind from your path. | ||
./run_task.sh integration 0.21.0 # Downloads Core version 0.21.0 and runs integration tests againts it. | ||
EOF | ||
} | ||
|
||
# Make all cargo invocations verbose. | ||
export CARGO_TERM_VERBOSE=true | ||
|
||
main() { | ||
local task="${1:-usage}" | ||
local bitcoin_version="${2:-none}" | ||
|
||
if [ "$task" = "usage" ] || [ "$task" = "-h" ] || [ "$task" = "--help" ]; then | ||
usage | ||
exit 0 | ||
fi | ||
|
||
check_required_commands | ||
|
||
cargo --version | ||
rustc --version | ||
/usr/bin/env bash --version | ||
locale | ||
env | ||
|
||
case $task in | ||
stable) | ||
build_and_test "+stable" | ||
;; | ||
|
||
nightly) | ||
build_and_test "+nightly" | ||
;; | ||
|
||
msrv) | ||
do_msrv_pins | ||
build_and_test "+$MSRV" | ||
;; | ||
|
||
fmt) | ||
do_fmt | ||
;; | ||
|
||
integration) | ||
integration "$bitcoin_version" | ||
;; | ||
|
||
*) | ||
echo "" | ||
usage | ||
err "Error: unknown task $task" | ||
;; | ||
esac | ||
} | ||
|
||
# Build and test workspace. | ||
build_and_test() { | ||
local toolchain="$1" | ||
|
||
for crate in json client integration_test; do | ||
pushd "$REPO_DIR/$crate" > /dev/null; | ||
|
||
cargo "$toolchain" build | ||
cargo "$toolchain" test | ||
|
||
popd > /dev/null | ||
done | ||
} | ||
|
||
# Pin dependencies to get the MSRV build to work. | ||
do_msrv_pins() { | ||
cargo update -p tempfile --precise 3.6.0 | ||
cargo update -p cc --precise 1.0.79 | ||
cargo update -p log --precise 0.4.18 | ||
cargo update -p serde_json --precise 1.0.96 | ||
cargo update -p serde --precise 1.0.156 | ||
} | ||
|
||
# Check the workspace formatting. | ||
do_fmt() { | ||
cargo +stable fmt --all --check | ||
} | ||
|
||
# Pulls down Bitcoin Core binary and runs the integration tests. | ||
integration() { | ||
local core_version="$1" | ||
|
||
cd "$REPO_DIR" | ||
|
||
if [ "$core_version" != "none" ]; then | ||
wget "https://bitcoincore.org/bin/bitcoin-core-$bitcoin_version/bitcoin-$bitcoin_version-x86_64-linux-gnu.tar.gz" | ||
tar -xzvf "bitcoin-$bitcoin_version-x86_64-linux-gnu.tar.gz" | ||
export PATH=$PATH:"$REPO_DIR/bitcoin-$bitcoin_version/bin" | ||
fi | ||
|
||
need_cmd "bitcoind" | ||
|
||
cd "$REPO_DIR/integration_test" | ||
./run.sh | ||
} | ||
|
||
# Check all the commands we use are present in the current environment. | ||
check_required_commands() { | ||
need_cmd cargo | ||
need_cmd rustc | ||
} | ||
|
||
need_cmd() { | ||
if ! command -v "$1" > /dev/null 2>&1 | ||
then err "need '$1' (command not found)" | ||
fi | ||
} | ||
|
||
err() { | ||
echo "$1" >&2 | ||
exit 1 | ||
} | ||
|
||
# | ||
# Main script | ||
# | ||
main "$@" | ||
exit 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters