2023-03-15 19:20:08 +00:00
#!/bin/bash
set -eox pipefail
RUSTC_MINOR_VERSION = $( rustc --version | awk '{ split($2,a,"."); print a[2] }' )
HOST_PLATFORM = " $( rustc --version --verbose | grep "host:" | awk '{ print $2 }' ) "
2023-07-17 21:53:07 +00:00
# Some crates require pinning to meet our MSRV even for our downstream users,
# which we do here.
# Further crates which appear only as dev-dependencies are pinned further down.
function PIN_RELEASE_DEPS {
2024-08-01 11:51:53 -05:00
# Starting with version 1.39.0, the `tokio` crate has an MSRV of rustc 1.70.0
[ " $RUSTC_MINOR_VERSION " -lt 70 ] && cargo update -p tokio --precise "1.38.1" --verbose
2024-09-08 21:09:20 +00:00
# Starting with version 0.7.12, the `tokio-util` crate has an MSRV of rustc 1.70.0
[ " $RUSTC_MINOR_VERSION " -lt 70 ] && cargo update -p tokio-util --precise "0.7.11" --verbose
2024-11-04 18:10:20 +01:00
# url 2.5.3 switched to idna 1.0.3 and ICU4X, which requires rustc 1.67 or newer.
# Here we opt to keep using unicode-rs by pinning idna_adapter as described here: https://docs.rs/crate/idna_adapter/1.2.0
[ " $RUSTC_MINOR_VERSION " -lt 67 ] && cargo update -p idna_adapter --precise "1.1.0" --verbose
2024-12-02 16:20:06 +01:00
# indexmap 2.6.0 upgraded to hashbrown 0.15, which unfortunately bumped their MSRV to rustc 1.65 with the 0.15.1 release (and 2.7.0 was released since).
[ " $RUSTC_MINOR_VERSION " -lt 65 ] && cargo update -p indexmap@2.7.0 --precise "2.5.0" --verbose
2024-11-07 14:29:09 +01:00
2024-12-11 22:40:57 -08:00
# Starting with version 0.23.20, the `rustls` crate has an MSRV of rustc 1.71.0
[ " $RUSTC_MINOR_VERSION " -lt 71 ] && cargo update -p rustls@0.23.20 --precise "0.23.19" --verbose
2023-07-17 21:53:07 +00:00
return 0 # Don't fail the script if our rustc is higher than the last check
}
PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
2023-06-12 18:37:17 +00:00
2023-10-24 15:16:38 +02:00
# Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
[ " $RUSTC_MINOR_VERSION " -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
2023-09-14 20:20:56 +00:00
2023-10-24 15:16:38 +02:00
# The addr2line v0.21 crate (a dependency of `backtrace` starting with 0.3.69) relies on rustc 1.65
[ " $RUSTC_MINOR_VERSION " -lt 65 ] && cargo update -p backtrace --precise "0.3.68" --verbose
2023-08-28 19:45:37 +00:00
2024-02-01 09:31:06 +01:00
# Starting with version 0.5.9 (there is no .6-.8), the `home` crate has an MSRV of rustc 1.70.0.
[ " $RUSTC_MINOR_VERSION " -lt 70 ] && cargo update -p home --precise "0.5.5" --verbose
2024-12-03 09:45:19 +01:00
# proptest 1.3.0 requires rustc 1.64.0
[ " $RUSTC_MINOR_VERSION " -lt 64 ] && cargo update -p proptest --precise "1.2.0" --verbose
2023-03-15 19:20:08 +00:00
export RUST_BACKTRACE = 1
2024-09-04 11:10:13 +02:00
echo -e "\n\nChecking the full workspace."
2023-09-17 00:57:00 +00:00
cargo check --verbose --color always
2023-03-15 19:20:08 +00:00
2024-09-13 13:14:40 +02:00
# When the workspace members change, make sure to update the list here as well
# as in `Cargo.toml`.
2024-09-04 11:10:13 +02:00
WORKSPACE_MEMBERS = (
lightning
lightning-types
lightning-block-sync
lightning-invoice
lightning-net-tokio
lightning-persister
lightning-background-processor
lightning-rapid-gossip-sync
lightning-custom-message
lightning-transaction-sync
2024-09-21 13:51:21 +09:00
lightning-macros
2024-07-14 13:08:04 +00:00
lightning-dns-resolver
2024-12-03 09:45:19 +01:00
lightning-liquidity
2024-09-04 11:10:13 +02:00
possiblyrandom
)
echo -e "\n\nChecking, testing, and building docs for all workspace members individually..."
for DIR in " ${ WORKSPACE_MEMBERS [@] } " ; do
cargo test -p " $DIR " --verbose --color always
cargo check -p " $DIR " --verbose --color always
cargo doc -p " $DIR " --document-private-items
done
echo -e "\n\nChecking and testing Block Sync Clients with features"
2024-08-16 20:13:18 +00:00
cargo test -p lightning-block-sync --verbose --color always --features rest-client
cargo check -p lightning-block-sync --verbose --color always --features rest-client
cargo test -p lightning-block-sync --verbose --color always --features rpc-client
cargo check -p lightning-block-sync --verbose --color always --features rpc-client
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
2023-03-15 19:20:08 +00:00
2023-10-24 15:16:38 +02:00
if [ [ " $HOST_PLATFORM " != *windows* ] ] ; then
2024-08-14 09:22:13 +02:00
echo -e "\n\nChecking Transaction Sync Clients with features."
2024-08-16 20:13:18 +00:00
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
cargo check -p lightning-transaction-sync --verbose --color always --features electrum
2024-08-14 09:22:13 +02:00
if [ -z " $CI_ENV " ] && [ [ -z " $BITCOIND_EXE " || -z " $ELECTRS_EXE " ] ] ; then
2024-08-01 10:47:45 -05:00
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
2024-08-16 20:13:18 +00:00
cargo check -p lightning-transaction-sync --tests
2024-08-01 10:47:45 -05:00
else
2024-08-14 09:22:13 +02:00
echo -e "\n\nTesting Transaction Sync Clients with features."
2024-08-16 20:13:18 +00:00
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
cargo test -p lightning-transaction-sync --verbose --color always --features electrum
2024-08-01 10:47:45 -05:00
fi
2023-07-24 22:03:15 +00:00
fi
echo -e "\n\nTest futures builds"
2024-08-16 20:13:18 +00:00
cargo test -p lightning-background-processor --verbose --color always --features futures
2024-08-16 19:07:05 +00:00
cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features
2023-07-24 22:03:15 +00:00
2023-10-24 15:16:38 +02:00
echo -e "\n\nTest Custom Message Macros"
2024-08-16 20:13:18 +00:00
cargo test -p lightning-custom-message --verbose --color always
2023-10-24 15:16:38 +02:00
[ " $CI_MINIMIZE_DISK_USAGE " != "" ] && cargo clean
2023-07-24 22:03:15 +00:00
2023-10-24 15:16:38 +02:00
echo -e "\n\nTest backtrace-debug builds"
2024-08-16 20:13:18 +00:00
cargo test -p lightning --verbose --color always --features backtrace
2023-03-15 19:20:08 +00:00
2024-09-13 13:14:40 +02:00
echo -e "\n\nTesting no_std builds"
2024-12-03 09:45:19 +01:00
for DIR in lightning-invoice lightning-rapid-gossip-sync lightning-liquidity; do
2024-08-16 19:17:42 +00:00
cargo test -p $DIR --verbose --color always --no-default-features
done
2024-09-13 13:14:40 +02:00
cargo test -p lightning --verbose --color always --no-default-features
2024-08-17 20:18:31 +00:00
echo -e "\n\nTesting c_bindings builds"
2024-08-26 19:25:46 +00:00
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
# disable doctests in `c_bindings` so we skip doctests entirely here.
RUSTFLAGS = " $RUSTFLAGS --cfg=c_bindings " cargo test --verbose --color always --lib --bins --tests
2023-10-24 15:16:38 +02:00
2024-08-17 20:18:31 +00:00
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
2024-09-13 13:14:40 +02:00
# check if there is a conflict between no_std and the c_bindings cfg
2024-08-17 20:18:31 +00:00
RUSTFLAGS = " $RUSTFLAGS --cfg=c_bindings " cargo test -p $DIR --verbose --color always --no-default-features
2023-03-15 19:20:08 +00:00
done
2023-10-21 01:08:38 +00:00
2024-08-17 20:18:31 +00:00
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
2024-08-26 19:25:46 +00:00
# disable doctests in `c_bindings` so we skip doctests entirely here.
2024-08-17 20:18:31 +00:00
RUSTFLAGS = " $RUSTFLAGS --cfg=c_bindings " cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features --lib --bins --tests
2024-09-13 13:14:40 +02:00
RUSTFLAGS = " $RUSTFLAGS --cfg=c_bindings " cargo test -p lightning --verbose --color always --no-default-features --lib --bins --tests
2024-08-17 20:18:31 +00:00
echo -e "\n\nTesting other crate-specific builds"
2023-04-19 15:13:35 -07:00
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
2024-08-17 21:06:52 +00:00
RUSTFLAGS = " $RUSTFLAGS --cfg=ldk_test_vectors " cargo test -p lightning --verbose --color always --no-default-features --features= std
2023-04-16 13:17:22 -05:00
# This one only works for lightning-invoice
2024-09-13 13:14:40 +02:00
# check that compile with no_std and serde works in lightning-invoice
2024-08-16 19:17:42 +00:00
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
2023-03-15 19:20:08 +00:00
2024-09-13 13:14:40 +02:00
echo -e "\n\nTesting no_std build on a downstream no-std crate"
2023-03-15 19:20:08 +00:00
# check no-std compatibility across dependencies
pushd no-std-check
2023-10-24 15:16:38 +02:00
cargo check --verbose --color always --features lightning-transaction-sync
2023-10-14 18:41:34 +00:00
[ " $CI_MINIMIZE_DISK_USAGE " != "" ] && cargo clean
2023-03-15 19:20:08 +00:00
popd
2023-07-17 21:53:07 +00:00
# Test that we can build downstream code with only the "release pins".
pushd msrv-no-dev-deps-check
PIN_RELEASE_DEPS
cargo check
2023-10-14 18:41:34 +00:00
[ " $CI_MINIMIZE_DISK_USAGE " != "" ] && cargo clean
2023-07-17 21:53:07 +00:00
popd
2023-03-15 19:20:08 +00:00
if [ -f " $( which arm-none-eabi-gcc) " ] ; then
pushd no-std-check
cargo build --target= thumbv7m-none-eabi
2023-10-14 18:41:34 +00:00
[ " $CI_MINIMIZE_DISK_USAGE " != "" ] && cargo clean
2023-03-15 19:20:08 +00:00
popd
fi
2023-12-13 22:55:32 +00:00
echo -e "\n\nTest cfg-flag builds"
2023-12-12 17:25:09 +01:00
RUSTFLAGS = "--cfg=taproot" cargo test --verbose --color always -p lightning
2024-03-12 15:19:51 +00:00
[ " $CI_MINIMIZE_DISK_USAGE " != "" ] && cargo clean
2024-04-18 08:40:34 +02:00
RUSTFLAGS = "--cfg=splicing" cargo test --verbose --color always -p lightning
2024-06-13 14:09:12 -04:00
[ " $CI_MINIMIZE_DISK_USAGE " != "" ] && cargo clean
RUSTFLAGS = "--cfg=async_payments" cargo test --verbose --color always -p lightning