Skip to content

Commit a026ace

Browse files
joostjagerclaude
andcommitted
Split CI test script into parallel jobs
Split the monolithic ci-tests.sh into six focused scripts that run as separate parallel jobs via a reusable workflow (ci-build.yml): - ci-tests-workspace.sh: workspace checks, tests, docs, and downstream compat - ci-tests-features.sh: crate feature/flag combinations (dnssec, tokio, backtrace, test vectors, serde) - ci-tests-bindings.sh: c_bindings builds and tests - ci-tests-nostd.sh: no_std builds and compatibility checks - ci-tests-cfg-flags.sh: experimental gated cfg flags (taproot, simple_close, lsps1_service, peer_storage) - ci-tests-sync.sh: block sync and transaction sync clients Shared setup (MSRV pins, backtrace) is extracted into ci-tests-common.sh. The ci-tests.sh script now delegates to the sub-scripts for local use. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8cd1660 commit a026ace

10 files changed

Lines changed: 298 additions & 209 deletions

.github/workflows/build.yml

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -26,72 +26,36 @@ jobs:
2626
cd ext-functional-test-demo
2727
cargo test --verbose --color always
2828
cargo test --verbose --color always --features test-broken
29-
build:
30-
strategy:
31-
fail-fast: false
32-
matrix:
33-
platform: >-
34-
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
35-
&& fromJSON('["self-hosted","windows-latest","macos-latest"]')
36-
|| fromJSON('["self-hosted"]') }}
37-
toolchain: >-
38-
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
39-
&& fromJSON('["stable","beta","1.75.0"]')
40-
|| fromJSON('["1.75.0"]') }}
41-
exclude:
42-
- platform: windows-latest
43-
toolchain: 1.75.0
44-
- platform: windows-latest
45-
toolchain: beta
46-
- platform: macos-latest
47-
toolchain: beta
48-
runs-on: ${{ matrix.platform }}
49-
steps:
50-
- name: Checkout source code
51-
uses: actions/checkout@v4
52-
- name: Install Rust ${{ matrix.toolchain }} toolchain
53-
run: |
54-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
55-
- name: Use rust-lld linker on Windows
56-
if: matrix.platform == 'windows-latest'
57-
shell: bash
58-
run: echo "RUSTFLAGS=-C linker=rust-lld" >> "$GITHUB_ENV"
59-
- name: Install no-std-check dependencies for ARM Embedded
60-
if: "matrix.platform == 'self-hosted'"
61-
run: |
62-
rustup target add thumbv7m-none-eabi
63-
- name: Set RUSTFLAGS to deny warnings
64-
if: "matrix.toolchain == '1.75.0'"
65-
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
66-
- name: Enable caching for bitcoind
67-
if: matrix.platform != 'windows-latest'
68-
id: cache-bitcoind
69-
uses: actions/cache@v4
70-
with:
71-
path: bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
72-
key: bitcoind-${{ runner.os }}-${{ runner.arch }}
73-
- name: Enable caching for electrs
74-
if: matrix.platform != 'windows-latest'
75-
id: cache-electrs
76-
uses: actions/cache@v4
77-
with:
78-
path: bin/electrs-${{ runner.os }}-${{ runner.arch }}
79-
key: electrs-${{ runner.os }}-${{ runner.arch }}
80-
- name: Download bitcoind/electrs
81-
if: "matrix.platform != 'windows-latest' && (steps.cache-bitcoind.outputs.cache-hit != 'true' || steps.cache-electrs.outputs.cache-hit != 'true')"
82-
run: |
83-
source ./contrib/download_bitcoind_electrs.sh
84-
mkdir bin
85-
mv "$BITCOIND_EXE" bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
86-
mv "$ELECTRS_EXE" bin/electrs-${{ runner.os }}-${{ runner.arch }}
87-
- name: Set bitcoind/electrs environment variables
88-
if: matrix.platform != 'windows-latest'
89-
run: |
90-
echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
91-
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
92-
- name: Run CI script
93-
shell: bash # Default on Winblows is powershell
94-
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
29+
30+
build-workspace:
31+
uses: ./.github/workflows/ci-build.yml
32+
with:
33+
script: ci/ci-tests-workspace.sh
34+
35+
build-features:
36+
uses: ./.github/workflows/ci-build.yml
37+
with:
38+
script: ci/ci-tests-features.sh
39+
40+
build-bindings:
41+
uses: ./.github/workflows/ci-build.yml
42+
with:
43+
script: ci/ci-tests-bindings.sh
44+
45+
build-nostd:
46+
uses: ./.github/workflows/ci-build.yml
47+
with:
48+
script: ci/ci-tests-nostd.sh
49+
50+
build-cfg-flags:
51+
uses: ./.github/workflows/ci-build.yml
52+
with:
53+
script: ci/ci-tests-cfg-flags.sh
54+
55+
build-sync:
56+
uses: ./.github/workflows/ci-build.yml
57+
with:
58+
script: ci/ci-tests-sync.sh
9559

