-
Notifications
You must be signed in to change notification settings - Fork 10
167 lines (151 loc) · 5.61 KB
/
test.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
# Ideally this should be replaced with a call out to Murdock; until that is
# practical, building representative examples.
# Ad RUSTFLAGS=-Dwarnings: While this is generally discouraged (for it means
# that new Rust versions break CI), in this case we don't get new Rust versions
# all the time but only on riotdocker updates, and that's a good time to
# reflect on whether the new warnings make sense or not.
name: test
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
jobs:
examples-and-tests:
runs-on: ubuntu-latest
container: riot/riotbuild
strategy:
matrix:
# This is the subset of `make -f makefiles/app_dirs.inc.mk
# info-applications` that is probably relevant; more is covered when
# riot-wrappers are updated in RIOT.
example: [examples/rust-hello-world, examples/rust-gcoap, examples/rust-async, tests/rust_minimal, tests/rust_libs]
board: [native, sltb001a, samr21-xpro, stk3700]
steps:
# common steps start here
- name: Check out riot-wrappers
uses: actions/checkout@v3
- name: Check out RIOT
uses: actions/checkout@v3
with:
repository: RIOT-OS/RIOT
path: RIOT
# common steps end here
- name: Patch .cargo/config.toml to use current checkout
run: |
set -x
cd RIOT
rm -f .cargo/config.toml
mkdir -p .cargo # Keep working if RIOT ever decides it doesn't need overrides any more
echo '[patch.crates-io]' >> .cargo/config.toml
echo 'riot-wrappers = { path = "../", version = "*" }' >> .cargo/config.toml
echo 'riot-sys = { git = "https://github.com/RIOT-OS/rust-riot-sys" }' >> .cargo/config.toml
- name: Pull cargo updates
# No sense in running this in parallel -- this will download the index
# and all relevant crates once, and after that, just make some notes in Cargo.lock
run: |
set -x
# It is important to cd in early, for otherwise the patch.crates-io
# will not catch on during the update
cd RIOT
for MANIF in $(find -name Cargo.toml)
do
echo "::group::Updating ${MANIF}"
cargo update -p riot-sys -p riot-wrappers --aggressive --manifest-path $MANIF
cargo fetch --manifest-path $MANIF
cargo tree --manifest-path $MANIF
echo "::endgroup::"
done
- name: Build the example
run: |
RUSTFLAGS=-Dwarnings make all BOARD=${{ matrix.board }} -C RIOT/${{ matrix.example }}
enumerate-wrappers-tests:
runs-on: ubuntu-latest
outputs:
list: ${{ steps.enumerate.outputs.tests }}
steps:
- name: Check out riot-wrappers
uses: actions/checkout@v3
- name: List tests in riot-wrappers
id: enumerate
run: |
echo "tests=[$(ls -d tests/*/ -1 | sed 's/.*/\"&\"/' | tr '\n' ',' | sed 's/,$//')]" >> "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}"
- name: Set job summary
run: |
# This doubles as a check to see that our JSON is right
echo 'Local tests were enumerated to be `${{ toJSON(fromJSON( steps.enumerate.outputs.tests )) }}`' >> $GITHUB_STEP_SUMMARY
wrappers-tests:
runs-on: ubuntu-latest
needs: enumerate-wrappers-tests
container: riot/riotbuild
strategy:
matrix:
board: [native, sltb001a, samr21-xpro, stk3700]
testdir: ${{ fromJSON(needs.enumerate-wrappers-tests.outputs.list) }}
steps:
# common steps start here (kept in sync even though we wouldn't need to patch RIOT's .cargo/config.toml)
- name: Check out riot-wrappers
uses: actions/checkout@v3
- name: Check out RIOT
uses: actions/checkout@v3
with:
repository: RIOT-OS/RIOT
path: RIOT
# common steps end here
- name: Patch local .cargo/config.toml to use current checkout
run: |
mkdir .cargo
echo '[patch.crates-io]' >> .cargo/config.toml
echo 'riot-wrappers = { path = ".", version = "*" }' >> .cargo/config.toml
echo 'riot-sys = { git = "https://github.com/RIOT-OS/rust-riot-sys" }' >> .cargo/config.toml
- name: Build and run test
run: |
set -x
export RIOTBASE=$(pwd)/RIOT
cd ${{ matrix.testdir }}
if BOARDS=${{ matrix.board }} make info-boards-supported | grep -q .
then
BOARD=${{ matrix.board }} RUSTFLAGS=-Dwarnings make all
if [ "native" = "${{ matrix.board }}" ] && make test/available BOARD=native
then
echo
echo "Testing ${D}"
echo
if make BOARD=native info-modules |grep -q netdev_tap; then
# Seems we can't have tap interfaces on GitHub actions, aborting.
echo "Board requires tap interface, skipping."
exit 0
fi
make all test BOARD=native
fi
else
echo "Board is not supported for this test, skipping."
fi
rustfmt:
runs-on: ubuntu-latest
container: docker.io/rust
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Add rustfmt component
run: rustup component add rustfmt
- name: Run cargo-fmt
run: cargo fmt --check
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
all-done:
needs: [rustfmt, wrappers-tests, examples-and-tests, typos, audit]
# It'd suffice to just do "needs", but GitHub actions insist to have steps
runs-on: ubuntu-latest
steps:
- run: echo "All done"