Skip to content

Commit

Permalink
CI: Use script from rust-bitcoin-maintainer-tools
Browse files Browse the repository at this point in the history
We have a CI script in the `rust-bitcoin-maintainer-tools` repository,
lets use it.
  • Loading branch information
tcharding committed May 3, 2024
1 parent 3dbfca6 commit 90b33a3
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 74 deletions.
130 changes: 94 additions & 36 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,104 @@
on: [push, pull_request]
--- # rust-bitcoin CI: If you edit this file please update README.md
on: # yamllint disable-line rule:truthy
push:
branches:
- master
- 'test-ci/**'
pull_request:

name: Continuous integration

jobs:
tests:
name: Tests
Stable: # 2 jobs, one per lock file.
name: Test - stable toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- rust: stable
env:
RUSTFMTCHK: true
- rust: nightly
env:
RUSTFMTCHK: false
- rust: 1.56.1
env:
RUSTFMTCHK: false
dep: [minimal, recent]
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Running test script
env: ${{ matrix.env }}
run: ./contrib/test.sh
repository: tcharding/rust-bitcoin-maintainer-tools
ref: 05-02-ci
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh stable

integrations-tests:
name: Integration Tests
Nightly: # 2 jobs, one per lock file.
name: Test - nightly toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [minimal, recent]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
with:
repository: tcharding/rust-bitcoin-maintainer-tools
ref: 05-02-ci
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@nightly
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh nightly

MSRV: # Recent lock file currently does not work with MSRV.
name: Test - 1.56.1 toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dep: [minimal]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Checkout maintainer tools"
uses: actions/checkout@v4
with:
repository: tcharding/rust-bitcoin-maintainer-tools
ref: 05-02-ci
path: maintainer-tools
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.56.1"
- name: "Set dependencies"
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
- name: "Run test script"
run: ./maintainer-tools/ci/run_task.sh msrv

Format: # 1 job, run cargo fmt directly.
name: Format - 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: "Check formatting"
run: cargo fmt --all -- --check

Integration: # 1 job for each Bitcoin Core version.
name: Integration tests - stable toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable]
bitcoinversion:
[
"0.18.0",
Expand All @@ -48,15 +110,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
10 changes: 10 additions & 0 deletions client/contrib/test_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Test all these features with "std" enabled.
FEATURES_WITH_STD=""

# Test all these features without "std" enabled.
FEATURES_WITHOUT_STD="verifymessage"

# Run these examples.
EXAMPLES="retry_client:verifymessage"
4 changes: 4 additions & 0 deletions contrib/crates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# Crates in this workspace to test (excl. fuzz an integration-tests).
CRATES=("json" "client")
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
38 changes: 0 additions & 38 deletions contrib/test.sh

This file was deleted.

1 change: 1 addition & 0 deletions json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ serde = { version = "1", features = [ "derive" ] }
serde_json = "1"

bitcoin = { version = "0.31.0", features = ["serde", "rand-std"]}

10 changes: 10 additions & 0 deletions json/contrib/test_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Test all these features with "std" enabled.
FEATURES_WITH_STD=""

# Test all these features without "std" enabled.
FEATURES_WITHOUT_STD=""

# Run these examples.
EXAMPLES=""

0 comments on commit 90b33a3

Please sign in to comment.