9660
coverage:
9761
needs: fuzz
@@ -343,7 +307,7 @@ jobs:
343307
TOR_PROXY="127.0.0.1:9050" RUSTFLAGS="--cfg=tor" cargo test --verbose --color always -p lightning-net-tokio
344308
345309
notify-failure:
346-
needs: [build, fuzz, linting, rustfmt, check_release, check_docs, benchmark, ext-test, tor-connect, coverage]
310+
needs: [build-workspace, build-features, build-bindings, build-nostd, build-cfg-flags, build-sync, fuzz, linting, rustfmt, check_release, check_docs, benchmark, ext-test, tor-connect, coverage]
347311
if: failure() && github.ref == 'refs/heads/main'
348312
runs-on: ubuntu-latest
349313
permissions:

.github/workflows/ci-build.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI Build Job
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
script:
7+
description: CI script to run (relative to repo root)
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
platform: >-
17+
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
18+
&& fromJSON('["self-hosted","windows-latest","macos-latest"]')
19+
|| fromJSON('["self-hosted"]') }}
20+
toolchain: >-
21+
${{ github.event_name == 'push' && github.ref == 'refs/heads/main'
22+
&& fromJSON('["stable","beta","1.75.0"]')
23+
|| fromJSON('["1.75.0"]') }}
24+
exclude:
25+
- platform: windows-latest
26+
toolchain: 1.75.0
27+
- platform: windows-latest
28+
toolchain: beta
29+
- platform: macos-latest
30+
toolchain: beta
31+
runs-on: ${{ matrix.platform }}
32+
steps:
33+
- name: Checkout source code
34+
uses: actions/checkout@v4
35+
- name: Install Rust ${{ matrix.toolchain }} toolchain
36+
run: |
37+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
38+
- name: Use rust-lld linker on Windows
39+
if: matrix.platform == 'windows-latest'
40+
shell: bash
41+
run: echo "RUSTFLAGS=-C linker=rust-lld" >> "$GITHUB_ENV"
42+
- name: Set RUSTFLAGS to deny warnings
43+
if: "matrix.toolchain == '1.75.0'"
44+
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
45+
- name: Install no-std-check dependencies for ARM Embedded
46+
if: matrix.platform == 'self-hosted'
47+
run: |
48+
rustup target add thumbv7m-none-eabi
49+
- name: Enable caching for bitcoind
50+
if: matrix.platform != 'windows-latest'
51+
id: cache-bitcoind
52+
uses: actions/cache@v4
53+
with:
54+
path: bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
55+
key: bitcoind-${{ runner.os }}-${{ runner.arch }}
56+
- name: Enable caching for electrs
57+
if: matrix.platform != 'windows-latest'
58+
id: cache-electrs
59+
uses: actions/cache@v4
60+
with:
61+
path: bin/electrs-${{ runner.os }}-${{ runner.arch }}
62+
key: electrs-${{ runner.os }}-${{ runner.arch }}
63+
- name: Download bitcoind/electrs
64+
if: >-
65+
matrix.platform != 'windows-latest'
66+
&& (steps.cache-bitcoind.outputs.cache-hit != 'true'
67+
|| steps.cache-electrs.outputs.cache-hit != 'true')
68+
run: |
69+
source ./contrib/download_bitcoind_electrs.sh
70+
mkdir bin
71+
mv "$BITCOIND_EXE" bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
72+
mv "$ELECTRS_EXE" bin/electrs-${{ runner.os }}-${{ runner.arch }}
73+
- name: Set bitcoind/electrs environment variables
74+
if: matrix.platform != 'windows-latest'
75+
run: |
76+
echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
77+
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
78+
- name: Run CI script
79+
shell: bash
80+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./${{ inputs.script }}

