Skip to content

Commit 4f74e2d

Browse files
joostjagerclaude
andcommitted
ci: Split CI tests into separate workflow steps
Refactor ci-tests.sh to support running individual test steps via command-line argument. Each test step now appears as a separate step in GitHub Actions, making it easier to identify which specific test failed without digging through logs. Run ./ci/ci-tests.sh locally to run all tests, or pass a step name (e.g., ./ci/ci-tests.sh workspace-check) to run a single step. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b64302b commit 4f74e2d

2 files changed

Lines changed: 228 additions & 127 deletions

File tree

.github/workflows/build.yml

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,72 @@ jobs:
8888
run: |
8989
echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
9090
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
91-
- name: Run CI script
92-
shell: bash # Default on Winblows is powershell
93-
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
91+
- name: Workspace check
92+
shell: bash
93+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh workspace-check
94+
- name: Workspace tests
95+
shell: bash
96+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh workspace-tests
97+
- name: LDK upgrade tests
98+
shell: bash
99+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh ldk-upgrade-tests
100+
- name: Workspace member checks
101+
shell: bash
102+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh workspace-member-checks
103+
- name: Lightning dnssec
104+
shell: bash
105+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh lightning-dnssec
106+
- name: Block sync tests
107+
shell: bash
108+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh block-sync-tests
109+
- name: Tx sync checks
110+
shell: bash
111+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh tx-sync-checks
112+
- name: Tx sync tests
113+
shell: bash
114+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh tx-sync-tests
115+
- name: Persister tests
116+
shell: bash
117+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh persister-tests
118+
- name: Custom message tests
119+
shell: bash
120+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh custom-message-tests
121+
- name: Lightning backtrace
122+
shell: bash
123+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh lightning-backtrace
124+
- name: No-std tests
125+
shell: bash
126+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh no-std-tests
127+
- name: C bindings tests
128+
shell: bash
129+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh c-bindings-tests
130+
- name: Test vectors
131+
shell: bash
132+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh test-vectors
133+
- name: Lightning invoice serde
134+
shell: bash
135+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh lightning-invoice-serde
136+
- name: No-std check
137+
shell: bash
138+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh no-std-check
139+
- name: MSRV no-dev-deps check
140+
shell: bash
141+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh msrv-no-dev-deps-check
142+
- name: No-std check ARM
143+
shell: bash
144+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh no-std-check-arm
145+
- name: Taproot tests
146+
shell: bash
147+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh taproot-tests
148+
- name: Simple close tests
149+
shell: bash
150+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh simple-close-tests
151+
- name: LSPS1 service tests
152+
shell: bash
153+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh lsps1-service-tests
154+
- name: Peer storage tests
155+
shell: bash
156+
run: CI_ENV=1 CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh peer-storage-tests
94157

95158
coverage:
96159
needs: fuzz

ci/ci-tests.sh

Lines changed: 162 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,6 @@ function PIN_RELEASE_DEPS {
1111
return 0 # Don't fail the script if our rustc is higher than the last check
1212
}
1313

14-
# Run a test command and emit GitHub Actions annotation on failure
15-
# Usage: run_test "Test Name" command arg1 arg2 ...
16-
function run_test {
17-
local name="$1"
18-
shift
19-
local start duration
20-
21-
echo -e "\n\n$name"
22-
start=$(date +%s)
23-
if "$@"; then
24-
return 0
25-
else
26-
duration=$(($(date +%s) - start))
27-
mins=$((duration / 60))
28-
secs=$((duration % 60))
29-
if [ "$mins" -gt 0 ]; then
30-
duration_str="${mins}m${secs}s"
31-
else
32-
duration_str="${secs}s"
33-
fi
34-
[ -n "$GITHUB_ACTIONS" ] && echo "::error title=$name::Test failed after ${duration_str}"
35-
return 1
36-
fi
37-
}
38-
39-
# Run a test command with custom RUSTFLAGS
40-
# Usage: run_test_with_flags "Test Name" "extra flags" command arg1 arg2 ...
41-
function run_test_with_flags {
42-
local name="$1"
43-
local extra_flags="$2"
44-
shift 2
45-
RUSTFLAGS="$RUSTFLAGS $extra_flags" run_test "$name" "$@"
46-
}
47-
4814
PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
4915

