Disable fast-fail to let CI actually run even though beta is broken
[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.36.0 is MSRV for Rust-Lightning, lightning-invoice, and lightning-persister
14                      1.36.0,
15                      # 1.41.0 is Debian stable
16                      1.41.0,
17                      # 1.45.2 is MSRV for lightning-net-tokio, lightning-block-sync, and coverage generation
18                      1.45.2,
19                      # 1.49.0 is MSRV for no_std builds using hashbrown
20                      1.49.0]
21         include:
22           - toolchain: stable
23             build-net-tokio: true
24             build-no-std: true
25           - toolchain: stable
26             platform: macos-latest
27             build-net-tokio: true
28             build-no-std: true
29           - toolchain: stable
30             platform: windows-latest
31             build-net-tokio: true
32             build-no-std: true
33           - toolchain: beta
34             build-net-tokio: true
35             build-no-std: true
36           - toolchain: 1.36.0
37             build-no-std: false
38           - toolchain: 1.41.0
39             build-no-std: false
40           - toolchain: 1.45.2
41             build-net-tokio: true
42             build-no-std: false
43             coverage: true
44           - toolchain: 1.49.0
45             build-no-std: true
46     runs-on: ${{ matrix.platform }}
47     steps:
48       - name: Checkout source code
49         uses: actions/checkout@v2
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: Build on Rust ${{ matrix.toolchain }} with net-tokio
57         if: "matrix.build-net-tokio && !matrix.coverage"
58         run: cargo build --verbose --color always
59       - name: Build on Rust ${{ matrix.toolchain }} with net-tokio and full code-linking for coverage generation
60         if: matrix.coverage
61         run: RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always
62       - name: Build on Rust ${{ matrix.toolchain }}
63         if: "! matrix.build-net-tokio"
64         run: |
65           cargo build --verbose  --color always -p lightning
66           cargo build --verbose  --color always -p lightning-invoice
67           cargo build --verbose  --color always -p lightning-persister
68       - name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features
69         if: "matrix.build-net-tokio && !matrix.coverage"
70         run: |
71           cd lightning-block-sync
72           cargo build --verbose --color always --features rest-client
73           cargo build --verbose --color always --features rpc-client
74           cargo build --verbose --color always --features rpc-client,rest-client
75           cargo build --verbose --color always --features rpc-client,rest-client,tokio
76       - name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
77         if: matrix.coverage
78         run: |
79           cd lightning-block-sync
80           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rest-client
81           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client
82           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
83           RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client,tokio
84       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio
85         if: "matrix.build-net-tokio && !matrix.coverage"
86         run: cargo test --verbose --color always
87       - name: Test on Rust ${{ matrix.toolchain }} with net-tokio and full code-linking for coverage generation
88         if: matrix.coverage
89         run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always
90       - name: Test on no_std bullds Rust ${{ matrix.toolchain }}
91         if: "matrix.build-no-std && !matrix.coverage"
92         run: |
93           cd lightning
94           cargo test --verbose --color always --no-default-features --features no_std
95           # check if there is a conflict between no_std and the default std feature
96           cargo test --verbose --color always --features no_std
97           cd ..
98       - name: Test on no_std bullds Rust ${{ matrix.toolchain }} and full code-linking for coverage generation
99         if: "matrix.build-no-std && matrix.coverage"
100         run: |
101           cd lightning
102           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --no-default-features --features no_std
103           cd ..
104       - name: Test on Rust ${{ matrix.toolchain }}
105         if: "! matrix.build-net-tokio"
106         run: |
107           cargo test --verbose --color always  -p lightning
108           cargo test --verbose --color always  -p lightning-invoice
109           cargo build --verbose  --color always -p lightning-persister
110       - name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features
111         if: "matrix.build-net-tokio && !matrix.coverage"
112         run: |
113           cd lightning-block-sync
114           cargo test --verbose --color always --features rest-client
115           cargo test --verbose --color always --features rpc-client
116           cargo test --verbose --color always --features rpc-client,rest-client
117           cargo test --verbose --color always --features rpc-client,rest-client,tokio
118       - name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
119         if: matrix.coverage
120         run: |
121           cd lightning-block-sync
122           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rest-client
123           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client
124           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client,rest-client
125           RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always --features rpc-client,rest-client,tokio
126       - name: Install deps for kcov
127         if: matrix.coverage
128         run: |
129           sudo apt-get update
130           sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
131       - name: Install kcov
132         if: matrix.coverage
133         run: |
134           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
135           tar xzf master.tar.gz
136           cd kcov-master && mkdir build && cd build
137           cmake ..
138           make
139           make install DESTDIR=../../kcov-build
140           cd ../.. && rm -rf kcov-master master.tar.gz
141       - name: Generate coverage report
142         if: matrix.coverage
143         run: |
144           for file in target/debug/deps/lightning*; do
145             [ -x "${file}" ] || continue;
146             mkdir -p "target/cov/$(basename $file)";
147             ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file";
148           done
149       - name: Upload coverage
150         if: matrix.coverage
151         uses: codecov/codecov-action@v1
152         with:
153           # Could you use this to fake the coverage report for your PR? Sure.
154           # Will anyone be impressed by your amazing coverage? No
155           # Maybe if codecov wasn't broken we wouldn't need to do this...
156           token: f421b687-4dc2-4387-ac3d-dc3b2528af57
157           fail_ci_if_error: true
158
159   benchmark:
160     runs-on: ubuntu-latest
161     env:
162       TOOLCHAIN: nightly
163     steps:
164       - name: Checkout source code
165         uses: actions/checkout@v2
166       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
167         uses: actions-rs/toolchain@v1
168         with:
169           toolchain: ${{ env.TOOLCHAIN }}
170           override: true
171           profile: minimal
172       - name: Cache routing graph snapshot
173         id: cache-graph
174         uses: actions/cache@v2
175         with:
176           path: lightning/net_graph-2021-05-31.bin
177           key: ldk-net_graph-v0.0.15-2021-05-31.bin
178       - name: Fetch routing graph snapshot
179         if: steps.cache-graph.outputs.cache-hit != 'true'
180         run: |
181           wget -O lightning/net_graph-2021-05-31.bin https://bitcoin.ninja/ldk-net_graph-v0.0.15-2021-05-31.bin
182           if [ "$(sha256sum lightning/net_graph-2021-05-31.bin | awk '{ print $1 }')" != "05a5361278f68ee2afd086cc04a1f927a63924be451f3221d380533acfacc303" ]; then
183             echo "Bad hash"
184             exit 1
185           fi
186       - name: Test with Network Graph on Rust ${{ matrix.toolchain }}
187         run: |
188           cd lightning
189           RUSTFLAGS="--cfg=require_route_graph_test" cargo test
190           RUSTFLAGS="--cfg=require_route_graph_test" cargo test --features hashbrown
191           cd ..
192       - name: Run benchmarks on Rust ${{ matrix.toolchain }}
193         run: |
194           cargo bench --features unstable
195
196   check_commits:
197     runs-on: ubuntu-latest
198     env:
199       # rustc 1.53 regressed and panics when building our (perfectly fine) docs.
200       # See https://github.com/rust-lang/rust/issues/84738
201       TOOLCHAIN: 1.52.1
202     steps:
203       - name: Checkout source code
204         uses: actions/checkout@v2
205         with:
206           fetch-depth: 0
207       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
208         uses: actions-rs/toolchain@v1
209         with:
210           toolchain: ${{ env.TOOLCHAIN }}
211           override: true
212           profile: minimal
213       - name: Fetch full tree and rebase on upstream
214         run: |
215           git remote add upstream https://github.com/rust-bitcoin/rust-lightning
216           git fetch upstream
217           export GIT_COMMITTER_EMAIL="rl-ci@example.com"
218           export GIT_COMMITTER_NAME="RL CI"
219           git rebase upstream/main
220       - name: For each commit, run cargo check (including in fuzz)
221         run: ci/check-each-commit.sh upstream/main
222
223   fuzz:
224     runs-on: ubuntu-latest
225     env:
226       TOOLCHAIN: stable
227     steps:
228       - name: Checkout source code
229         uses: actions/checkout@v2
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: Install dependencies for honggfuzz
237         run: |
238           sudo apt-get update
239           sudo apt-get -y install build-essential binutils-dev libunwind-dev
240       - name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
241         run: cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose --color always
242       - name: Run fuzzers
243         run: cd fuzz && ./ci-fuzz.sh && cd ..
244       - name: Run lightning-invoice fuzzers
245         run: cd lightning-invoice/fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose && ./ci-fuzz.sh
246
247   linting:
248     runs-on: ubuntu-latest
249     env:
250       TOOLCHAIN: 1.45.2
251     steps:
252       - name: Checkout source code
253         uses: actions/checkout@v2
254       - name: Install Rust ${{ env.TOOLCHAIN }} toolchain
255         uses: actions-rs/toolchain@v1
256         with:
257           toolchain: ${{ env.TOOLCHAIN }}
258           override: true
259           profile: minimal
260       - name: Install clippy
261         run: |
262           rustup component add clippy
263       - name: Run default clippy linting
264         run: |
265           cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else