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