5016
# The backtrace v0.3.75 crate relies on rustc 1.82
@@ -58,98 +24,170 @@ PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
5824

5925
export RUST_BACKTRACE=1
6026

61-
run_test "Workspace check" cargo check --verbose --color always
62-
6327
WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' ' ') )
6428

65-
run_test "Workspace tests" cargo test --verbose --color always
66-
67-
run_test "LDK upgrade tests" bash -c 'pushd lightning-tests && cargo test && popd'
68-
69-
for DIR in "${WORKSPACE_MEMBERS[@]}"; do
70-
run_test "Check $DIR" cargo check -p "$DIR" --verbose --color always
71-
run_test "Docs $DIR" cargo doc -p "$DIR" --document-private-items
72-
done
73-
74-
run_test "lightning tests (dnssec)" cargo test -p lightning --verbose --color always --features dnssec
75-
run_test "lightning check (dnssec)" cargo check -p lightning --verbose --color always --features dnssec
76-
run_test "lightning docs (dnssec)" cargo doc -p lightning --document-private-items --features dnssec
77-
78-
run_test "block-sync test (rest-client)" cargo test -p lightning-block-sync --verbose --color always --features rest-client
79-
run_test "block-sync check (rest-client)" cargo check -p lightning-block-sync --verbose --color always --features rest-client
80-
run_test "block-sync test (rpc-client)" cargo test -p lightning-block-sync --verbose --color always --features rpc-client
81-
run_test "block-sync check (rpc-client)" cargo check -p lightning-block-sync --verbose --color always --features rpc-client
82-
run_test "block-sync test (rpc+rest)" cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
83-
run_test "block-sync check (rpc+rest)" cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
84-
run_test "block-sync test (rpc+rest+tokio)" cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
85-
run_test "block-sync check (rpc+rest+tokio)" cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
86-
87-
run_test "tx-sync check (esplora-blocking)" cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
88-
run_test "tx-sync check (esplora-async)" cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
89-
run_test "tx-sync check (esplora-async-https)" cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
90-
run_test "tx-sync check (electrum)" cargo check -p lightning-transaction-sync --verbose --color always --features electrum
29+
run_step() {
30+
case "$1" in
31+
workspace-check)
32+
cargo check --verbose --color always
33+
;;
34+
workspace-tests)
35+
cargo test --verbose --color always
36+
;;
37+
ldk-upgrade-tests)
38+
pushd lightning-tests && cargo test && popd
39+
;;
40+
workspace-member-checks)
41+
for DIR in "${WORKSPACE_MEMBERS[@]}"; do
42+
cargo check -p "$DIR" --verbose --color always
43+
cargo doc -p "$DIR" --document-private-items
44+
done
45+
;;
46+
lightning-dnssec)
47+
cargo test -p lightning --verbose --color always --features dnssec
48+
cargo check -p lightning --verbose --color always --features dnssec
49+
cargo doc -p lightning --document-private-items --features dnssec
50+
;;
51+
block-sync-tests)
52+
cargo test -p lightning-block-sync --verbose --color always --features rest-client
53+
cargo check -p lightning-block-sync --verbose --color always --features rest-client
54+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client
55+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client
56+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
57+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
58+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
59+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
60+
;;
61+
tx-sync-checks)
62+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
63+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
64+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
65+
cargo check -p lightning-transaction-sync --verbose --color always --features electrum
66+
;;
67+
tx-sync-tests)
68+
if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
69+
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
70+
cargo check -p lightning-transaction-sync --tests
71+
else
72+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
73+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
74+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
75+
cargo test -p lightning-transaction-sync --verbose --color always --features electrum
76+
fi
77+
;;
78+
persister-tests)
79+
cargo test -p lightning-persister --verbose --color always --features tokio
80+
cargo check -p lightning-persister --verbose --color always --features tokio
81+
cargo doc -p lightning-persister --document-private-items --features tokio
82+
;;
83+
custom-message-tests)
84+
cargo test -p lightning-custom-message --verbose --color always
85+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
86+
;;
87+
lightning-backtrace)
88+
cargo test -p lightning --verbose --color always --features backtrace
89+
;;
90+
no-std-tests)
91+
for DIR in lightning-invoice lightning-rapid-gossip-sync lightning-liquidity; do
92+
cargo test -p $DIR --verbose --color always --no-default-features
93+
done
94+
cargo test -p lightning --verbose --color always --no-default-features
95+
cargo test -p lightning-background-processor --verbose --color always --no-default-features
96+
;;
97+
c-bindings-tests)
98+
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
99+
# disable doctests in `c_bindings` so we skip doctests entirely here.
100+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
101+
102+
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
103+
# check if there is a conflict between no_std and the c_bindings cfg
104+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
105+
done
106+
107+
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
108+
# disable doctests in `c_bindings` so we skip doctests entirely here.
109+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --no-default-features --lib --bins --tests
110+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --lib --bins --tests
111+
;;
112+
test-vectors)
113+
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
114+
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
115+
;;
116+
lightning-invoice-serde)
117+
# check that compile with no_std and serde works in lightning-invoice
118+
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
119+
;;
120+
no-std-check)
121+
pushd no-std-check && cargo check --verbose --color always && popd
122+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd no-std-check && cargo clean)
123+
;;
124+
msrv-no-dev-deps-check)
125+
# Test that we can build downstream code with only the "release pins".
126+
pushd msrv-no-dev-deps-check && cargo check && popd
127+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd msrv-no-dev-deps-check && cargo clean)
128+
;;
129+
no-std-check-arm)
130+
if [ -f "$(which arm-none-eabi-gcc)" ]; then
131+
pushd no-std-check && cargo build --target=thumbv7m-none-eabi && popd
132+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd no-std-check && cargo clean)
133+
else
134+
echo "Skipping ARM build (arm-none-eabi-gcc not found)"
135+
fi
136+
;;
137+
taproot-tests)
138+
RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning
139+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
140+
;;
141+
simple-close-tests)
142+
RUSTFLAGS="$RUSTFLAGS --cfg=simple_close" cargo test --verbose --color always -p lightning
143+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
144+
;;
145+
lsps1-service-tests)
146+
RUSTFLAGS="$RUSTFLAGS --cfg=lsps1_service" cargo test --verbose --color always -p lightning-liquidity
147+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
148+
;;
149+
peer-storage-tests)
150+
RUSTFLAGS="$RUSTFLAGS --cfg=peer_storage" cargo test --verbose --color always -p lightning
151+
;;
152+
*)
153+
echo "Unknown step: $1"
154+
exit 1
155+
;;
156+
esac
157+
}
91158

