Make `htlc_maximum_msat` a required field.
[rust-lightning] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on: [push, pull_request]
4
5 jobs:
6   build:
7     strategy:
8       fail-fast: false
9       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, and coverage generation
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]
19         include:
20           - toolchain: stable
21             build-net-tokio: true
22             build-no-std: true
23           - toolchain: stable
24             platform: macos-latest
25             build-net-tokio: true
26             build-no-std: true
27           - toolchain: beta
28             platform: macos-latest
29             build-net-tokio: true
30             build-no-std: true
31           - toolchain: stable
32             platform: windows-latest
33             build-net-tokio: true
34             build-no-std: true
35           - toolchain: beta
36             platform: windows-latest
37             build-net-tokio: true
38             build-no-std: true
39           - toolchain: beta
40             build-net-tokio: true
41             build-no-std: true
42           - toolchain: 1.41.1
43             build-no-std: false
44             test-log-variants: true
45           - toolchain: 1.45.2
46             build-net-old-tokio: true
47             build-net-tokio: true
48             build-no-std: false
49             coverage: true
50           - toolchain: 1.47.0
51             build-no-std: true
52     runs-on: ${{ matrix.platform }}
53     steps:
54       - name: Checkout source code
55         uses: actions/checkout@v3
56       - name: Install Rust ${{ matrix.toolchain }} toolchain
57         uses: actions-rs/toolchain@v1
58         with:
59           toolchain: ${{ matrix.toolchain }}
60           override: true
61           profile: minimal
62       - name: Pin tokio to 1.14 for Rust 1.45
63         if: "matrix.build-net-old-tokio"
64         run: cargo update -p tokio --precise "1.14.0" --verbose
65       - name: Build on Rust ${{ matrix.toolchain }} with net-tokio
66         if: "matrix.build-net-tokio && !matrix.coverage"
67         run: cargo build --verbose --color always
68       - name: Build on Rust ${{ matrix.toolchain }} with net-tokio and full code-linking for coverage generation
69         if: matrix.coverage
70         run: RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always
71       - name: Build on Rust ${{ matrix.toolchain }}
72         if: "! matrix.build-net-tokio"
73         run: |
74           cargo build --verbose  --color always -p lightning
75           cargo build --verbose  --color always -p lightning-invoice
76           cargo build --verbose  --color always -p lightning-persister
77       - name: Build on Rust ${{ matrix.toolchain }} with all Log-Limiting features
78         if: matrix.test-log-variants
79         run: |
80           cd lightning
81           for FEATURE in $(cat Cargo.toml | grep '^max_level_' | awk '{ print $1 }'); do
82             cargo build --verbose --color always --features $FEATURE
83           done
84       - name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features
85         if: "matrix.build-net-tokio && !matrix.coverage"
86         run: |
87           cd lightning-block-sync
88           cargo build --verbose --color always --features rest-client
89           cargo build --verbose --color always --features rpc-client
90           cargo build --verbose --color always --features rpc-client,rest-client
91           cargo build --verbose --color always --features rpc-client,rest-client,tokio
92       - name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
93         if: matrix.coverage
94         run: |
95           cd lightning-block-sync
96           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rest-client
97           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client
98           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
99           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client,tokio
100       - name: Test backtrace-debug builds on Rust ${{ matrix.toolchain }}
101         if: "matrix.build-no-std"
102         run: |
103           cd lightning && cargo test --verbose --color always --features backtrace
104       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio
105         if: "matrix.build-net-tokio && !matrix.coverage"
106         run: cargo test --verbose --color always
107       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio and full code-linking for coverage generation
108         if: matrix.coverage
109         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always
110       - name: Test on no-std bullds Rust ${{ matrix.toolchain }}
111         if: "matrix.build-no-std && !matrix.coverage"
112         shell: bash # Default on Winblows is powershell
113         run: |
114           cd lightning
115           cargo test --verbose --color always --no-default-features --features no-std
116           # check if there is a conflict between no-std and the default std feature
117           cargo test --verbose --color always --features no-std
118           # check that things still pass without grind_signatures
119           # note that outbound_commitment_test only runs in this mode, because of hardcoded signature values
120           cargo test --verbose --color always --no-default-features --features std
121           # check if there is a conflict between no-std and the c_bindings cfg
122           RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std
123           cd ..
124           cd lightning-invoice
125           cargo test --verbose --color always --no-default-features --features no-std
126           # check if there is a conflict between no-std and the default std feature
127           cargo test --verbose --color always --features no-std
128           # check no-std compatibility across dependencies
129           cd ..
130           cd no-std-check
131           cargo check --verbose --color always
132           cd ..
133       - name: Test on no-std builds Rust ${{ matrix.toolchain }} and full code-linking for coverage generation
134         if: "matrix.build-no-std && matrix.coverage"
135         run: |
136           cd lightning
137           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --no-default-features --features no-std
138           cd ..
139       - name: Test on Rust ${{ matrix.toolchain }}
140         if: "! matrix.build-net-tokio"
141         run: |
142           cargo test --verbose --color always  -p lightning
143           cargo test --verbose --color always  -p lightning-invoice
144           cargo test --verbose --color always  -p lightning-rapid-gossip-sync
145           cargo build --verbose  --color always -p lightning-persister
146           cargo build --verbose  --color always -p lightning-background-processor
147       - name: Test C Bindings Modifications on Rust ${{ matrix.toolchain }}
148         if: "! matrix.build-net-tokio"
149         run: |
150           RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always  -p lightning
151           RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always  -p lightning-invoice
152           RUSTFLAGS="--cfg=c_bindings" cargo build --verbose  --color always -p lightning-persister
153           RUSTFLAGS="--cfg=c_bindings" cargo build --verbose  --color always -p lightning-background-processor
154       - name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features
155         if: "matrix.build-net-tokio && !matrix.coverage"
156         run: |
157           cd lightning-block-sync
158           cargo test --verbose --color always --features rest-client
159           cargo test --verbose --color always --features rpc-client
160           cargo test --verbose --color always --features rpc-client,rest-client
161           cargo test --verbose --color always --features rpc-client,rest-client,tokio
162       - name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
163         if: matrix.coverage
164         run: |
165           cd lightning-block-sync
166           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rest-client
167           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client
168           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client,rest-client
169           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client,rest-client,tokio
170       - name: Install deps for kcov
171         if: matrix.coverage
172         run: |
173           sudo apt-get update
174           sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
175       - name: Install kcov
176         if: matrix.coverage
177         run: |
178           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
179           tar xzf master.tar.gz
180           cd kcov-master && mkdir build && cd build
181           cmake ..
182           make
183           make install DESTDIR=../../kcov-build
184           cd ../.. && rm -rf kcov-master master.tar.gz
185       - name: Generate coverage report
186         if: matrix.coverage
187         run: |
188           for file in target/debug/deps/lightning*; do
189             [ -x "${file}" ] || continue;
190             mkdir -p "target/cov/$(basename $file)";
191             ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
192           done
193       - name: Upload coverage
194         if: matrix.coverage
195         uses: codecov/codecov-action@v3
196         with:
197           # Could you use this to fake the coverage report for your PR? Sure.
198           # Will anyone be impressed by your amazing coverage? No
199           # Maybe if codecov wasn't broken we wouldn't need to do this...
200           token: f421b687-4dc2-4387-ac3d-dc3b2528af57
201           fail_ci_if_error: true
202
203   benchmark:
204     runs-on: ubuntu-latest
205     env:
206       TOOLCHAIN: nightly
207     steps:
208       - name: Checkout source code
209         uses: actions/checkout@v3
210       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
211         uses: actions-rs/toolchain@v1
212         with:
213           toolchain: ${{ env.TOOLCHAIN }}
214           override: true
215           profile: minimal
216       - name: Cache routing graph snapshot
217         id: cache-graph
218         uses: actions/cache@v3
219         with:
220           path: lightning/net_graph-2021-05-31.bin
221           key: ldk-net_graph-v0.0.15-2021-05-31.bin
222       - name: Fetch routing graph snapshot
223         if: steps.cache-graph.outputs.cache-hit != 'true'
224         run: |
225           curl --verbose -L -o lightning/net_graph-2021-05-31.bin https://bitcoin.ninja/ldk-net_graph-v0.0.15-2021-05-31.bin
226           echo "Sha sum: $(sha256sum lightning/net_graph-2021-05-31.bin | awk '{ print $1 }')"
227           if [ "$(sha256sum lightning/net_graph-2021-05-31.bin | awk '{ print $1 }')" != "${EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM}" ]; then
228             echo "Bad hash"
229             exit 1
230           fi
231         env:
232           EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM: 05a5361278f68ee2afd086cc04a1f927a63924be451f3221d380533acfacc303
233       - name: Fetch rapid graph sync reference input
234         run: |
235           curl --verbose -L -o lightning-rapid-gossip-sync/res/full_graph.lngossip https://bitcoin.ninja/ldk-compressed_graph-285cb27df79-2022-07-21.bin
236           echo "Sha sum: $(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')"
237           if [ "$(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')" != "${EXPECTED_RAPID_GOSSIP_SHASUM}" ]; then
238             echo "Bad hash"
239             exit 1
240           fi
241         env:
242           EXPECTED_RAPID_GOSSIP_SHASUM: e0f5d11641c11896d7af3a2246d3d6c3f1720b7d2d17aab321ecce82e6b7deb8
243       - name: Test with Network Graph on Rust ${{ matrix.toolchain }}
244         run: |
245           cd lightning
246           RUSTFLAGS="--cfg=require_route_graph_test" cargo test
247           RUSTFLAGS="--cfg=require_route_graph_test" cargo test --features hashbrown
248           cd ..
249       - name: Run benchmarks on Rust ${{ matrix.toolchain }}
250         run: |
251           cargo bench --features _bench_unstable
252
253   check_commits:
254     runs-on: ubuntu-latest
255     env:
256       TOOLCHAIN: 1.57.0
257     steps:
258       - name: Checkout source code
259         uses: actions/checkout@v3
260         with:
261           fetch-depth: 0
262       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
263         uses: actions-rs/toolchain@v1
264         with:
265           toolchain: ${{ env.TOOLCHAIN }}
266           override: true
267           profile: minimal
268       - name: Fetch full tree and rebase on upstream
269         run: |
270           git remote add upstream https://github.com/lightningdevkit/rust-lightning
271           git fetch upstream
272           export GIT_COMMITTER_EMAIL="rl-ci@example.com"
273           export GIT_COMMITTER_NAME="RL CI"
274           git rebase upstream/main
275       - name: For each commit, run cargo check (including in fuzz)
276         run: ci/check-each-commit.sh upstream/main
277
278   check_release:
279     runs-on: ubuntu-latest
280     env:
281       TOOLCHAIN: stable
282     steps:
283       - name: Checkout source code
284         uses: actions/checkout@v3
285         with:
286           fetch-depth: 0
287       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
288         uses: actions-rs/toolchain@v1
289         with:
290           toolchain: ${{ env.TOOLCHAIN }}
291           override: true
292           profile: minimal
293       - name: Run cargo check for release build.
294         run: |
295           cargo check --release
296           cargo check --no-default-features --features=no-std --release
297           cargo doc --release
298
299   fuzz:
300     runs-on: ubuntu-latest
301     env:
302       TOOLCHAIN: stable
303     steps:
304       - name: Checkout source code
305         uses: actions/checkout@v3
306       - name: Install Rust 1.58 toolchain
307         uses: actions-rs/toolchain@v1
308         with:
309           toolchain: 1.58
310           override: true
311           profile: minimal
312       - name: Install dependencies for honggfuzz
313         run: |
314           sudo apt-get update
315           sudo apt-get -y install build-essential binutils-dev libunwind-dev
316       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
317         run: cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose --color always
318       - name: Run fuzzers
319         run: cd fuzz && ./ci-fuzz.sh && cd ..
320       - name: Run lightning-invoice fuzzers
321         run: cd lightning-invoice/fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose && ./ci-fuzz.sh
322
323   linting:
324     runs-on: ubuntu-latest
325     env:
326       TOOLCHAIN: 1.47.0
327     steps:
328       - name: Checkout source code
329         uses: actions/checkout@v3
330       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
331         uses: actions-rs/toolchain@v1
332         with:
333           toolchain: ${{ env.TOOLCHAIN }}
334           override: true
335           profile: minimal
336       - name: Install clippy
337         run: |
338           rustup component add clippy
339       - name: Run default clippy linting
340         run: |
341           cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err