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