]> git.bitcoin.ninja Git - rust-lightning/blob - .github/workflows/build.yml
Merge pull request #3054 from TheBlueMatt/2024-04-fuzz-bolt11
[rust-lightning] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on:
4   push:
5     branches-ignore:
6       - master
7   pull_request:
8     branches-ignore:
9       - master
10
11 concurrency:
12   group: ${{ github.workflow }}-${{ github.ref }}
13   cancel-in-progress: true
14
15 jobs:
16   build:
17     strategy:
18       fail-fast: false
19       matrix:
20         platform: [ ubuntu-latest, windows-latest, macos-latest ]
21         toolchain: [ stable, beta, 1.63.0 ] # 1.63.0 is the MSRV for all crates.
22     runs-on: ${{ matrix.platform }}
23     steps:
24       - name: Checkout source code
25         uses: actions/checkout@v3
26       - name: Install Rust ${{ matrix.toolchain }} toolchain
27         run: |
28           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
29           rustup override set ${{ matrix.toolchain }}
30       - name: Install no-std-check dependencies for ARM Embedded
31         if: "matrix.platform == 'ubuntu-latest'"
32         run: |
33           rustup target add thumbv7m-none-eabi
34           sudo apt-get -y install gcc-arm-none-eabi
35       - name: Check for unknown cfg tags
36         run: ci/check-cfg-flags.py
37       - name: shellcheck the CI script
38         if: "matrix.platform == 'ubuntu-latest'"
39         run: |
40           sudo apt-get -y install shellcheck
41           shellcheck ci/ci-tests.sh
42       - name: Set RUSTFLAGS to deny warnings
43         if: "matrix.toolchain == '1.63.0'"
44         run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
45       - name: Run CI script
46         shell: bash # Default on Winblows is powershell
47         run: CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
48
49   coverage:
50     strategy:
51       fail-fast: false
52     runs-on: ubuntu-latest
53     steps:
54       - name: Checkout source code
55         uses: actions/checkout@v3
56         with:
57           fetch-depth: 0
58       - name: Install Rust stable toolchain
59         run: |
60           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
61       - name: Run tests with coverage generation
62         run: |
63           cargo install cargo-llvm-cov
64           export RUSTFLAGS="-Clink-dead-code -Coverflow-checks=off"
65           cargo llvm-cov --features rest-client,rpc-client,tokio,futures,serde --codecov --hide-instantiations --output-path=target/codecov.json
66           # Could you use this to fake the coverage report for your PR? Sure.
67           # Will anyone be impressed by your amazing coverage? No
68           # Maybe if codecov wasn't broken we wouldn't need to do this...
69           bash <(curl -s https://codecov.io/bash) -f target/codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57"
70
71   benchmark:
72     runs-on: ubuntu-latest
73     env:
74       TOOLCHAIN: stable
75     steps:
76       - name: Checkout source code
77         uses: actions/checkout@v3
78       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
79         run: |
80           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
81           rustup override set ${{ env.TOOLCHAIN }}
82       - name: Cache routing graph snapshot
83         id: cache-graph
84         uses: actions/cache@v3
85         with:
86           path: lightning/net_graph-2023-01-18.bin
87           key: ldk-net_graph-v0.0.113-2023-01-18.bin
88       - name: Fetch routing graph snapshot
89         if: steps.cache-graph.outputs.cache-hit != 'true'
90         run: |
91           curl --verbose -L -o lightning/net_graph-2023-01-18.bin https://bitcoin.ninja/ldk-net_graph-v0.0.113-2023-01-18.bin
92           echo "Sha sum: $(sha256sum lightning/net_graph-2023-01-18.bin | awk '{ print $1 }')"
93           if [ "$(sha256sum lightning/net_graph-2023-01-18.bin | awk '{ print $1 }')" != "${EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM}" ]; then
94             echo "Bad hash"
95             exit 1
96           fi
97         env:
98           EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM: da6066f2bddcddbe7d8a6debbd53545697137b310bbb8c4911bc8c81fc5ff48c
99       - name: Fetch rapid graph sync reference input
100         run: |
101           curl --verbose -L -o lightning-rapid-gossip-sync/res/full_graph.lngossip https://bitcoin.ninja/ldk-compressed_graph-285cb27df79-2022-07-21.bin
102           echo "Sha sum: $(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')"
103           if [ "$(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')" != "${EXPECTED_RAPID_GOSSIP_SHASUM}" ]; then
104             echo "Bad hash"
105             exit 1
106           fi
107         env:
108           EXPECTED_RAPID_GOSSIP_SHASUM: e0f5d11641c11896d7af3a2246d3d6c3f1720b7d2d17aab321ecce82e6b7deb8
109       - name: Test with Network Graph on Rust ${{ matrix.toolchain }}
110         run: |
111           cd lightning
112           RUSTFLAGS="--cfg=require_route_graph_test" cargo test
113           RUSTFLAGS="--cfg=require_route_graph_test" cargo test --features hashbrown
114           cd ..
115       - name: Run benchmarks on Rust ${{ matrix.toolchain }}
116         run: |
117           cd bench
118           RUSTFLAGS="--cfg=ldk_bench --cfg=require_route_graph_test" cargo bench
119       - name: Run benchmarks with hashbrown on Rust ${{ matrix.toolchain }}
120         run: |
121           cd bench
122           RUSTFLAGS="--cfg=ldk_bench --cfg=require_route_graph_test" cargo bench --features hashbrown
123
124   check_commits:
125     runs-on: ubuntu-latest
126     env:
127       TOOLCHAIN: stable
128     steps:
129       - name: Checkout source code
130         uses: actions/checkout@v3
131         with:
132           fetch-depth: 0
133       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
134         run: |
135           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
136           rustup override set ${{ env.TOOLCHAIN }}
137       - name: Fetch full tree and rebase on upstream
138         run: |
139           git remote add upstream https://github.com/lightningdevkit/rust-lightning
140           git fetch upstream
141           export GIT_COMMITTER_EMAIL="rl-ci@example.com"
142           export GIT_COMMITTER_NAME="RL CI"
143           git rebase upstream/main
144       - name: For each commit, run cargo check (including in fuzz)
145         run: ci/check-each-commit.sh upstream/main
146
147   check_release:
148     runs-on: ubuntu-latest
149     env:
150       TOOLCHAIN: stable
151     steps:
152       - name: Checkout source code
153         uses: actions/checkout@v3
154         with:
155           fetch-depth: 0
156       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
157         run: |
158           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
159           rustup override set ${{ env.TOOLCHAIN }}
160       - name: Run cargo check for release build.
161         run: |
162           cargo check --release
163           cargo check --no-default-features --features=no-std --release
164           cargo check --no-default-features --features=futures,std --release
165           cargo doc --release
166       - name: Run cargo check for Taproot build.
167         run: |
168           cargo check --release
169           cargo check --no-default-features --features=no-std --release
170           cargo check --no-default-features --features=futures,std --release
171           cargo doc --release
172         env:
173           RUSTFLAGS: '--cfg=taproot'
174           RUSTDOCFLAGS: '--cfg=taproot'
175
176   fuzz:
177     runs-on: ubuntu-latest
178     env:
179       TOOLCHAIN: 1.63
180     steps:
181       - name: Checkout source code
182         uses: actions/checkout@v3
183       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
184         run: |
185           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
186           rustup override set ${{ env.TOOLCHAIN }}
187       - name: Install dependencies for honggfuzz
188         run: |
189           sudo apt-get update
190           sudo apt-get -y install build-essential binutils-dev libunwind-dev
191       - name: Pin the regex dependency
192         run: |
193           cd fuzz && cargo update -p regex --precise "1.9.6" --verbose && cd ..
194       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
195         run: cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose --color always
196       - name: Run fuzzers
197         run: cd fuzz && ./ci-fuzz.sh && cd ..
198
199   linting:
200     runs-on: ubuntu-latest
201     env:
202       TOOLCHAIN: stable
203     steps:
204       - name: Checkout source code
205         uses: actions/checkout@v3
206       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
207         run: |
208           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
209           rustup override set ${{ env.TOOLCHAIN }}
210       - name: Install clippy
211         run: |
212           rustup component add clippy
213       - name: Run default clippy linting
214         run: |
215           cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
216
217   rustfmt:
218     runs-on: ubuntu-latest
219     env:
220       TOOLCHAIN: 1.63.0
221     steps:
222       - name: Checkout source code
223         uses: actions/checkout@v3
224       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
225         run: |
226           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
227           rustup override set ${{ env.TOOLCHAIN }}
228       - name: Install rustfmt
229         run: |
230           rustup component add rustfmt
231       - name: Run rustfmt checks
232         run: ci/rustfmt.sh