-
Notifications
You must be signed in to change notification settings - Fork 12
484 lines (426 loc) · 15.6 KB
/
main.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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
schedule:
# run every morning at 3:17am
- cron: '17 3 * * *'
jobs:
build:
runs-on: ubuntu-24.04
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# clang-sys and thus bindgen is sensitive to multiple installed versions
# around, see eg. https://github.com/rust-lang/rust-bindgen/issues/2682
#
# CLANG_PATH should be set to the most recent clang installed, no matter
# what /usr/bin/clang is, for some parts of the code will go for the
# newest standard library. It may also need to be aligned with the clang
# version which Xtensa provides.
CLANG_PATH: /usr/bin/clang-18
strategy:
fail-fast: false
matrix:
partition: ["1/20", "2/20", "3/20", "4/20", "5/20", "6/20", "7/20", "8/20", "9/20", "10/20", "11/20", "12/20", "13/20", "14/20", "15/20", "16/20", "17/20", "18/20", "19/20", "20/20"]
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Get git tree hash
id: get-tree-hash
run: |
git rev-parse HEAD^{tree} > .tree-hash
echo "hash=$(cat .tree-hash)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: result-cache
with:
path: .tree-hash
key: success-${{ steps.get-tree-hash.outputs.hash }}-${{ matrix.partition }}-${{ github.event_name == 'schedule' && 'full' || 'limited' }}
- name: Run sccache-cache
if: steps.result-cache.outputs.cache-hit != 'true'
uses: mozilla-actions/sccache-action@v0.0.4
- id: get_toolchain
run: echo "toolchain=$(scripts/rust-toolchain.sh)" >> $GITHUB_OUTPUT
- name: Install toolchain
if: steps.result-cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.get_toolchain.outputs.toolchain }}
targets: riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv8m.main-none-eabi
# rust-src: Used for -Zbuild-std.
# rustfmt: Used by bindgen for liboscore
components: rust-src, rustfmt
- name: Install Rust for Xtensa
uses: esp-rs/xtensa-toolchain@v1.5
with:
buildtargets: esp32s3
- name: Keep general build environment clean of Xtensa peculiarities
# The Xtensa setup unconditionally sets LIBCLANG_PATH in GITHUB_ENV --
# we can't undo that. (It also sets it in ~/exports, but that is just
# what it uses internally to get that data around into the action
# script)
#
# As the shell apparently does not source any files, and until
# https://github.com/actions/runner/issues/1126 is fixed by GitHub, the
# best remedy is to stow the workaround and source it wherever we can.
run: |
set -x
echo 'unset LIBCLANG_PATH' >> ~/source-this-first.sh
- name: rust cache
if: steps.result-cache.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.partition }}"
- uses: taiki-e/install-action@v2
if: steps.result-cache.outputs.cache-hit != 'true'
with:
tool: cargo-binstall
- name: "installing prerequisites"
if: steps.result-cache.outputs.cache-hit != 'true'
run: |
source ~/source-this-first.sh
git config --global init.defaultBranch main
git config --global user.email "ci@riot-labs.de"
git config --global user.name "CI"
cargo binstall --no-confirm --no-symlinks --force --no-discover-github-token laze
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
sudo apt-get install ninja-build gcc-arm-none-eabi
- name: "Show installed versions"
run: |
set -x
set +e
env
llvm-config --libs
cargo version
laze --version
arm-none-eabi-gcc --version
clang --version
set +x
# Check which alternative versions are installed
IFS=":"; for p in $PATH; do ls $p/llvm-config-* $p/clang-* 2>/dev/null; done
sha256sum /usr/lib/llvm-*/lib/clang/*/include/stdint.h
true
- name: "limit build unless nightly build"
if: github.event_name != 'schedule'
run: |
source ~/source-this-first.sh
echo "LAZE_BUILDERS=ai-c3,espressif-esp32-c6-devkitc-1,espressif-esp32-s3-wroom-1,microbit-v2,nrf52840dk,nrf5340dk,rpi-pico,rpi-pico-w,st-nucleo-h755zi-q,st-nucleo-wb55" >> "$GITHUB_ENV"
- name: "riot-rs compilation test"
if: steps.result-cache.outputs.cache-hit != 'true'
run: |
source ~/source-this-first.sh
sccache --start-server || true # work around https://github.com/ninja-build/ninja/issues/2052
CONFIG_WIFI_NETWORK='test' CONFIG_WIFI_PASSWORD='password' laze build --global --partition hash:${{ matrix.partition }}
cargo-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- id: get_toolchain
run: echo "toolchain=$(scripts/rust-toolchain.sh)" >> $GITHUB_OUTPUT
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.get_toolchain.outputs.toolchain }}
# TODO: we'll eventually want to test the whole workspace with --workspace
# TODO: we'll eventually want to enable relevant features
- name: Run crate tests
run: |
cargo test \
--no-default-features \
--features "
external-interrupts,
i2c,
no-boards,
spi,
" \
-p riot-rs \
-p riot-rs-embassy \
-p riot-rs-embassy-common \
-p riot-rs-identity \
-p riot-rs-macros \
-p riot-rs-runqueue \
-p riot-rs-threads \
cargo test \
-p coapcore \
-p rbi \
-p ringbuffer \
# We need to set `RUSTDOCFLAGS` as well in the following jobs, because it
# is used for doc tests.
- name: cargo test for RP
run: |
RUSTDOCFLAGS='--cfg context="rp2040"' RUSTFLAGS='--cfg context="rp2040"' cargo test \
--features "
embassy-rp/rp2040,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-rp
- name: cargo test for nRF
run: |
RUSTDOCFLAGS='--cfg context="nrf52840"' RUSTFLAGS='--cfg context="nrf52840"' cargo test \
--features "
embassy-nrf/nrf52840,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-nrf
- name: cargo test for STM32
run: |
RUSTDOCFLAGS='--cfg context="stm32wb55rgvx"' RUSTFLAGS='--cfg context="stm32wb55rgvx"' cargo test \
--features "
embassy-stm32/stm32wb55rg,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-stm32
lint:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- id: get_toolchain
run: echo "toolchain=$(scripts/rust-toolchain.sh)" >> $GITHUB_OUTPUT
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.get_toolchain.outputs.toolchain }}
# Required for checking riot-rs-esp
targets: riscv32imac-unknown-none-elf
components: clippy, rustfmt
- name: rust cache
uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-binstall
# Should run as soon as possible to avoid using unwanted crates
# `--force`ing is required as the installed binary could have been
# restored from cache.
- name: cargo-deny
run: |
cargo binstall --no-confirm --no-discover-github-token --force cargo-deny
cargo deny check bans licenses sources
# Must run after the cargo-deny job as it requires the downloaded
# cargo-deny binary.
- name: cargo-deny advisories
run: cargo deny check advisories
# Prevent sudden announcement of a new advisory from failing CI
continue-on-error: true
# TODO: we'll eventually want to check the whole workspace with --workspace
# TODO: we'll eventually want to check relevant feature combinations
# TODO: we may want to use --no-deps as well
- name: clippy
uses: clechasseur/rs-clippy-check@v3
with:
args: |
--verbose
--locked
--features "
external-interrupts,
net,
no-boards,
spi,
storage,
"
-p riot-rs
-p riot-rs-arch
-p riot-rs-boards
-p riot-rs-chips
-p riot-rs-coap
-p riot-rs-debug
-p riot-rs-embassy
-p riot-rs-embassy-common
-p riot-rs-identity
-p riot-rs-macros
-p riot-rs-random
-p riot-rs-rt
-p riot-rs-storage
-p riot-rs-threads
-p riot-rs-utils
--
--deny warnings
- run: echo 'RUSTFLAGS=--cfg context="esp32c6"' >> $GITHUB_ENV
- name: clippy for ESP32
uses: clechasseur/rs-clippy-check@v3
with:
args: |
--verbose
--locked
--target=riscv32imac-unknown-none-elf
--features "
esp-hal-embassy/esp32c6,
esp-hal/esp32c6,
external-interrupts,
i2c,
spi,
"
-p riot-rs-esp
--
--deny warnings
- run: echo 'RUSTFLAGS=--cfg context="rp2040"' >> $GITHUB_ENV
- name: clippy for RP
uses: clechasseur/rs-clippy-check@v3
with:
args: |
--verbose
--locked
--features "
embassy-rp/rp2040,
external-interrupts,
i2c,
spi,
"
-p riot-rs-rp
--
--deny warnings
- run: echo 'RUSTFLAGS=--cfg context="nrf52840"' >> $GITHUB_ENV
- name: clippy for nRF
uses: clechasseur/rs-clippy-check@v3
with:
args: |
--verbose
--locked
--features "
embassy-nrf/nrf52840,
external-interrupts,
i2c,
spi,
"
-p riot-rs-nrf
--
--deny warnings
- run: echo 'RUSTFLAGS=--cfg context="stm32wb55rgvx"' >> $GITHUB_ENV
- name: clippy for STM32
uses: clechasseur/rs-clippy-check@v3
with:
args: |
--verbose
--locked
--features "
embassy-stm32/stm32wb55rg,
external-interrupts,
i2c,
spi,
"
-p riot-rs-stm32
--
--deny warnings
# Reset `RUSTFLAGS`
- run: echo 'RUSTFLAGS=' >> $GITHUB_ENV
- name: rustdoc
run: |
RUSTDOCFLAGS='-D warnings' cargo doc \
-p riot-rs \
--features "
bench,
coap,
csprng,
executor-thread,
external-interrupts,
hwrng,
i2c,
net,
no-boards,
random,
riot-rs-coap/doc,
spi,
storage,
threading,
usb,
"
- name: rustdoc for ESP32
run: |
RUSTDOCFLAGS='-D warnings --cfg context="esp32c6"' cargo doc \
--target=riscv32imac-unknown-none-elf \
--features "
esp-hal-embassy/esp32c6,
esp-hal/esp32c6,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-esp
- name: rustdoc for RP
run: |
RUSTDOCFLAGS='-D warnings --cfg context="rp2040"' cargo doc \
--features "
embassy-rp/rp2040,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-rp
- name: rustdoc for nRF
run: |
RUSTDOCFLAGS='-D warnings --cfg context="nrf52840"' cargo doc \
--features "
embassy-nrf/nrf52840,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-nrf
- name: rustdoc for STM32
run: |
RUSTDOCFLAGS='-D warnings --cfg context="stm32wb55rgvx"' cargo doc \
--features "
embassy-stm32/stm32wb55rg,
external-interrupts,
i2c,
spi,
" \
-p riot-rs-stm32
- name: rustfmt
run: cargo fmt --check --all
- name: yamllint
uses: karancode/yamllint-github-action@master
with:
yamllint_comment: true # Insert inline PR comments
yamllint_strict: true # Set error code on warnings
- name: Install taplo
run: cargo binstall --no-confirm --no-symlinks --no-discover-github-token --force taplo-cli
- name: Check toml formatting
run: taplo fmt --check
# TODO: cargo-sort is disabled for now, as it won't stop formatting / failing perfectly sorted Cargo.toml files.
# - name: Install cargo-sort
# run: cargo install --git=https://github.com/DevinR528/cargo-sort --rev 55ec89082466f6bb246d870a8d56d166a8e1f08b cargo-sort
# - name: Check item order of Cargo.toml files
# run: cargo sort --check --grouped --workspace --no-format
- name: Ruff
uses: chartboost/ruff-action@v1
with:
args: format --check # Only check formatting for now
- name: typos
uses: crate-ci/typos@v1.22.0
- name: Check that the HTML support matrix is up to date
run: ./doc/gen_support_matrix_html.rs check doc/support_matrix.yml book/src/support_matrix.html
CI-success:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Final Results
needs: [build]
steps:
- run: |
result="${{ needs.build.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
- name: Report nightly failure
if: failure() && github.event_name == 'schedule' && github.repository == 'future-proof-iot/RIOT-rs'
uses: s3krit/matrix-message-action@v0.0.3
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "The nightly build [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
server: "matrix.org"