]> git.bitcoin.ninja Git - rust-lightning/blob - ci/ci-tests.sh
8dfb432666dbb5ffc92a61294026439a9c6f785f
[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 # Some crates require pinning to meet our MSRV even for our downstream users,
8 # which we do here.
9 # Further crates which appear only as dev-dependencies are pinned further down.
10 function PIN_RELEASE_DEPS {
11         return 0 # Don't fail the script if our rustc is higher than the last check
12 }
13
14 PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
15
16 # Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
17 [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
18
19 # The addr2line v0.21 crate (a dependency of `backtrace` starting with 0.3.69) relies on rustc 1.65
20 [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p backtrace --precise "0.3.68" --verbose
21
22 export RUST_BACKTRACE=1
23
24 echo -e "\n\nBuilding and testing all workspace crates..."
25 cargo test --verbose --color always
26 cargo check --verbose --color always
27
28 echo -e "\n\nBuilding and testing Block Sync Clients with features"
29 pushd lightning-block-sync
30 cargo test --verbose --color always --features rest-client
31 cargo check --verbose --color always --features rest-client
32 cargo test --verbose --color always --features rpc-client
33 cargo check --verbose --color always --features rpc-client
34 cargo test --verbose --color always --features rpc-client,rest-client
35 cargo check --verbose --color always --features rpc-client,rest-client
36 cargo test --verbose --color always --features rpc-client,rest-client,tokio
37 cargo check --verbose --color always --features rpc-client,rest-client,tokio
38 popd
39
40 if [[ "$HOST_PLATFORM" != *windows* ]]; then
41         echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
42         pushd lightning-transaction-sync
43
44         # zstd-sys 2.0.9+zstd.1.5.5 requires rustc 1.64.0
45         [ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5" --verbose
46         # reqwest 0.11.21 had a regression that broke its 1.63.0 MSRV
47         [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p reqwest --precise "0.11.20" --verbose
48         # jobserver 0.1.27 requires rustc 1.66.0
49         [ "$RUSTC_MINOR_VERSION" -lt 66 ] && cargo update -p jobserver --precise "0.1.26" --verbose
50         # Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
51         [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
52
53         cargo test --verbose --color always --features esplora-blocking
54         cargo check --verbose --color always --features esplora-blocking
55         cargo test --verbose --color always --features esplora-async
56         cargo check --verbose --color always --features esplora-async
57         cargo test --verbose --color always --features esplora-async-https
58         cargo check --verbose --color always --features esplora-async-https
59         cargo test --verbose --color always --features electrum
60         cargo check --verbose --color always --features electrum
61
62         popd
63 fi
64
65 echo -e "\n\nTest futures builds"
66 pushd lightning-background-processor
67 cargo test --verbose --color always --features futures
68 popd
69
70 echo -e "\n\nTest Custom Message Macros"
71 pushd lightning-custom-message
72 cargo test --verbose --color always
73 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
74 popd
75
76 echo -e "\n\nTest backtrace-debug builds"
77 pushd lightning
78 cargo test --verbose --color always --features backtrace
79 popd
80
81 echo -e "\n\nBuilding with all Log-Limiting features"
82 pushd lightning
83 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
84         cargo check --verbose --color always --features "$FEATURE"
85 done
86 popd
87
88 echo -e "\n\nTesting no-std flags in various combinations"
89 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
90         cargo test -p $DIR --verbose --color always --no-default-features --features no-std
91         # check if there is a conflict between no-std and the default std feature
92         cargo test -p $DIR --verbose --color always --features no-std
93 done
94
95 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
96         # check if there is a conflict between no-std and the c_bindings cfg
97         RUSTFLAGS="--cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
98 done
99 RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always
100
101 # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
102 pushd lightning
103 cargo test --verbose --color always --no-default-features --features=std,_test_vectors
104 popd
105 # This one only works for lightning-invoice
106 pushd lightning-invoice
107 # check that compile with no-std and serde works in lightning-invoice
108 cargo test --verbose --color always --no-default-features --features no-std --features serde
109 popd
110
111 echo -e "\n\nTesting no-std build on a downstream no-std crate"
112 # check no-std compatibility across dependencies
113 pushd no-std-check
114 cargo check --verbose --color always --features lightning-transaction-sync
115 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
116 popd
117
118 # Test that we can build downstream code with only the "release pins".
119 pushd msrv-no-dev-deps-check
120 PIN_RELEASE_DEPS
121 cargo check
122 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
123 popd
124
125 if [ -f "$(which arm-none-eabi-gcc)" ]; then
126         pushd no-std-check
127         cargo build --target=thumbv7m-none-eabi
128         [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
129         popd
130 fi
131
132 echo -e "\n\nTest Taproot builds"
133 pushd lightning
134 RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning
135 popd