Skip to content

Commit 217c3e0

Browse files
authored
Merge pull request #2107 from TheBlueMatt/2023-04-msrv-cleanup
Bump MSRV to 1.48 and replace most of CI with a bash script
2 parents 12d799e + 6558b51 commit 217c3e0

File tree

3 files changed

+116
-212
lines changed

3 files changed

+116
-212
lines changed

.github/workflows/build.yml

+23-210
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,21 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
platform: [ ubuntu-latest ]
11-
toolchain: [ stable,
12-
beta,
13-
# 1.41.1 is MSRV for Rust-Lightning, lightning-invoice, and lightning-persister
14-
1.41.1,
15-
# 1.45.2 is MSRV for lightning-net-tokio, lightning-block-sync, lightning-background-processor
16-
1.45.2,
17-
# 1.47.0 will be the MSRV for no-std builds using hashbrown once core2 is updated
18-
1.47.0]
10+
platform: [ ubuntu-latest, windows-latest, macos-latest ]
11+
toolchain: [ stable, beta ]
1912
include:
2013
- toolchain: stable
21-
build-net-tokio: true
22-
build-no-std: true
23-
build-futures: true
24-
build-tx-sync: true
14+
platform: ubuntu-latest
2515
coverage: true
26-
- toolchain: stable
27-
platform: macos-latest
28-
build-net-tokio: true
29-
build-no-std: true
30-
build-futures: true
31-
build-tx-sync: true
32-
- toolchain: stable
33-
test-custom-message: true
34-
- toolchain: beta
35-
platform: macos-latest
36-
build-net-tokio: true
37-
build-no-std: true
38-
build-futures: true
39-
build-tx-sync: true
40-
- toolchain: stable
16+
# 1.48.0 is the MSRV for all crates except lightning-transaction-sync and Win/Mac
17+
- toolchain: 1.48.0
18+
platform: ubuntu-latest
19+
# Windows requires 1.49.0 because that's the MSRV for supported Tokio
20+
- toolchain: 1.49.0
4121
platform: windows-latest
42-
build-net-tokio: true
43-
build-no-std: true
44-
build-futures: true
45-
build-tx-sync: false
46-
- toolchain: beta
47-
platform: windows-latest
48-
build-net-tokio: true
49-
build-no-std: true
50-
build-futures: true
51-
build-tx-sync: false
52-
- toolchain: beta
53-
build-net-tokio: true
54-
build-no-std: true
55-
build-futures: true
56-
build-tx-sync: true
57-
- toolchain: beta
58-
test-custom-message: true
59-
- toolchain: 1.41.1
60-
build-no-std: false
61-
test-log-variants: true
62-
build-futures: false
63-
build-tx-sync: false
64-
- toolchain: 1.45.2
65-
build-net-old-tokio: true
66-
build-net-tokio: true
67-
build-no-std: false
68-
build-futures: true
69-
build-tx-sync: false
70-
- toolchain: 1.47.0
71-
build-futures: true
72-
build-no-std: true
73-
build-tx-sync: false
22+
# MacOS-latest requires 1.54.0 because that's what's required for linking to work properly
23+
- toolchain: 1.54.0
24+
platform: macos-latest
7425
runs-on: ${{ matrix.platform }}
7526
steps:
7627
- name: Checkout source code
@@ -81,162 +32,24 @@ jobs:
8132
toolchain: ${{ matrix.toolchain }}
8233
override: true
8334
profile: minimal
84-
- name: Pin tokio to 1.14 for Rust 1.45
85-
if: "matrix.build-net-old-tokio"
86-
run: cargo update -p tokio --precise "1.14.0" --verbose
87-
env:
88-
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
89-
- name: Pin tokio to 1.26 for Windows
90-
if: "matrix.platform == 'windows-latest'"
91-
run: cargo update -p tokio --precise "1.26.0" --verbose
92-
env:
93-
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
94-
- name: Build on Rust ${{ matrix.toolchain }} with net-tokio
95-
if: "matrix.build-net-tokio && !matrix.coverage"
96-
run: cargo build --verbose --color always
97-
- name: Build on Rust ${{ matrix.toolchain }} with net-tokio, and full code-linking for coverage generation
98-
if: matrix.coverage
99-
run: RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always
100-
- name: Build on Rust ${{ matrix.toolchain }}
101-
if: "! matrix.build-net-tokio"
102-
run: |
103-
cargo build --verbose --color always -p lightning
104-
cargo build --verbose --color always -p lightning-invoice
105-
cargo build --verbose --color always -p lightning-persister
106-
- name: Build on Rust ${{ matrix.toolchain }} with all Log-Limiting features
107-
if: matrix.test-log-variants
108-
run: |
109-
cd lightning
110-
for FEATURE in $(cat Cargo.toml | grep '^max_level_' | awk '{ print $1 }'); do
111-
cargo build --verbose --color always --features $FEATURE
112-
done
113-
- name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features
114-
if: "matrix.build-net-tokio && !matrix.coverage"
115-
run: |
116-
cd lightning-block-sync
117-
cargo build --verbose --color always --features rest-client
118-
cargo build --verbose --color always --features rpc-client
119-
cargo build --verbose --color always --features rpc-client,rest-client
120-
cargo build --verbose --color always --features rpc-client,rest-client,tokio
121-
- name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
122-
if: matrix.coverage
123-
run: |
124-
cd lightning-block-sync
125-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rest-client
126-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client
127-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
128-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client,tokio
129-
- name: Build Transaction Sync Clients on Rust ${{ matrix.toolchain }} with features
130-
if: "matrix.build-tx-sync && !matrix.coverage"
131-
run: |
132-
cd lightning-transaction-sync
133-
cargo build --verbose --color always --features esplora-blocking
134-
cargo build --verbose --color always --features esplora-async
135-
cargo build --verbose --color always --features esplora-async-https
136-
- name: Build transaction sync clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
137-
if: "matrix.build-tx-sync && matrix.coverage"
35+
- name: Install no-std-check dependencies for ARM Embedded
36+
if: "matrix.platform == 'ubuntu-latest'"
13837
run: |
139-
cd lightning-transaction-sync
140-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-blocking
141-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async
142-
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async-https
143-
- name: Test transaction sync clients on Rust ${{ matrix.toolchain }} with features
144-
if: "matrix.build-tx-sync"
145-
run: |
146-
cd lightning-transaction-sync
147-
cargo test --verbose --color always --features esplora-blocking
148-
cargo test --verbose --color always --features esplora-async
149-
cargo test --verbose --color always --features esplora-async-https
150-
- name: Test backtrace-debug builds on Rust ${{ matrix.toolchain }}
151-
if: "matrix.toolchain == 'stable'"
152-
shell: bash # Default on Winblows is powershell
153-
run: |
154-
cd lightning && RUST_BACKTRACE=1 cargo test --verbose --color always --features backtrace
155-
- name: Test on Rust ${{ matrix.toolchain }} with net-tokio
156-
if: "matrix.build-net-tokio && !matrix.coverage"
157-
run: cargo test --verbose --color always
158-
- name: Test on Rust ${{ matrix.toolchain }} with net-tokio, and full code-linking for coverage generation
159-
if: matrix.coverage
160-
run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always
161-
- name: Test no-std builds on Rust ${{ matrix.toolchain }}
162-
if: "matrix.build-no-std && !matrix.coverage"
163-
shell: bash # Default on Winblows is powershell
164-
run: |
165-
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
166-
cd $DIR
167-
cargo test --verbose --color always --no-default-features --features no-std
168-
# check if there is a conflict between no-std and the default std feature
169-
cargo test --verbose --color always --features no-std
170-
# check that things still pass without grind_signatures
171-
# note that outbound_commitment_test only runs in this mode, because of hardcoded signature values
172-
cargo test --verbose --color always --no-default-features --features std
173-
# check if there is a conflict between no-std and the c_bindings cfg
174-
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std
175-
cd ..
176-
done
177-
# check no-std compatibility across dependencies
178-
cd no-std-check
179-
cargo check --verbose --color always --features lightning-transaction-sync
180-
- name: Build no-std-check on Rust ${{ matrix.toolchain }} for ARM Embedded
181-
if: "matrix.build-no-std && matrix.platform == 'ubuntu-latest'"
182-
run: |
183-
cd no-std-check
18438
rustup target add thumbv7m-none-eabi
18539
sudo apt-get -y install gcc-arm-none-eabi
186-
cargo build --target=thumbv7m-none-eabi
187-
- name: Test on no-std builds Rust ${{ matrix.toolchain }} and full code-linking for coverage generation
188-
if: "matrix.build-no-std && matrix.coverage"
40+
- name: shellcheck the CI script
41+
if: "matrix.platform == 'ubuntu-latest'"
18942
run: |
190-
cd lightning
191-
RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --no-default-features --features no-std
192-
- name: Test futures builds on Rust ${{ matrix.toolchain }}
193-
if: "matrix.build-futures && !matrix.coverage"
43+
sudo apt-get -y install shellcheck
44+
shellcheck ci/ci-tests.sh
45+
- name: Run CI script with coverage generation
46+
if: matrix.coverage
19447
shell: bash # Default on Winblows is powershell
195-
run: |
196-
cd lightning-background-processor
197-
cargo test --verbose --color always --no-default-features --features futures
198-
- name: Test futures builds on Rust ${{ matrix.toolchain }} and full code-linking for coverage generation
199-
if: "matrix.build-futures && matrix.coverage"
48+
run: LDK_COVERAGE_BUILD=true ./ci/ci-tests.sh
49+
- name: Run CI script
50+
if: "!matrix.coverage"
20051
shell: bash # Default on Winblows is powershell
201-
run: |
202-
cd lightning-background-processor
203-
RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --no-default-features --features futures
204-
- name: Test on Rust ${{ matrix.toolchain }}
205-
if: "! matrix.build-net-tokio"
206-
run: |
207-
cargo test --verbose --color always -p lightning
208-
cargo test --verbose --color always -p lightning-invoice
209-
cargo test --verbose --color always -p lightning-rapid-gossip-sync
210-
cargo test --verbose --color always -p lightning-persister
211-
cargo test --verbose --color always -p lightning-background-processor
212-
- name: Test C Bindings Modifications on Rust ${{ matrix.toolchain }}
213-
if: "! matrix.build-net-tokio"
214-
run: |
215-
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always -p lightning
216-
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always -p lightning-invoice
217-
RUSTFLAGS="--cfg=c_bindings" cargo build --verbose --color always -p lightning-persister
218-
RUSTFLAGS="--cfg=c_bindings" cargo build --verbose --color always -p lightning-background-processor
219-
- name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features
220-
if: "matrix.build-net-tokio && !matrix.coverage"
221-
run: |
222-
cd lightning-block-sync
223-
cargo test --verbose --color always --features rest-client
224-
cargo test --verbose --color always --features rpc-client
225-
cargo test --verbose --color always --features rpc-client,rest-client
226-
cargo test --verbose --color always --features rpc-client,rest-client,tokio
227-
- name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
228-
if: matrix.coverage
229-
run: |
230-
cd lightning-block-sync
231-
RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rest-client
232-
RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client
233-
RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client,rest-client
234-
RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client,rest-client,tokio
235-
- name: Test Custom Message Macros on Rust ${{ matrix.toolchain }}
236-
if: "matrix.test-custom-message"
237-
run: |
238-
cd lightning-custom-message
239-
cargo test --verbose --color always
52+
run: ./ci/ci-tests.sh
24053
- name: Install deps for kcov
24154
if: matrix.coverage
24255
run: |

ci/ci-tests.sh

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

lightning/src/onion_message/functional_tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use bitcoin::network::constants::Network;
2020
use bitcoin::secp256k1::{PublicKey, Secp256k1};
2121

2222
use crate::io;
23+
use crate::io_extras::read_to_end;
2324
use crate::sync::Arc;
2425

2526
struct MessengerNode {
@@ -59,8 +60,7 @@ impl CustomOnionMessageHandler for TestCustomMessageHandler {
5960
fn handle_custom_message(&self, _msg: Self::CustomMessage) {}
6061
fn read_custom_message<R: io::Read>(&self, message_type: u64, buffer: &mut R) -> Result<Option<Self::CustomMessage>, DecodeError> where Self: Sized {
6162
if message_type == CUSTOM_MESSAGE_TYPE {
62-
let mut buf = Vec::new();
63-
buffer.read_to_end(&mut buf)?;
63+
let buf = read_to_end(buffer)?;
6464
assert_eq!(buf, CUSTOM_MESSAGE_CONTENTS);
6565
return Ok(Some(TestCustomMessage {}))
6666
}

0 commit comments

Comments
 (0)