Skip to content

Commit 9ca38c5

Browse files
committed
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.
1 parent f8b7ad2 commit 9ca38c5

File tree

4 files changed

+26
-47
lines changed

4 files changed

+26
-47
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ opt-level = 3
4141
lto = true
4242
panic = "abort"
4343

44-
[patch.crates-io.possiblyrandom]
45-
path = "possiblyrandom"
46-
4744
[workspace.lints.rust.unexpected_cfgs]
4845
level = "forbid"
4946
# When adding a new cfg attribute, ensure that it is added to this list.

ci/ci-tests.sh

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,60 +32,49 @@ cargo test --verbose --color always
3232
cargo check --verbose --color always
3333

3434
echo -e "\n\nBuilding and testing Block Sync Clients with features"
35-
pushd lightning-block-sync
36-
cargo test --verbose --color always --features rest-client
37-
cargo check --verbose --color always --features rest-client
38-
cargo test --verbose --color always --features rpc-client
39-
cargo check --verbose --color always --features rpc-client
40-
cargo test --verbose --color always --features rpc-client,rest-client
41-
cargo check --verbose --color always --features rpc-client,rest-client
42-
cargo test --verbose --color always --features rpc-client,rest-client,tokio
43-
cargo check --verbose --color always --features rpc-client,rest-client,tokio
44-
popd
35+
36+
cargo test -p lightning-block-sync --verbose --color always --features rest-client
37+
cargo check -p lightning-block-sync --verbose --color always --features rest-client
38+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client
39+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client
40+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
41+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
42+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
43+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
4544

4645
if [[ "$HOST_PLATFORM" != *windows* ]]; then
47-
pushd lightning-transaction-sync
4846
echo -e "\n\nChecking Transaction Sync Clients with features."
49-
cargo check --verbose --color always --features esplora-blocking
50-
cargo check --verbose --color always --features esplora-async
51-
cargo check --verbose --color always --features esplora-async-https
52-
cargo check --verbose --color always --features electrum
47+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
48+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
49+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
50+
cargo check -p lightning-transaction-sync --verbose --color always --features electrum
5351

5452
if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
5553
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
56-
cargo check --tests
54+
cargo check -p lightning-transaction-sync --tests
5755
else
5856
echo -e "\n\nTesting Transaction Sync Clients with features."
59-
cargo test --verbose --color always --features esplora-blocking
60-
cargo test --verbose --color always --features esplora-async
61-
cargo test --verbose --color always --features esplora-async-https
62-
cargo test --verbose --color always --features electrum
57+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
58+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
59+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
60+
cargo test -p lightning-transaction-sync --verbose --color always --features electrum
6361
fi
64-
popd
6562
fi
6663

6764
echo -e "\n\nTest futures builds"
68-
pushd lightning-background-processor
69-
cargo test --verbose --color always --features futures
70-
popd
65+
cargo test -p lightning-background-processor --verbose --color always --features futures
7166

7267
echo -e "\n\nTest Custom Message Macros"
73-
pushd lightning-custom-message
74-
cargo test --verbose --color always
68+
cargo test -p lightning-custom-message --verbose --color always
7569
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
76-
popd
7770

7871
echo -e "\n\nTest backtrace-debug builds"
79-
pushd lightning
80-
cargo test --verbose --color always --features backtrace
81-
popd
72+
cargo test -p lightning --verbose --color always --features backtrace
8273

8374
echo -e "\n\nBuilding with all Log-Limiting features"
84-
pushd lightning
85-
grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
86-
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE"
75+
grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
76+
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE"
8777
done
88-
popd
8978

9079
echo -e "\n\nTesting no-std flags in various combinations"
9180
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
@@ -101,14 +90,10 @@ done
10190
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
10291

10392
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
104-
pushd lightning
105-
cargo test --verbose --color always --no-default-features --features=std,_test_vectors
106-
popd
93+
cargo test -p lightning --verbose --color always --no-default-features --features=std,_test_vectors
10794
# This one only works for lightning-invoice
108-
pushd lightning-invoice
10995
# check that compile with no-std and serde works in lightning-invoice
110-
cargo test --verbose --color always --no-default-features --features no-std --features serde
111-
popd
96+
cargo test -p lightning-invoice --verbose --color always --no-default-features --features no-std --features serde
11297

11398
echo -e "\n\nTesting no-std build on a downstream no-std crate"
11499
# check no-std compatibility across dependencies

lightning/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bech32 = { version = "0.9.1", default-features = false }
4747
bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
4848

4949
hashbrown = { version = "0.13", optional = true, default-features = false }
50-
possiblyrandom = { version = "0.2", optional = true, default-features = false }
50+
possiblyrandom = { version = "0.2", path = "../possiblyrandom", optional = true, default-features = false }
5151
regex = { version = "1.5.6", optional = true }
5252
backtrace = { version = "0.3", optional = true }
5353

no-std-check/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ lightning-background-processor = { path = "../lightning-background-processor", f
1515
# Obviously lightning-transaction-sync doesn't support no-std, but it should build
1616
# even if lightning is built with no-std.
1717
lightning-transaction-sync = { path = "../lightning-transaction-sync", optional = true }
18-
19-
[patch.crates-io]
20-
possiblyrandom = { path = "../possiblyrandom" }

0 commit comments

Comments
 (0)