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