-
-
Notifications
You must be signed in to change notification settings - Fork 21
304 lines (283 loc) Β· 9.42 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: CI
on:
pull_request:
workflow_dispatch:
push:
branches: ["main"]
env:
# disable incremental compilation.
#
# incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. however,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# see https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). this should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
# loom config
LOOM_LOG: "mycelium=trace,cordyceps=trace,maitake=trace,debug"
jobs:
changed_paths:
continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
do_not_skip: '["workflow_dispatch", "push"]'
paths_ignore: '["**/README.md"]'
paths_filter: |
cordyceps:
paths:
- 'cordyceps/**/*.rs'
- 'cordyceps/Cargo.toml'
- '.github/workflows/ci.yml'
- 'justfile'
util:
paths:
- 'util/**/*.rs'
- 'util/Cargo.toml'
- '.github/workflows/ci.yml'
- 'justfile'
maitake:
paths:
- 'maitake/**/*.rs'
- 'maitake-sync/**/*.rs'
- 'maitake-sync/Cargo.toml'
- 'maitake/Cargo.toml'
- '.github/workflows/ci.yml'
- 'justfile'
# run `cargo check` with the host target triple.
check-host:
name: cargo check (host)
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: install rust toolchain
run: rustup show
- uses: olix0r/cargo-action-fmt@ee1ef42932e44794821dab57ef1bf7a73df8b21f
- uses: actions/checkout@v4
- name: run cargo check (debug)
run: |
cargo check \
--workspace \
--all-features \
--quiet \
--message-format=json |
cargo-action-fmt
- name: run cargo check (release)
run: |
cargo check \
--release \
--workspace \
--all-features \
--quiet \
--message-format=json |
cargo-action-fmt
# check code style with `rustfmt`
rustfmt:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- uses: olix0r/cargo-action-fmt@ee1ef42932e44794821dab57ef1bf7a73df8b21f
- name: run rustfmt
run: cargo fmt --check --message-format=json | cargo-action-fmt
# are there any annoying clippy lints we ought to clean up?
clippy:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: olix0r/cargo-action-fmt@ee1ef42932e44794821dab57ef1bf7a73df8b21f
- name: cargo clippy
run: just clippy
# run host tests
#
# many crates in mycelium have tests that run on the host platform and are
# compiled with the host's target triple. this allows the tests to use the
# Rust standard library, enabling the use of testing libraries like `proptest`
# and `loom`.
#
# it's also faster to run these tests without building a kernel image and
# spinning up a QEMU VM, so host tests are preferred for tests that doesn't
# *need* to be tested in a mycelium VM.
test-host:
runs-on: ubuntu-latest
name: cargo test (host)
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install nextest
uses: taiki-e/install-action@nextest
- name: cargo nextest run
run: just test-host
# build a bootable image for the `x86_64-mycelium` target.
build-x64:
name: build boot image (x86_64)
runs-on: ubuntu-latest
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: x86_64 boot image
run: cargo build-x64
# run kernel tests in QEMU for the `x86_64-mycelium` target.
test-x64:
name: cargo test (cross x64)
runs-on: ubuntu-latest
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
# install QEMU
- name: install qemu
run: |
sudo apt-get update
sudo apt-get install qemu-system-x86
# run kernel tests in QEMU
- name: run tests
run: cargo test-x64
# check that RustDoc builds
docs:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- uses: olix0r/cargo-action-fmt@ee1ef42932e44794821dab57ef1bf7a73df8b21f
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: run rustdoc
run: just check-docs
### cordyceps ###
# run loom tests
cordyceps_loom:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true' || !fromJSON(needs.changed_paths.outputs.paths_result).cordyceps.should_skip
runs-on: ubuntu-latest
name: Loom tests (cordyceps)
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install nextest
uses: taiki-e/install-action@nextest
- name: run loom tests
run: just loom cordyceps
# run miri tests
cordyceps_miri:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true' || !fromJSON(needs.changed_paths.outputs.paths_result).cordyceps.should_skip
runs-on: ubuntu-latest
name: Miri tests (codyceps)
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install nextest
uses: taiki-e/install-action@nextest
- name: run Miri tests
run: just miri cordyceps
### maitake ###
# test with `--no-default-features`
maitake_no_default_features:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true' || !fromJSON(needs.changed_paths.outputs.paths_result).maitake.should_skip
runs-on: ubuntu-latest
name: Tests (maitake, no-default-features)
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: run tests
# don't run doctests with `no-default-features`, as some of them
# require liballoc.
run: cargo test -p maitake --no-default-features --tests --lib
# run loom tests
maitake_loom:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true' || !fromJSON(needs.changed_paths.outputs.paths_result).maitake.should_skip
runs-on: ubuntu-latest
name: Loom tests (maitake)
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install nextest
uses: taiki-e/install-action@nextest
- name: run loom tests (maitake)
run: just loom maitake
- name: run loom tests (maitake-sync)
run: just loom maitake-sync
### mycelium-util ###
# run loom tests
util_loom:
needs: changed_paths
if: needs.changed_paths.outputs.should_skip != 'true' || !fromJSON(needs.changed_paths.outputs.paths_result).util.should_skip
runs-on: ubuntu-latest
name: Loom tests (mycelium-util)
steps:
- name: install rust toolchain
run: rustup show
- uses: actions/checkout@v4
- name: install Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install nextest
uses: taiki-e/install-action@nextest
- name: run loom tests
run: just loom mycelium-util