92-
if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
93-
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
94-
run_test "tx-sync check (tests only)" cargo check -p lightning-transaction-sync --tests
159+
# All steps in order
160+
ALL_STEPS=(
161+
workspace-check
162+
workspace-tests
163+
ldk-upgrade-tests
164+
workspace-member-checks
165+
lightning-dnssec
166+
block-sync-tests
167+
tx-sync-checks
168+
tx-sync-tests
169+
persister-tests
170+
custom-message-tests
171+
lightning-backtrace
172+
no-std-tests
173+
c-bindings-tests
174+
test-vectors
175+
lightning-invoice-serde
176+
no-std-check
177+
msrv-no-dev-deps-check
178+
no-std-check-arm
179+
taproot-tests
180+
simple-close-tests
181+
lsps1-service-tests
182+
peer-storage-tests
183+
)
184+
185+
# If a step name is passed, run just that step. Otherwise run all.
186+
if [ -n "$1" ]; then
187+
run_step "$1"
95188
else
96-
run_test "tx-sync test (esplora-blocking)" cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
97-
run_test "tx-sync test (esplora-async)" cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
98-
run_test "tx-sync test (esplora-async-https)" cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
99-
run_test "tx-sync test (electrum)" cargo test -p lightning-transaction-sync --verbose --color always --features electrum
100-
fi
101-
102-
run_test "persister test (tokio)" cargo test -p lightning-persister --verbose --color always --features tokio
103-
run_test "persister check (tokio)" cargo check -p lightning-persister --verbose --color always --features tokio
104-
run_test "persister docs (tokio)" cargo doc -p lightning-persister --document-private-items --features tokio
105-
106-
run_test "custom-message test" cargo test -p lightning-custom-message --verbose --color always
107-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
108-
109-
run_test "lightning test (backtrace)" cargo test -p lightning --verbose --color always --features backtrace
110-
111-
for DIR in lightning-invoice lightning-rapid-gossip-sync lightning-liquidity; do
112-
run_test "$DIR test (no-std)" cargo test -p $DIR --verbose --color always --no-default-features
113-
done
114-
115-
run_test "lightning test (no-std)" cargo test -p lightning --verbose --color always --no-default-features
116-
run_test "background-processor test (no-std)" cargo test -p lightning-background-processor --verbose --color always --no-default-features
117-
118-
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
119-
# disable doctests in `c_bindings` so we skip doctests entirely here.
120-
run_test_with_flags "c_bindings test (workspace)" "--cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
121-
122-
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
123-
# check if there is a conflict between no_std and the c_bindings cfg
124-
run_test_with_flags "$DIR test (c_bindings+no-std)" "--cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
125-
done
126-
127-
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
128-
# disable doctests in `c_bindings` so we skip doctests entirely here.
129-
run_test_with_flags "background-processor test (c_bindings+no-std)" "--cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --no-default-features --lib --bins --tests
130-
run_test_with_flags "lightning test (c_bindings+no-std)" "--cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --lib --bins --tests
131-
132-
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
133-
run_test_with_flags "lightning test (test_vectors)" "--cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
134-
# check that compile with no_std and serde works in lightning-invoice
135-
run_test "lightning-invoice test (no-std+serde)" cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
136-
137-
run_test "no-std-check" bash -c 'pushd no-std-check && cargo check --verbose --color always && popd'
138-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd no-std-check && cargo clean)
139-
140-
# Test that we can build downstream code with only the "release pins".
141-
run_test "msrv-no-dev-deps-check" bash -c 'pushd msrv-no-dev-deps-check && cargo check && popd'
142-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd msrv-no-dev-deps-check && cargo clean)
143-
144-
if [ -f "$(which arm-none-eabi-gcc)" ]; then
145-
run_test "no-std-check (ARM)" bash -c 'pushd no-std-check && cargo build --target=thumbv7m-none-eabi && popd'
146-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd no-std-check && cargo clean)
189+
for step in "${ALL_STEPS[@]}"; do
190+
echo -e "\n\n=== Running step: $step ==="
191+
run_step "$step"
192+
done
147193
fi
148-
149-
run_test_with_flags "lightning test (taproot)" "--cfg=taproot" cargo test --verbose --color always -p lightning
150-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
151-
run_test_with_flags "lightning test (simple_close)" "--cfg=simple_close" cargo test --verbose --color always -p lightning
152-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
153-
run_test_with_flags "lightning-liquidity test (lsps1_service)" "--cfg=lsps1_service" cargo test --verbose --color always -p lightning-liquidity
154-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
155-
run_test_with_flags "lightning test (peer_storage)" "--cfg=peer_storage" cargo test --verbose --color always -p lightning

0 commit comments

Comments
 (0)