-
Notifications
You must be signed in to change notification settings - Fork 50
200 lines (185 loc) · 9.97 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
# 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:
merge_group:
push:
branches:
- main # Running the CI on the main branch is important in order to fill the caches that pull requests will pick up.
permissions: read-all
jobs:
test-64bits:
runs-on: ubuntu-latest
container:
image: rust:1.81
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: RUSTFLAGS=-Dwarnings cargo test --locked --workspace --all-features
test-32bits:
runs-on: ubuntu-latest
container:
image: rust:1.81
steps:
- run: apt-get update && apt install -y libc6-dev-i386
- uses: actions/checkout@v4
- 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.81
steps:
- uses: actions/checkout@v4
- run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- uses: actions/[email protected]
with:
# Set to the oldest version still maintained, in order to ensure compatibility. See <https://nodejs.dev/en/about/releases/>
node-version: '18'
- uses: denoland/setup-deno@v2
with:
deno-version: v1.x
- run: cd wasm-node/javascript && RUSTFLAGS=-Dwarnings npm install-ci-test
check-features:
runs-on: ubuntu-latest
container:
image: rust:1.81
steps:
- uses: actions/checkout@v4
- 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 --locked --no-default-features --features database-sqlite --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot --locked --no-default-features --features std --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features --features std --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite --features std --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot --locked --no-default-features --features database-sqlite --features std --features wasmtime
- 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
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot-light --locked --no-default-features --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot-light --locked --no-default-features --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target x86_64-unknown-linux-gnu --package smoldot-light --locked --no-default-features --features std --features wasmtime
- run: RUSTFLAGS=-Dwarnings cargo check --target i686-unknown-linux-gnu --package smoldot-light --locked --no-default-features --features std --features wasmtime
check-no-std:
runs-on: ubuntu-latest
container:
image: rust:1.81
steps:
- uses: actions/checkout@v4
- run: rustup target add thumbv7m-none-eabi
- uses: Swatinem/rust-cache@v2
# We use `thumbv7m-none-eabi` as this target seems to generally work fine and doesn't support `std`. Many targets unfortunately have Rust/LLVM bugs preventing compilation.
- run: RUSTFLAGS=-Dwarnings cargo build --package smoldot --locked --no-default-features --target=thumbv7m-none-eabi
- run: RUSTFLAGS=-Dwarnings cargo build --package smoldot-light --locked --no-default-features --target=thumbv7m-none-eabi
check-rustdoc-links:
runs-on: ubuntu-latest
container:
image: rust:1.81
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: RUSTDOCFLAGS=-Dwarnings cargo doc --verbose --workspace --all-features --no-deps --document-private-items
fmt:
runs-on: ubuntu-latest
container:
image: rust:1.81
steps:
# Checks `rustfmt` formatting
- uses: actions/checkout@v4
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --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
container:
image: rust:1.81
steps:
- uses: actions/checkout@v4
# 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.
- run: rustup default nightly-2023-07-15
- 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@v4
- 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@v4
- run: sudo apt-get update && sudo apt install -y libclang-dev # Required by cargo-spellcheck
- uses: baptiste0928/cargo-install@v3 # 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
container:
image: rust:1.81
steps:
- uses: actions/checkout@v4
- run: apt-get update && apt install -y jq
# Compares whether the version in `package.json` matches the version in `Cargo.toml`.
- id: js-version
run: echo "version=`jq .version ./wasm-node/javascript/package.json`" >> $GITHUB_OUTPUT
- id: rust-version
run: echo "version=`cargo read-manifest --manifest-path=./wasm-node/rust/Cargo.toml | jq .version`" >> $GITHUB_OUTPUT
- 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, check-features, check-no-std, check-rustdoc-links, fmt, clippy, cargo-deny, cargo-spellcheck, wasm-node-versions-match]
runs-on: ubuntu-latest
steps:
- run: echo Success