Replace the bulk of CI with a (much simpler) bash script
[rust-lightning] / ci / ci-tests.sh
1 #!/bin/bash
2 set -eox pipefail
3
4 RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
5 HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
6
7 # Tokio MSRV on versions newer than 1.14 is rustc 1.49
8 [ "$RUSTC_MINOR_VERSION" -lt 49 ] && cargo update -p tokio --precise "1.14.0" --verbose
9 [ "$LDK_COVERAGE_BUILD" != "" ] && export RUSTFLAGS="-C link-dead-code"
10
11 export RUST_BACKTRACE=1
12
13 echo -e "\n\nBuilding and testing all workspace crates..."
14 cargo build --verbose --color always
15 cargo test --verbose --color always
16
17 echo -e "\n\nBuilding with all Log-Limiting features"
18 pushd lightning
19 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
20         cargo build --verbose --color always --features "$FEATURE"
21 done
22 popd
23
24 if [ "$RUSTC_MINOR_VERSION" -gt 51 ]; then # Current `object` MSRV, subject to change
25         echo -e "\n\nTest backtrace-debug builds"
26         pushd lightning
27         cargo test --verbose --color always --features backtrace
28         popd
29 fi
30
31 echo -e "\n\nTesting no-std flags in various combinations"
32 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
33         pushd $DIR
34         cargo test --verbose --color always --no-default-features --features no-std
35         # check if there is a conflict between no-std and the default std feature
36         cargo test --verbose --color always --features no-std
37         # check that things still pass without grind_signatures
38         # note that outbound_commitment_test only runs in this mode, because of hardcoded signature values
39         cargo test --verbose --color always --no-default-features --features std
40         # check if there is a conflict between no-std and the c_bindings cfg
41         RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std
42         popd
43 done
44
45 echo -e "\n\nTesting no-std build on a downstream no-std crate"
46 # check no-std compatibility across dependencies
47 pushd no-std-check
48 cargo check --verbose --color always --features lightning-transaction-sync
49 popd
50
51 if [ -f "$(which arm-none-eabi-gcc)" ]; then
52         pushd no-std-check
53         cargo build --target=thumbv7m-none-eabi
54         popd
55 fi
56
57 echo -e "\n\nBuilding and testing Block Sync Clients with features"
58 pushd lightning-block-sync
59 cargo build --verbose --color always --features rest-client
60 cargo test --verbose --color always --features rest-client
61 cargo build --verbose --color always --features rpc-client
62 cargo test --verbose --color always --features rpc-client
63 cargo build --verbose --color always --features rpc-client,rest-client
64 cargo test --verbose --color always --features rpc-client,rest-client
65 cargo build --verbose --color always --features rpc-client,rest-client,tokio
66 cargo test --verbose --color always --features rpc-client,rest-client,tokio
67 popd
68
69 if [[ $RUSTC_MINOR_VERSION -gt 67 && "$HOST_PLATFORM" != *windows* ]]; then
70         echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
71         pushd lightning-transaction-sync
72         cargo build --verbose --color always --features esplora-blocking
73         cargo test --verbose --color always --features esplora-blocking
74         cargo build --verbose --color always --features esplora-async
75         cargo test --verbose --color always --features esplora-async
76         cargo build --verbose --color always --features esplora-async-https
77         cargo test --verbose --color always --features esplora-async-https
78         popd
79 fi
80
81 echo -e "\n\nTest futures builds"
82 pushd lightning-background-processor
83 cargo test --verbose --color always --no-default-features --features futures
84 popd
85
86 if [ "$RUSTC_MINOR_VERSION" -gt 55 ]; then
87         echo -e "\n\nTest Custom Message Macros"
88         pushd lightning-custom-message
89         cargo test --verbose --color always
90         popd
91 fi