]> git.bitcoin.ninja Git - rust-lightning/blob - .github/workflows/build.yml
Bump MSRV to rustc 1.63.0 and edition to 2021
[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: shellcheck the CI script
36         if: "matrix.platform == 'ubuntu-latest'"
37         run: |
38           sudo apt-get -y install shellcheck
39           shellcheck ci/ci-tests.sh
40       - name: Run CI script
41         shell: bash # Default on Winblows is powershell
42         run: CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
43
44   coverage:
45     strategy:
46       fail-fast: false
47     runs-on: ubuntu-latest
48     steps:
49       - name: Checkout source code
50         uses: actions/checkout@v3
51         with:
52           fetch-depth: 0
53       - name: Install Rust stable toolchain
54         run: |
55           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
56       - name: Run tests with coverage generation
57         run: |
58           cargo install cargo-llvm-cov
59           export RUSTFLAGS="-Clink-dead-code -Coverflow-checks=off"
60           cargo llvm-cov --features rest-client,rpc-client,tokio,futures,serde --codecov --hide-instantiations --output-path=target/codecov.json
61           # Could you use this to fake the coverage report for your PR? Sure.
62           # Will anyone be impressed by your amazing coverage? No
63           # Maybe if codecov wasn't broken we wouldn't need to do this...
64           bash <(curl -s https://codecov.io/bash) -f target/codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57"
65
66   benchmark:
67     runs-on: ubuntu-latest
68     env:
69       TOOLCHAIN: stable
70     steps:
71       - name: Checkout source code
72         uses: actions/checkout@v3
73       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
74         run: |
75           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
76           rustup override set ${{ env.TOOLCHAIN }}
77       - name: Cache routing graph snapshot
78         id: cache-graph
79         uses: actions/cache@v3
80         with:
81           path: lightning/net_graph-2023-01-18.bin
82           key: ldk-net_graph-v0.0.113-2023-01-18.bin
83       - name: Fetch routing graph snapshot
84         if: steps.cache-graph.outputs.cache-hit != 'true'
85         run: |
86           curl --verbose -L -o lightning/net_graph-2023-01-18.bin https://bitcoin.ninja/ldk-net_graph-v0.0.113-2023-01-18.bin
87           echo "Sha sum: $(sha256sum lightning/net_graph-2023-01-18.bin | awk '{ print $1 }')"
88           if [ "$(sha256sum lightning/net_graph-2023-01-18.bin | awk '{ print $1 }')" != "${EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM}" ]; then
89             echo "Bad hash"
90             exit 1
91           fi
92         env:
93           EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM: da6066f2bddcddbe7d8a6debbd53545697137b310bbb8c4911bc8c81fc5ff48c
94       - name: Fetch rapid graph sync reference input
95         run: |
96           curl --verbose -L -o lightning-rapid-gossip-sync/res/full_graph.lngossip https://bitcoin.ninja/ldk-compressed_graph-285cb27df79-2022-07-21.bin
97           echo "Sha sum: $(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')"
98           if [ "$(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')" != "${EXPECTED_RAPID_GOSSIP_SHASUM}" ]; then
99             echo "Bad hash"
100             exit 1
101           fi
102         env:
103           EXPECTED_RAPID_GOSSIP_SHASUM: e0f5d11641c11896d7af3a2246d3d6c3f1720b7d2d17aab321ecce82e6b7deb8
104       - name: Test with Network Graph on Rust ${{ matrix.toolchain }}
105         run: |
106           cd lightning
107           RUSTFLAGS="--cfg=require_route_graph_test" cargo test
108           RUSTFLAGS="--cfg=require_route_graph_test" cargo test --features hashbrown
109           cd ..
110       - name: Run benchmarks on Rust ${{ matrix.toolchain }}
111         run: |
112           cd bench
113           RUSTFLAGS="--cfg=ldk_bench --cfg=require_route_graph_test" cargo bench
114       - name: Run benchmarks with hashbrown on Rust ${{ matrix.toolchain }}
115         run: |
116           cd bench
117           RUSTFLAGS="--cfg=ldk_bench --cfg=require_route_graph_test" cargo bench --features hashbrown
118
119   check_commits:
120     runs-on: ubuntu-latest
121     env:
122       TOOLCHAIN: stable
123     steps:
124       - name: Checkout source code
125         uses: actions/checkout@v3
126         with:
127           fetch-depth: 0
128       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
129         run: |
130           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
131           rustup override set ${{ env.TOOLCHAIN }}
132       - name: Fetch full tree and rebase on upstream
133         run: |
134           git remote add upstream https://github.com/lightningdevkit/rust-lightning
135           git fetch upstream
136           export GIT_COMMITTER_EMAIL="rl-ci@example.com"
137           export GIT_COMMITTER_NAME="RL CI"
138           git rebase upstream/main
139       - name: For each commit, run cargo check (including in fuzz)
140         run: ci/check-each-commit.sh upstream/main
141
142   check_release:
143     runs-on: ubuntu-latest
144     env:
145       TOOLCHAIN: stable
146     steps:
147       - name: Checkout source code
148         uses: actions/checkout@v3
149         with:
150           fetch-depth: 0
151       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
152         run: |
153           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
154           rustup override set ${{ env.TOOLCHAIN }}
155       - name: Run cargo check for release build.
156         run: |
157           cargo check --release
158           cargo check --no-default-features --features=no-std --release
159           cargo check --no-default-features --features=futures,std --release
160           cargo doc --release
161       - name: Run cargo check for Taproot build.
162         run: |
163           cargo check --release
164           cargo check --no-default-features --features=no-std --release
165           cargo check --no-default-features --features=futures,std --release
166           cargo doc --release
167         env:
168           RUSTFLAGS: '--cfg=taproot'
169           RUSTDOCFLAGS: '--cfg=taproot'
170
171   fuzz:
172     runs-on: ubuntu-latest
173     env:
174       TOOLCHAIN: 1.58
175     steps:
176       - name: Checkout source code
177         uses: actions/checkout@v3
178       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
179         run: |
180           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
181           rustup override set ${{ env.TOOLCHAIN }}
182       - name: Install dependencies for honggfuzz
183         run: |
184           sudo apt-get update
185           sudo apt-get -y install build-essential binutils-dev libunwind-dev
186       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
187         run: cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose --color always
188       - name: Run fuzzers
189         run: cd fuzz && ./ci-fuzz.sh && cd ..
190       - name: Run lightning-invoice fuzzers
191         run: cd lightning-invoice/fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose && ./ci-fuzz.sh
192
193   linting:
194     runs-on: ubuntu-latest
195     env:
196       TOOLCHAIN: stable
197     steps:
198       - name: Checkout source code
199         uses: actions/checkout@v3
200       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
201         run: |
202           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
203           rustup override set ${{ env.TOOLCHAIN }}
204       - name: Install clippy
205         run: |
206           rustup component add clippy
207       - name: Run default clippy linting
208         run: |
209           cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err