ci/ci-tests-bindings.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# shellcheck source=ci/ci-tests-common.sh
5+
source "$(dirname "$0")/ci-tests-common.sh"
6+
7+
echo -e "\n\nTesting c_bindings builds"
8+
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
9+
# disable doctests in `c_bindings` so we skip doctests entirely here.
10+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --quiet --color always --lib --bins --tests
11+
12+
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
13+
# check if there is a conflict between no_std and the c_bindings cfg
14+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --quiet --color always --no-default-features
15+
done
16+
17+
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
18+
# disable doctests in `c_bindings` so we skip doctests entirely here.
19+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --quiet --color always --no-default-features --lib --bins --tests
20+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --quiet --color always --no-default-features --lib --bins --tests

ci/ci-tests-cfg-flags.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# shellcheck source=ci/ci-tests-common.sh
5+
source "$(dirname "$0")/ci-tests-common.sh"
6+
7+
echo -e "\n\nTest cfg-flag builds"
8+
RUSTFLAGS="--cfg=taproot" cargo test --quiet --color always -p lightning
9+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
10+
RUSTFLAGS="--cfg=simple_close" cargo test --quiet --color always -p lightning
11+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
12+
RUSTFLAGS="--cfg=lsps1_service" cargo test --quiet --color always -p lightning-liquidity
13+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
14+
RUSTFLAGS="--cfg=peer_storage" cargo test --quiet --color always -p lightning

ci/ci-tests-common.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# ci/ci-tests-common.sh - Shared helpers for CI test scripts.
3+
# Source this file; do not execute it directly.
4+
# shellcheck disable=SC2002,SC2207
5+
6+
RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
7+
8+
# Some crates require pinning to meet our MSRV even for our downstream users,
9+
# which we do here.
10+
# Further crates which appear only as dev-dependencies are pinned further down.
11+
function PIN_RELEASE_DEPS {
12+
return 0 # Don't fail the script if our rustc is higher than the last check
13+
}
14+
15+
PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
16+
17+
# The backtrace v0.3.75 crate relies on rustc 1.82
18+
[ "$RUSTC_MINOR_VERSION" -lt 82 ] && cargo update -p backtrace --precise "0.3.74" --quiet
19+
20+
# Starting with version 1.2.0, the `idna_adapter` crate has an MSRV of rustc 1.81.0.
21+
[ "$RUSTC_MINOR_VERSION" -lt 81 ] && cargo update -p idna_adapter --precise "1.1.0" --quiet
22+
23+
export RUST_BACKTRACE=1

ci/ci-tests-features.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# shellcheck source=ci/ci-tests-common.sh
5+
source "$(dirname "$0")/ci-tests-common.sh"
6+
7+
echo -e "\n\nChecking and testing lightning with features"
8+
cargo test -p lightning --quiet --color always --features dnssec
9+
cargo check -p lightning --quiet --color always --features dnssec
10+
cargo doc -p lightning --quiet --document-private-items --features dnssec
11+
12+
echo -e "\n\nChecking and testing lightning-persister with features"
13+
cargo test -p lightning-persister --quiet --color always --features tokio
14+
cargo check -p lightning-persister --quiet --color always --features tokio
15+
cargo doc -p lightning-persister --quiet --document-private-items --features tokio
16+
17+
echo -e "\n\nTest backtrace-debug builds"
18+
cargo test -p lightning --quiet --color always --features backtrace
19+
20+
echo -e "\n\nTesting other crate-specific builds"
21+
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
22+
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --quiet --color always --no-default-features --features=std
23+
# This one only works for lightning-invoice
24+
# check that compile with no_std and serde works in lightning-invoice
25+
cargo test -p lightning-invoice --quiet --color always --no-default-features --features serde

