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