Remove anchors config flag
[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 1.17 through 1.26 is rustc 1.49. Above 1.26 MSRV is 1.56.
8 [ "$RUSTC_MINOR_VERSION" -lt 49 ] && cargo update -p tokio --precise "1.14.1" --verbose
9 [[ "$RUSTC_MINOR_VERSION" -gt 48  &&  "$RUSTC_MINOR_VERSION" -lt 56 ]] && cargo update -p tokio --precise "1.25.1" --verbose
10
11 # Sadly the log crate is always a dependency of tokio until 1.20, and has no reasonable MSRV guarantees
12 [ "$RUSTC_MINOR_VERSION" -lt 49 ] && cargo update -p log --precise "0.4.18" --verbose
13
14 [ "$LDK_COVERAGE_BUILD" != "" ] && export RUSTFLAGS="-C link-dead-code"
15
16 export RUST_BACKTRACE=1
17
18 echo -e "\n\nBuilding and testing all workspace crates..."
19 cargo build --verbose --color always
20 cargo test --verbose --color always
21
22 echo -e "\n\nBuilding with all Log-Limiting features"
23 pushd lightning
24 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
25         cargo build --verbose --color always --features "$FEATURE"
26 done
27 popd
28
29 if [ "$RUSTC_MINOR_VERSION" -gt 51 ]; then # Current `object` MSRV, subject to change
30         echo -e "\n\nTest backtrace-debug builds"
31         pushd lightning
32         cargo test --verbose --color always --features backtrace
33         popd
34 fi
35
36 echo -e "\n\nTesting no-std flags in various combinations"
37 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
38         pushd $DIR
39         cargo test --verbose --color always --no-default-features --features no-std
40         # check if there is a conflict between no-std and the default std feature
41         cargo test --verbose --color always --features no-std
42         # check if there is a conflict between no-std and the c_bindings cfg
43         RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std
44         popd
45 done
46 # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
47 pushd lightning
48 cargo test --verbose --color always --no-default-features --features=std,_test_vectors
49 popd
50 # This one only works for lightning-invoice
51 pushd lightning-invoice
52 # check that compile with no-std and serde works in lightning-invoice
53 cargo test --verbose --color always --no-default-features --features no-std --features serde
54 popd
55
56 echo -e "\n\nTesting no-std build on a downstream no-std crate"
57 # check no-std compatibility across dependencies
58 pushd no-std-check
59 cargo check --verbose --color always --features lightning-transaction-sync
60 popd
61
62 if [ -f "$(which arm-none-eabi-gcc)" ]; then
63         pushd no-std-check
64         cargo build --target=thumbv7m-none-eabi
65         popd
66 fi
67
68 echo -e "\n\nBuilding and testing Block Sync Clients with features"
69 pushd lightning-block-sync
70 cargo build --verbose --color always --features rest-client
71 cargo test --verbose --color always --features rest-client
72 cargo build --verbose --color always --features rpc-client
73 cargo test --verbose --color always --features rpc-client
74 cargo build --verbose --color always --features rpc-client,rest-client
75 cargo test --verbose --color always --features rpc-client,rest-client
76 cargo build --verbose --color always --features rpc-client,rest-client,tokio
77 cargo test --verbose --color always --features rpc-client,rest-client,tokio
78 popd
79
80 if [[ $RUSTC_MINOR_VERSION -gt 67 && "$HOST_PLATFORM" != *windows* ]]; then
81         echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
82         pushd lightning-transaction-sync
83         cargo build --verbose --color always --features esplora-blocking
84         cargo test --verbose --color always --features esplora-blocking
85         cargo build --verbose --color always --features esplora-async
86         cargo test --verbose --color always --features esplora-async
87         cargo build --verbose --color always --features esplora-async-https
88         cargo test --verbose --color always --features esplora-async-https
89         popd
90 fi
91
92 echo -e "\n\nTest futures builds"
93 pushd lightning-background-processor
94 cargo test --verbose --color always --features futures
95 popd
96
97 if [ "$RUSTC_MINOR_VERSION" -gt 55 ]; then
98         echo -e "\n\nTest Custom Message Macros"
99         pushd lightning-custom-message
100         cargo test --verbose --color always
101         popd
102 fi
103
104 echo -e "\n\nTest Taproot builds"
105 pushd lightning
106 RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning
107 popd