ci/ci-tests-nostd.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# shellcheck source=ci/ci-tests-common.sh
5+
source "$(dirname "$0")/ci-tests-common.sh"
6+
7+
echo -e "\n\nTesting no_std builds"
8+
for DIR in lightning-invoice lightning-rapid-gossip-sync lightning-liquidity; do
9+
cargo test -p $DIR --quiet --color always --no-default-features
10+
done
11+
12+
cargo test -p lightning --quiet --color always --no-default-features
13+
cargo test -p lightning-background-processor --quiet --color always --no-default-features
14+
15+
echo -e "\n\nTesting no_std build on a downstream no-std crate"
16+
# check no-std compatibility across dependencies
17+
pushd no-std-check
18+
cargo check --quiet --color always
19+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
20+
popd
21+
22+
if [ -f "$(which arm-none-eabi-gcc)" ]; then
23+
pushd no-std-check
24+
cargo build --quiet --target=thumbv7m-none-eabi
25+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
26+
popd
27+
fi

ci/ci-tests-sync.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# shellcheck source=ci/ci-tests-common.sh
5+
source "$(dirname "$0")/ci-tests-common.sh"
6+
7+
echo -e "\n\nChecking and testing Block Sync Clients with features"
8+
9+
cargo test -p lightning-block-sync --quiet --color always --features rest-client
10+
cargo check -p lightning-block-sync --quiet --color always --features rest-client
11+
cargo test -p lightning-block-sync --quiet --color always --features rpc-client
12+
cargo check -p lightning-block-sync --quiet --color always --features rpc-client
13+
cargo test -p lightning-block-sync --quiet --color always --features rpc-client,rest-client
14+
cargo check -p lightning-block-sync --quiet --color always --features rpc-client,rest-client
15+
cargo test -p lightning-block-sync --quiet --color always --features rpc-client,rest-client,tokio
16+
cargo check -p lightning-block-sync --quiet --color always --features rpc-client,rest-client,tokio
17+
18+
echo -e "\n\nChecking Transaction Sync Clients with features."
19+
cargo check -p lightning-transaction-sync --quiet --color always --features esplora-blocking
20+
cargo check -p lightning-transaction-sync --quiet --color always --features esplora-async
21+
cargo check -p lightning-transaction-sync --quiet --color always --features esplora-async-https
22+
cargo check -p lightning-transaction-sync --quiet --color always --features electrum
23+
24+
if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
25+
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
26+
cargo check -p lightning-transaction-sync --tests
27+
else
28+
echo -e "\n\nTesting Transaction Sync Clients with features."
29+
cargo test -p lightning-transaction-sync --quiet --color always --features esplora-blocking
30+
cargo test -p lightning-transaction-sync --quiet --color always --features esplora-async
31+
cargo test -p lightning-transaction-sync --quiet --color always --features esplora-async-https
32+
cargo test -p lightning-transaction-sync --quiet --color always --features electrum
33+
fi

ci/ci-tests-workspace.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#shellcheck disable=SC2002,SC2207
3+
set -eox pipefail
4+
5+
# shellcheck source=ci/ci-tests-common.sh
6+
source "$(dirname "$0")/ci-tests-common.sh"
7+
8+
echo -e "\n\nChecking the workspace, except lightning-transaction-sync."
9+
cargo check --quiet --color always
10+
11+
WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' ' ') )
12+
13+
echo -e "\n\nTesting the workspace, except lightning-transaction-sync."
14+
cargo test --quiet --color always
15+
16+
echo -e "\n\nTesting upgrade from prior versions of LDK"
17+
pushd lightning-tests
18+
cargo test --quiet
19+
popd
20+
21+
echo -e "\n\nChecking and building docs for all workspace members individually..."
22+
for DIR in "${WORKSPACE_MEMBERS[@]}"; do
23+
cargo check -p "$DIR" --quiet --color always
24+
cargo doc -p "$DIR" --quiet --document-private-items
25+
done
26+
27+
echo -e "\n\nTest Custom Message Macros"
28+
cargo test -p lightning-custom-message --quiet --color always
29+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
30+
31+
# Test that we can build downstream code with only the "release pins".
32+
pushd msrv-no-dev-deps-check
33+
PIN_RELEASE_DEPS
34+
cargo check --quiet
35+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
36+
popd

0 commit comments

Comments
 (0)