-
Notifications
You must be signed in to change notification settings - Fork 74
236 lines (221 loc) · 10.2 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# Smoldot
# Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
# SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
name: continuous-integration
on:
pull_request:
push:
branches:
- main # Running the CI on the main branch is important in order to fill the caches that pull requests will pick up.
jobs:
test-64bits:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: RUSTFLAGS=-Dwarnings cargo test --locked --workspace --all-features
test-32bits:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- run: apt-get update && apt install -y libc6-dev-i386
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: rustup target add i686-unknown-linux-gnu
- run: RUSTFLAGS=-Dwarnings cargo test --target i686-unknown-linux-gnu --locked --workspace --all-features
wasm-node-check:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- run: apt-get update && apt install -y binaryen # For `wasm-opt`
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-node@v3.5.1
with:
node-version: '16' # An old version is used to ensure compatibility
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- run: cd bin/wasm-node/javascript && RUSTFLAGS=-Dwarnings npm install-ci-test
wasm-node-size-diff:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- run: apt-get update && apt install -y binaryen # For `wasm-opt`
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Necessary to fetch pull request base below
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-node@v3.5.1
with:
node-version: '14' # Because this step doesn't actually check anything, we use a more liberal version
- uses: baptiste0928/cargo-install@v1 # This action ensures that the twiggy compilation is cached.
with:
crate: twiggy
version: 0.6
- run: git checkout ${{ github.event.pull_request.base.sha }}
- run: cd bin/wasm-node/javascript && npm ci && npm run-script build
- run: cp ./target/wasm32-wasi/min-size-release/smoldot_light_wasm.wasm ./.ci-parent-build.wasm # TODO: maybe get the path from the `npm build` output or something?
- run: git checkout ${{ github.event.pull_request.head.sha }}
- run: cd bin/wasm-node/javascript && npm ci && npm run-script build
- run: twiggy diff ./.ci-parent-build.wasm ./target/wasm32-wasi/min-size-release/smoldot_light_wasm.wasm > ./twiggy-diff # TODO: maybe get the path from the `npm build` output or something?
# Now that we've generated the diff in a `./twiggy-diff` file, the next step is to upload
# the PR number and diff content as an artifact that will then be picked up by a
# `workflow_run` action that does the actual commenting.
- run: |
mkdir -p ./pr
echo ${{ github.event.pull_request.number }} > ./pr/number
cp ./twiggy-diff ./pr
- uses: actions/upload-artifact@v3
with:
name: pr
path: pr/
check-features:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: apt-get update && apt install -y libc6-dev-i386
- run: rustup target add i686-unknown-linux-gnu
# We test for both x86_64 and i686 because there is some `cfg(target_arch = "x86_64")`
# conditional compilation within the source code.
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot --locked --no-default-features
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot --locked --no-default-features --features std
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features --features std
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite --features std
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite --features std
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot-light --locked --no-default-features
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot-light --locked --no-default-features
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot-light --locked --no-default-features --features std
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot-light --locked --no-default-features --features std
fuzzing-binaries-compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
# Since build artifacts are specific to a nightly version, we pin the specific nightly
# version to use in order to not invalidate the build cache every day. The exact version
# is completely arbitrary.
toolchain: nightly-2022-10-16
override: true
- uses: baptiste0928/cargo-install@v1 # This action ensures that the compilation is cached.
with:
crate: cargo-fuzz
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
./bin/fuzz
- run: cargo fuzz build --fuzz-dir ./bin/fuzz
check-rustdoc-links:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: RUSTDOCFLAGS=-Dwarnings cargo doc --verbose --workspace --all-features --no-deps --document-private-items
fmt:
runs-on: ubuntu-latest
steps:
# Checks `rustfmt` formatting
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
# The fuzzing targets are in a different package and thus need to be checked separately.
with:
command: fmt
args: --manifest-path ./bin/fuzz/Cargo.toml --all -- --check
# TODO: as explained in the official repo (https://github.com/actions-rs/clippy), this action uses unstable GH actions features, but has the huge advantage of not requiring `GITHUB_TOKEN` and working on PRs from forked repositories ; should eventually replace `actions-rs/clippy@master` with a specific version
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
override: true
- uses: Swatinem/rust-cache@v2 # Note that this is done after switching the compiler version to nightly
- uses: actions-rs/clippy@master
with:
args: --all-features --all-targets
cargo-deny:
runs-on: ubuntu-latest
strategy:
matrix:
# The `advisories` check isn't done, because pragmatically speaking it fails CI too often.
# See `audit.yml` instead.
checks:
- bans licenses sources
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check --config .github/cargo-deny.toml ${{ matrix.checks }}
arguments: --workspace --all-features
cargo-spellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt-get update && sudo apt install -y libclang-dev # Required by cargo-spellcheck
- uses: baptiste0928/cargo-install@v1 # This action ensures that the compilation is cached.
with:
crate: cargo-spellcheck
version: 0.11.2
- run: cargo spellcheck -m 99
wasm-node-versions-match:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# Compares whether the version in `package.json` matches the version in `Cargo.toml`.
- id: js-version
run: echo "::set-output name=version::`jq .version ./bin/wasm-node/javascript/package.json`"
- id: rust-version
run: echo "::set-output name=version::`cargo read-manifest --manifest-path=./bin/wasm-node/rust/Cargo.toml | jq .version`"
- run: exit 1
if: ${{ steps.js-version.outputs.version == '' }} # Defensive test against mistakes in the CI script
- run: exit 1
if: ${{ steps.js-version.outputs.version != steps.rust-version.outputs.version }}
all-ci:
# This dummy job depends on all the mandatory checks. It succeeds if and only if CI is
# considered successful.
needs: [test-64bits, test-32bits, wasm-node-check, wasm-node-size-diff, check-features, fuzzing-binaries-compile, check-rustdoc-links, fmt, clippy, cargo-deny, cargo-spellcheck, wasm-node-versions-match]
runs-on: ubuntu-latest
steps:
- run: echo Success