-
Notifications
You must be signed in to change notification settings - Fork 8
381 lines (331 loc) · 12.9 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
name: CI
on:
pull_request:
push:
permissions:
contents: read
checks: write
jobs:
# Do a quick check before proceeding to full tests
check:
name: Quick check
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
# FIXME: Switch back when actions-rs/toolchain#{209,220,222} is merged
uses: r3-os/actions-rust-toolchain@a862b6623c178b43a3135516442a5f72fb5c1877
with:
profile: minimal
components: clippy, rustfmt
- name: Install Tagref
uses: ./.github/actions/install-tagref
- name: Install dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev libudev-dev
- name: Allow `incomplete_features`
run: |
echo "RUSTFLAGS=-A incomplete_features" >> $GITHUB_ENV
- name: Exclude crates
run: |
# Example crates will fail to compile unless an appropriate target
# triple is provided.
sed -E -i.bak 's/.*basic_.*//' Cargo.toml
sed -E -i.bak 's/.*smp_rp_pico.*//' Cargo.toml
# Make sure to remove the backup file, or else Tagref will report an
# error for having duplicate tag definitions
rm Cargo.toml.bak
- name: Check cross-references with Tagref
run: tagref
- name: Clippy
# FIXME: Switch back when actions-rs/clippy-check#168 gets merged
uses: r3-os/actions-rust-clippy-check@7418fd383746dc33a54d80bdba01d3ea74e7105b
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace
# TODO: Add something like <https://github.com/mbrobbel/rustfmt-check>,
# except for pushing commits automatically
# Check crate metadata
workspace:
name: Check crate metadata
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies (Linux)
run: sudo snap install deno
- name: Check crate metadata
run: |
deno --version
deno run --allow-read scripts/check-workspace.ts
# Build examples
build-examples:
name: Build examples
needs: check
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2022]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
# FIXME: Switch back when actions-rs/toolchain#{209,220,222} is merged
uses: r3-os/actions-rust-toolchain@a862b6623c178b43a3135516442a5f72fb5c1877
with:
profile: minimal
- name: Install additional target of the Rust toolchain (Arm)
run: |
rustup target add thumbv6m-none-eabi thumbv7em-none-eabihf
rustup target add armv7a-none-eabi
- name: Allow `incomplete_features`
run: |
echo "RUSTFLAGS=-A incomplete_features" >> $GITHUB_ENV
- name: Build examples
shell: bash
run: |
for d in examples/*; do
echo "::group::$d"
pushd $d
cargo build --release
popd
echo "::endgroup::"
done
# Run tests on the host system
test-hosted:
name: Test
needs: check
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# TODO: Add `macos-11` after addressing `riscv-rt` build failure
os: [ubuntu-20.04, windows-2022]
features: [all-features]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
# FIXME: Switch back when actions-rs/toolchain#{209,220,222} is merged
uses: r3-os/actions-rust-toolchain@a862b6623c178b43a3135516442a5f72fb5c1877
with:
profile: minimal
- name: Install dependencies (Linux)
if: startsWith(matrix.os, 'ubuntu-')
run: |
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev libudev-dev
# Some tests are sensitive to timing and can fail
# in Windows and macOS VMs
- name: Limit concurrency
if: "!startsWith(matrix.os, 'ubuntu-')"
run: echo "testflags=--test-threads=1" >> $GITHUB_ENV
- name: Allow `incomplete_features`
run: |
echo "RUSTFLAGS=-A incomplete_features" >> $GITHUB_ENV
- name: Exclude crates
shell: bash
run: |
sed -E -i.bak 's/.*basic_.*//' Cargo.toml
sed -E -i.bak 's/.*smp_rp_pico.*//' Cargo.toml
- name: Test
# FIXME: Switch back when actions-rs/cargo#217 gets merged
uses: r3-os/actions-rust-cargo@fb222fe18dc90e381546d012f9e3d6f353f0f627
with:
command: test
args: --workspace -- ${{ env.testflags }}
env:
RUST_LOG: debug
- name: Test (-p r3_port_std --benches)
# FIXME: Switch back when actions-rs/cargo#217 gets merged
uses: r3-os/actions-rust-cargo@fb222fe18dc90e381546d012f9e3d6f353f0f627
with:
command: test
args: -p r3_port_std --benches -- ${{ env.testflags }}
env:
RUST_LOG: debug
# Run tests on the host system with a subset of optional features enabled
test-hosted-subset:
name: Test
needs: check
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
features:
- ""
- priority_boost
- system_time
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
# FIXME: Switch back when actions-rs/toolchain#{209,220,222} is merged
uses: r3-os/actions-rust-toolchain@a862b6623c178b43a3135516442a5f72fb5c1877
with:
profile: minimal
- name: Install dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev libudev-dev
- name: Allow `incomplete_features`
run: |
echo "RUSTFLAGS=-A incomplete_features" >> $GITHUB_ENV
- name: Convert feature list to Cargo parameter
run: |
features='${{ matrix.features }}'
if [ "$features" ]; then
features="--features r3_test_suite/$features --features r3_kernel/$features"
fi
echo "features_param=$features" >> $GITHUB_ENV
- name: Test
# FIXME: Switch back when actions-rs/cargo#217 gets merged
uses: r3-os/actions-rust-cargo@fb222fe18dc90e381546d012f9e3d6f353f0f627
with:
command: test
args: -p r3_port_std --no-default-features ${{ env.features_param }}
env:
RUST_LOG: debug
# Run tests on emulated freestanding targets
test-freestanding:
name: Test
needs: check
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
# Arm RealView PBX for Cortex-A9, Armv7-A
- { ty: arm, runner_target: qemu_realview_pbx_a9, runner_args: "" }
# MPS2+ AN505, Armv8-M Mainline + FPU
- { ty: arm, runner_target: qemu_mps2_an505, runner_args: "" }
# MPS2+ AN505, Armv8-M Mainline
- { ty: arm, runner_target: qemu_mps2_an505, runner_args: --arch cortex_m33 }
# MPS2+ AN505, Armv8-M Baseline
- { ty: arm, runner_target: qemu_mps2_an505, runner_args: --arch cortex_m23 }
# MPS2+ AN505, Armv7-M + FPU + DSP
- { ty: arm, runner_target: qemu_mps2_an505, runner_args: --arch cortex_m4f }
# MPS2+ AN385, Armv7-M
- { ty: arm, runner_target: qemu_mps2_an385, runner_args: "" }
# MPS2+ AN385, Armv6-M
- { ty: arm, runner_target: qemu_mps2_an385, runner_args: --arch cortex_m0 }
# SiFive U, RV64GC
- { ty: riscv, runner_target: qemu_sifive_u_rv64, runner_args: "" }
# SiFive U, RV64IMAC
- { ty: riscv, runner_target: qemu_sifive_u_rv64, runner_args: --arch rv64i+m+a+c }
# SiFive U, RV64IMA
- { ty: riscv, runner_target: qemu_sifive_u_rv64, runner_args: --arch rv64i+m+a }
# SiFive U, RV32GC
# FIXME: Re-enable when rust-lang/rust#104284 is fixed
# - { ty: riscv, runner_target: qemu_sifive_u_rv32, runner_args: "" }
# SiFive U, RV64GC, S-mode
- { ty: riscv, runner_target: qemu_sifive_u_s_rv64, runner_args: "" }
# SiFive U, RV32GC, S-mode
# FIXME: Re-enable when rust-lang/rust#104284 is fixed
# - { ty: riscv, runner_target: qemu_sifive_u_s_rv32, runner_args: "" }
# SiFive E, RV32IMAC
- { ty: riscv, runner_target: qemu_sifive_e_rv32, runner_args: "" }
# SiFive E, RV32IA
- { ty: riscv, runner_target: qemu_sifive_e_rv32, runner_args: --arch rv32i+a }
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
# FIXME: Switch back when actions-rs/toolchain#{209,220,222} is merged
uses: r3-os/actions-rust-toolchain@a862b6623c178b43a3135516442a5f72fb5c1877
with:
profile: minimal
components: rust-src
- name: Install dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev libudev-dev ninja-build
- name: Cache QEMU's built binaries
uses: actions/cache@v3
with:
path: ~/.qemu
key: ${{ runner.os }}-ci-qemu-arm_riscv
- name: Install QEMU 6.1.0 from source
uses: ./.github/actions/install-qemu
with:
target-list: arm-softmmu,riscv32-softmmu,riscv64-softmmu
- name: Install additional target of the Rust toolchain (Arm)
if: matrix.ty == 'arm'
run: |
rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabihf
rustup target add thumbv8m.base-none-eabi thumbv8m.main-none-eabi thumbv8m.main-none-eabihf
rustup target add armv7a-none-eabi
- name: Install additional target of the Rust toolchain (RISC-V)
if: matrix.ty == 'riscv'
run: |
rustup target add riscv32imac-unknown-none-elf
rustup target add riscv64imac-unknown-none-elf riscv64gc-unknown-none-elf
- name: Cache test runner's binary
uses: actions/cache@v3
with:
path: ./target/debug
key: ${{ runner.os }}-ci-runner-${{ hashFiles('rust-toolchain', 'src/r3_test_runner/**', 'src/r3_test_suite/**') }}
- name: Test
run: |
cargo r3test --target ${{ matrix.runner_target }} ${{ matrix.runner_args }} --log-level debug
# Build a small subset of tests for real freestanding targets
build-freestanding:
name: Build
needs: check
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- { ty: arm, runner_target: nucleo_f401re, runner_args: "", bench: "bench" }
- { ty: arm, runner_target: gr_peach, runner_args: "", bench: "bench" }
- { ty: arm, runner_target: rp_pico, runner_args: "", bench: "bench" }
- { ty: riscv, runner_target: red_v, runner_args: "", bench: "bench" }
- { ty: riscv, runner_target: maix, runner_args: "", bench: "bench" }
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
# FIXME: Switch back when actions-rs/toolchain#{209,220,222} is merged
uses: r3-os/actions-rust-toolchain@a862b6623c178b43a3135516442a5f72fb5c1877
with:
profile: minimal
components: rust-src
- name: Install dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev libudev-dev
- name: Install additional target of the Rust toolchain (Arm)
if: matrix.ty == 'arm'
run: |
rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabihf
rustup target add thumbv8m.base-none-eabi thumbv8m.main-none-eabi thumbv8m.main-none-eabihf
rustup target add armv7a-none-eabi
- name: Install additional target of the Rust toolchain (RISC-V)
if: matrix.ty == 'riscv'
run: |
rustup target add riscv32imac-unknown-none-elf
rustup target add riscv64imac-unknown-none-elf riscv64gc-unknown-none-elf
- name: Cache test runner's binary
uses: actions/cache@v3
with:
path: ./target/debug
key: ${{ runner.os }}-ci-runner-${{ hashFiles('rust-toolchain', 'src/r3_test_runner/**', 'src/r3_test_suite/**') }}
- name: Build tests
run: |
cargo r3test --target ${{ matrix.runner_target }} ${{ matrix.runner_args }} --norun basic
- name: Build benchmark tests
if: matrix.bench == 'bench' # Benchmark support is optional
run: |
cargo r3test --target ${{ matrix.runner_target }} ${{ matrix.runner_args }} --norun -b semaphore