Skip to content

Commit 03aa9f1

Browse files
joostjagerclaude
andcommitted
ci: Add GitHub Job Summary reporting to ci-tests.sh
Add run_test() and run_test_with_flags() wrapper functions that report test results to GitHub Actions Job Summaries. Each test is logged with its name, pass/fail status, and duration in a markdown table. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 9e91b2e commit 03aa9f1

File tree

1 file changed

+90
-77
lines changed

1 file changed

+90
-77
lines changed

ci/ci-tests.sh

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

14+
# Initialize GitHub Actions Job Summary
15+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
16+
{
17+
echo "## CI Test Results"
18+
echo ""
19+
echo "| Test | Status | Duration |"
20+
echo "|------|--------|----------|"
21+
} >> "$GITHUB_STEP_SUMMARY"
22+
fi
23+
24+
# Run a test command and report results to GitHub Job Summary
25+
# Usage: run_test "Test Name" command arg1 arg2 ...
26+
function run_test {
27+
local name="$1"
28+
shift
29+
local start end duration
30+
31+
echo -e "\n\n$name"
32+
start=$(date +%s)
33+
if "$@"; then
34+
end=$(date +%s)
35+
duration=$((end - start))
36+
[ -n "$GITHUB_STEP_SUMMARY" ] && echo "| $name | ✅ | ${duration}s |" >> "$GITHUB_STEP_SUMMARY"
37+
return 0
38+
else
39+
end=$(date +%s)
40+
duration=$((end - start))
41+
[ -n "$GITHUB_STEP_SUMMARY" ] && echo "| $name | ❌ | ${duration}s |" >> "$GITHUB_STEP_SUMMARY"
42+
return 1
43+
fi
44+
}
45+
46+
# Run a test command with custom RUSTFLAGS
47+
# Usage: run_test_with_flags "Test Name" "extra flags" command arg1 arg2 ...
48+
function run_test_with_flags {
49+
local name="$1"
50+
local extra_flags="$2"
51+
shift 2
52+
RUSTFLAGS="$RUSTFLAGS $extra_flags" run_test "$name" "$@"
53+
}
54+
1455
PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
1556

1657
# The backtrace v0.3.75 crate relies on rustc 1.82
@@ -24,126 +65,98 @@ PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
2465

2566
export RUST_BACKTRACE=1
2667

27-
echo -e "\n\nChecking the workspace, except lightning-transaction-sync."
28-
cargo check --verbose --color always
68+
run_test "Workspace check" cargo check --verbose --color always
2969

3070
WORKSPACE_MEMBERS=( $(cat Cargo.toml | tr '\n' '\r' | sed 's/\r //g' | tr '\r' '\n' | grep '^members =' | sed 's/members.*=.*\[//' | tr -d '"' | tr ',' ' ') )
3171

32-
echo -e "\n\nTesting the workspace, except lightning-transaction-sync."
33-
cargo test --verbose --color always
72+
run_test "Workspace tests" cargo test --verbose --color always
3473

35-
echo -e "\n\nTesting upgrade from prior versions of LDK"
36-
pushd lightning-tests
37-
cargo test
38-
popd
74+
run_test "LDK upgrade tests" bash -c 'pushd lightning-tests && cargo test && popd'
3975

40-
echo -e "\n\nChecking and building docs for all workspace members individually..."
4176
for DIR in "${WORKSPACE_MEMBERS[@]}"; do
42-
cargo check -p "$DIR" --verbose --color always
43-
cargo doc -p "$DIR" --document-private-items
77+
run_test "Check $DIR" cargo check -p "$DIR" --verbose --color always
78+
run_test "Docs $DIR" cargo doc -p "$DIR" --document-private-items
4479
done
4580

46-
echo -e "\n\nChecking and testing lightning with features"
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-
echo -e "\n\nChecking and testing Block Sync Clients with features"
81+
run_test "lightning tests (dnssec)" cargo test -p lightning --verbose --color always --features dnssec
82+
run_test "lightning check (dnssec)" cargo check -p lightning --verbose --color always --features dnssec
83+
run_test "lightning docs (dnssec)" cargo doc -p lightning --document-private-items --features dnssec
5284

53-
cargo test -p lightning-block-sync --verbose --color always --features rest-client
54-
cargo check -p lightning-block-sync --verbose --color always --features rest-client
55-
cargo test -p lightning-block-sync --verbose --color always --features rpc-client
56-
cargo check -p lightning-block-sync --verbose --color always --features rpc-client
57-
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
58-
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
59-
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
60-
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
85+
run_test "block-sync test (rest-client)" cargo test -p lightning-block-sync --verbose --color always --features rest-client
86+
run_test "block-sync check (rest-client)" cargo check -p lightning-block-sync --verbose --color always --features rest-client
87+
run_test "block-sync test (rpc-client)" cargo test -p lightning-block-sync --verbose --color always --features rpc-client
88+
run_test "block-sync check (rpc-client)" cargo check -p lightning-block-sync --verbose --color always --features rpc-client
89+
run_test "block-sync test (rpc+rest)" cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
90+
run_test "block-sync check (rpc+rest)" cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
91+
run_test "block-sync test (rpc+rest+tokio)" cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
92+
run_test "block-sync check (rpc+rest+tokio)" cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
6193

62-
echo -e "\n\nChecking Transaction Sync Clients with features."
63-
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
64-
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
65-
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
66-
cargo check -p lightning-transaction-sync --verbose --color always --features electrum
94+
run_test "tx-sync check (esplora-blocking)" cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
95+
run_test "tx-sync check (esplora-async)" cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
96+
run_test "tx-sync check (esplora-async-https)" cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
97+
run_test "tx-sync check (electrum)" cargo check -p lightning-transaction-sync --verbose --color always --features electrum
6798

