From: Matt Corallo Date: Fri, 16 Aug 2024 20:13:18 +0000 (+0000) Subject: Ensure we always pass a `path` for in-workspace dependencies X-Git-Tag: v0.0.124-beta~5^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9ca38c59f426034e889ad9a19d0736978c718b32;p=rust-lightning Ensure we always pass a `path` for in-workspace dependencies In order to ensure our crates depend on the workspace copies of each other in test builds we need to override the crates.io dependency with a local `path`. We can do this in one of two ways - either specify the `path` in the dependency listing in each crate's `Cargo.toml` or use the workspace `Cargo.toml` to `patch` all dependencies. The first is tedious while the second lets us have it all in one place. However, the second option does break `cargo *` in individual crate directories (forcing the use of `cargo -p crate *` instead) and makes it rather difficult to depend on local versions of workspace crates. Thus, here we drop the `patch.crates-io` from our top-level `Cargo.toml` entirely. Still, we do update the `ci/ci-tests.sh` script here to use `cargo -p crate` instead of switching to each crate's directory as it allows `cargo` to use a shared `target` and may speed up tests. --- diff --git a/Cargo.toml b/Cargo.toml index f7f4ba021..d1e2f0e05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,9 +41,6 @@ opt-level = 3 lto = true panic = "abort" -[patch.crates-io.possiblyrandom] -path = "possiblyrandom" - [workspace.lints.rust.unexpected_cfgs] level = "forbid" # When adding a new cfg attribute, ensure that it is added to this list. diff --git a/ci/ci-tests.sh b/ci/ci-tests.sh index 43d6aeaa4..ff955666c 100755 --- a/ci/ci-tests.sh +++ b/ci/ci-tests.sh @@ -32,60 +32,49 @@ cargo test --verbose --color always cargo check --verbose --color always echo -e "\n\nBuilding and testing Block Sync Clients with features" -pushd lightning-block-sync -cargo test --verbose --color always --features rest-client -cargo check --verbose --color always --features rest-client -cargo test --verbose --color always --features rpc-client -cargo check --verbose --color always --features rpc-client -cargo test --verbose --color always --features rpc-client,rest-client -cargo check --verbose --color always --features rpc-client,rest-client -cargo test --verbose --color always --features rpc-client,rest-client,tokio -cargo check --verbose --color always --features rpc-client,rest-client,tokio -popd + +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 if [[ "$HOST_PLATFORM" != *windows* ]]; then - pushd lightning-transaction-sync echo -e "\n\nChecking Transaction Sync Clients with features." - cargo check --verbose --color always --features esplora-blocking - cargo check --verbose --color always --features esplora-async - cargo check --verbose --color always --features esplora-async-https - cargo check --verbose --color always --features electrum + 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 if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset." - cargo check --tests + cargo check -p lightning-transaction-sync --tests else echo -e "\n\nTesting Transaction Sync Clients with features." - cargo test --verbose --color always --features esplora-blocking - cargo test --verbose --color always --features esplora-async - cargo test --verbose --color always --features esplora-async-https - cargo test --verbose --color always --features electrum + 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 fi - popd fi echo -e "\n\nTest futures builds" -pushd lightning-background-processor -cargo test --verbose --color always --features futures -popd +cargo test -p lightning-background-processor --verbose --color always --features futures echo -e "\n\nTest Custom Message Macros" -pushd lightning-custom-message -cargo test --verbose --color always +cargo test -p lightning-custom-message --verbose --color always [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean -popd echo -e "\n\nTest backtrace-debug builds" -pushd lightning -cargo test --verbose --color always --features backtrace -popd +cargo test -p lightning --verbose --color always --features backtrace echo -e "\n\nBuilding with all Log-Limiting features" -pushd lightning -grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do - RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE" +grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do + RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE" done -popd echo -e "\n\nTesting no-std flags in various combinations" for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do @@ -101,14 +90,10 @@ done RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values -pushd lightning -cargo test --verbose --color always --no-default-features --features=std,_test_vectors -popd +cargo test -p lightning --verbose --color always --no-default-features --features=std,_test_vectors # This one only works for lightning-invoice -pushd lightning-invoice # check that compile with no-std and serde works in lightning-invoice -cargo test --verbose --color always --no-default-features --features no-std --features serde -popd +cargo test -p lightning-invoice --verbose --color always --no-default-features --features no-std --features serde echo -e "\n\nTesting no-std build on a downstream no-std crate" # check no-std compatibility across dependencies diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index 9f310c12d..6fab8d5ec 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -47,7 +47,7 @@ bech32 = { version = "0.9.1", default-features = false } bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] } hashbrown = { version = "0.13", optional = true, default-features = false } -possiblyrandom = { version = "0.2", optional = true, default-features = false } +possiblyrandom = { version = "0.2", path = "../possiblyrandom", optional = true, default-features = false } regex = { version = "1.5.6", optional = true } backtrace = { version = "0.3", optional = true } diff --git a/no-std-check/Cargo.toml b/no-std-check/Cargo.toml index 45a70c2a6..c9d404c92 100644 --- a/no-std-check/Cargo.toml +++ b/no-std-check/Cargo.toml @@ -15,6 +15,3 @@ lightning-background-processor = { path = "../lightning-background-processor", f # Obviously lightning-transaction-sync doesn't support no-std, but it should build # even if lightning is built with no-std. lightning-transaction-sync = { path = "../lightning-transaction-sync", optional = true } - -[patch.crates-io] -possiblyrandom = { path = "../possiblyrandom" }