6899
if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
69100
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
101+
run_test "tx-sync check (tests only)" cargo check -p lightning-transaction-sync --tests
71102
else
72-
echo -e "\n\nTesting Transaction Sync Clients with features."
73-
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
74-
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
75-
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
76-
cargo test -p lightning-transaction-sync --verbose --color always --features electrum
103+
run_test "tx-sync test (esplora-blocking)" cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
104+
run_test "tx-sync test (esplora-async)" cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
105+
run_test "tx-sync test (esplora-async-https)" cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
106+
run_test "tx-sync test (electrum)" cargo test -p lightning-transaction-sync --verbose --color always --features electrum
77107
fi
78108

79-
echo -e "\n\nChecking and testing lightning-persister with features"
80-
cargo test -p lightning-persister --verbose --color always --features tokio
81-
cargo check -p lightning-persister --verbose --color always --features tokio
82-
cargo doc -p lightning-persister --document-private-items --features tokio
109+
run_test "persister test (tokio)" cargo test -p lightning-persister --verbose --color always --features tokio
110+
run_test "persister check (tokio)" cargo check -p lightning-persister --verbose --color always --features tokio
111+
run_test "persister docs (tokio)" cargo doc -p lightning-persister --document-private-items --features tokio
83112

84-
echo -e "\n\nTest Custom Message Macros"
85-
cargo test -p lightning-custom-message --verbose --color always
113+
run_test "custom-message test" cargo test -p lightning-custom-message --verbose --color always
86114
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
87115

88-
echo -e "\n\nTest backtrace-debug builds"
89-
cargo test -p lightning --verbose --color always --features backtrace
116+
run_test "lightning test (backtrace)" cargo test -p lightning --verbose --color always --features backtrace
90117

91-
echo -e "\n\nTesting no_std builds"
92118
for DIR in lightning-invoice lightning-rapid-gossip-sync lightning-liquidity; do
93-
cargo test -p $DIR --verbose --color always --no-default-features
119+
run_test "$DIR test (no-std)" cargo test -p $DIR --verbose --color always --no-default-features
94120
done
95121

96-
cargo test -p lightning --verbose --color always --no-default-features
97-
cargo test -p lightning-background-processor --verbose --color always --no-default-features
122+
run_test "lightning test (no-std)" cargo test -p lightning --verbose --color always --no-default-features
123+
run_test "background-processor test (no-std)" cargo test -p lightning-background-processor --verbose --color always --no-default-features
98124

99-
echo -e "\n\nTesting c_bindings builds"
100125
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
101126
# disable doctests in `c_bindings` so we skip doctests entirely here.
102-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
127+
run_test_with_flags "c_bindings test (workspace)" "--cfg=c_bindings" cargo test --verbose --color always --lib --bins --tests
103128

104129
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
105130
# check if there is a conflict between no_std and the c_bindings cfg
106-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
131+
run_test_with_flags "$DIR test (c_bindings+no-std)" "--cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
107132
done
108133

109134
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
110135
# disable doctests in `c_bindings` so we skip doctests entirely here.
111-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --no-default-features --lib --bins --tests
112-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --lib --bins --tests
136+
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
137+
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
113138

114-
echo -e "\n\nTesting other crate-specific builds"
115139
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
116-
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
117-
# This one only works for lightning-invoice
140+
run_test_with_flags "lightning test (test_vectors)" "--cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
118141
# check that compile with no_std and serde works in lightning-invoice
119-
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
142+
run_test "lightning-invoice test (no-std+serde)" cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
120143

121-
echo -e "\n\nTesting no_std build on a downstream no-std crate"
122-
# check no-std compatibility across dependencies
123-
pushd no-std-check
124-
cargo check --verbose --color always
125-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
126-
popd
144+
run_test "no-std-check" bash -c 'pushd no-std-check && cargo check --verbose --color always && popd'
145+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd no-std-check && cargo clean)
127146

128147
# Test that we can build downstream code with only the "release pins".
129-
pushd msrv-no-dev-deps-check
130-
PIN_RELEASE_DEPS
131-
cargo check
132-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
133-
popd
148+
run_test "msrv-no-dev-deps-check" bash -c 'pushd msrv-no-dev-deps-check && cargo check && popd'
149+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd msrv-no-dev-deps-check && cargo clean)
134150

135151
if [ -f "$(which arm-none-eabi-gcc)" ]; then
136-
pushd no-std-check
137-
cargo build --target=thumbv7m-none-eabi
138-
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
139-
popd
152+
run_test "no-std-check (ARM)" bash -c 'pushd no-std-check && cargo build --target=thumbv7m-none-eabi && popd'
153+
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && (cd no-std-check && cargo clean)
140154
fi
141155

142-
echo -e "\n\nTest cfg-flag builds"
143-
RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
156+
run_test_with_flags "lightning test (taproot)" "--cfg=taproot" cargo test --verbose --color always -p lightning
144157
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
145-
RUSTFLAGS="--cfg=simple_close" cargo test --verbose --color always -p lightning
158+
run_test_with_flags "lightning test (simple_close)" "--cfg=simple_close" cargo test --verbose --color always -p lightning
146159
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
147-
RUSTFLAGS="--cfg=lsps1_service" cargo test --verbose --color always -p lightning-liquidity
160+
run_test_with_flags "lightning-liquidity test (lsps1_service)" "--cfg=lsps1_service" cargo test --verbose --color always -p lightning-liquidity
148161
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
149-
RUSTFLAGS="--cfg=peer_storage" cargo test --verbose --color always -p lightning
162+
run_test_with_flags "lightning test (peer_storage)" "--cfg=peer_storage" cargo test --verbose --color always -p lightning

0 commit comments

Comments
 (0)