-
Notifications
You must be signed in to change notification settings - Fork 37
303 lines (257 loc) · 9.53 KB
/
run-tests.yaml
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
name: Run tests
on:
pull_request: {}
schedule:
- cron: '0 0 * * 0' # every sunday
env:
ZEPHYR_SDK_VERSION: 0.16.5
ZEPHYR_REV: 5cbf7b1b9d13a39f36ad8dabfaeaec21d98cf5ff
jobs:
merge-test-1:
runs-on: ubuntu-22.04
strategy:
matrix:
platform: ["native_posix", "native_posix/native/64", "mps2/an521/cpu0"]
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Merge test 1 - Twister (Ubuntu) (${{ matrix.platform }}${{ matrix.asserts != '' && ' with asserts' || '' }})
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Install zcbor
uses: ./.github/actions/install_zcbor
- name: Prepare and run tests
uses: ./.github/actions/prepare_and_run_tests
with:
twister_arguments: "--timestamps --platform ${{ matrix.platform }} ${{ matrix.asserts }} --exclude-tag release"
zephyr_toolchain: ${{ matrix.platform == 'mps2/an521/cpu0' && 'zephyr' || 'host'}}
zephyr_toolchain_arch: ${{ matrix.platform == 'mps2/an521/cpu0' && 'arm' || ''}}
merge-test-1-win:
runs-on: windows-latest
strategy:
matrix:
platform: ["mps2/an521/cpu0"]
asserts: [""]
name: Merge test 1 - Twister (Windows) (${{ matrix.platform }}${{ matrix.asserts != '' && ' with asserts' || '' }} - build only)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Checkout Zephyr
run: |
git init zephyr-clone
cd zephyr-clone
git remote add origin https://github.com/zephyrproject-rtos/zephyr
git fetch origin $env:ZEPHYR_REV --depth=1
git reset --hard FETCH_HEAD
- name: Install zcbor and pip dependencies
run: |
$ErrorActionPreference="Stop"
pip install -U -r scripts\requirements.txt -r zephyr-clone\scripts\requirements-base.txt -r zephyr-clone\scripts\requirements-build-test.txt -r zephyr-clone\scripts\requirements-run-test.txt; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
pip install -e .
- name: Install ninja and 7zip
run: |
choco feature enable -n allowGlobalConfirmation
choco install ninja 7zip
- name: Run West
run: |
$ErrorActionPreference="Stop"
west init -l zephyr-clone; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
west update cmsis
- name: Install Zephyr SDK (ARM)
run: |
$client = new-object System.Net.WebClient
$client.DownloadFile("https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$env:ZEPHYR_SDK_VERSION/zephyr-sdk-${env:ZEPHYR_SDK_VERSION}_windows-x86_64_minimal.7z", "$pwd\zephyr-sdk-${env:ZEPHYR_SDK_VERSION}_windows-x86_64_minimal.7z")
7z x $pwd\zephyr-sdk-${env:ZEPHYR_SDK_VERSION}_windows-x86_64_minimal.7z
Rename-Item -Path zephyr-sdk-${env:ZEPHYR_SDK_VERSION} -NewName zephyr-sdk
cd zephyr-sdk
$client.DownloadFile("https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$env:ZEPHYR_SDK_VERSION/toolchain_windows-x86_64_arm-zephyr-eabi.7z", "$pwd\toolchain_windows-x86_64_arm-zephyr-eabi.7z")
7z x $pwd\toolchain_windows-x86_64_arm-zephyr-eabi.7z
- name: Run Twister
shell: cmd
run: |
set ZEPHYR_BASE=%cd%\zephyr-clone
set ZEPHYR_TOOLCHAIN_VARIANT=zephyr
set ZEPHYR_SDK_INSTALL_DIR=%cd%\zephyr-sdk
python %ZEPHYR_BASE%\scripts\twister -i -v -T tests -W --timestamps --platform ${{ matrix.platform }} ${{ matrix.asserts }} --exclude-tag release --build-only
merge-test-2:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
name: Merge tests 2 - Python (${{ matrix.python-version }}) functional tests (Ubuntu)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_install'
- name: Run python tests
working-directory: tests/scripts
run: |
python3 -m unittest test_zcbor
merge-test-2-win:
runs-on: windows-latest
name: Merge tests 2 - Python (${{ matrix.python-version }}) functional tests (Windows)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Read zcbor version
run: |
echo "ZCBOR_VERSION=$(cat zcbor/VERSION)" >> $env:GITHUB_ENV
- name: Install west and dependencies
run: |
pip install -U pip
pip install -U build
pip install -U -r scripts/requirements.txt
- name: Generate and install zcbor package
run: |
$ErrorActionPreference="Stop"
python -m build; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
pip install dist/zcbor-$env:ZCBOR_VERSION-py3-none-any.whl; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
pip uninstall -y zcbor
pip install -e .
- name: Run python tests
working-directory: tests/scripts
run: |
python3 -m unittest test_zcbor
merge-test-3:
runs-on: ubuntu-22.04
name: Merge tests 3 - Check repo files (Ubuntu)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_develop'
- name: Run tests on repo files
working-directory: tests/scripts
run: |
python3 -m unittest test_repo_files
release-test-1:
runs-on: ubuntu-22.04
name: Release tests 1 - Fuzz
needs:
- merge-test-1
- merge-test-1-win
- merge-test-2
- merge-test-2-win
- merge-test-3
if: "startswith(github.head_ref, 'release/')"
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Read zcbor version
run: echo "ZCBOR_VERSION=$(cat zcbor/VERSION)" >> $GITHUB_ENV
- name: Install zcbor
uses: ./.github/actions/install_zcbor
- name: Run python release tests
working-directory: tests/scripts
run: |
set -e
echo -n ${{ github.head_ref }} > HEAD_REF
python3 -m unittest test_versions
rm HEAD_REF
- name: Install packages
run: |
sudo apt update
sudo apt install -y afl++
- name: Run everything fuzz tests
working-directory: tests/fuzz
run: |
./test-afl.sh 2400 64 everything
- name: Run manifest12 fuzz tests
working-directory: tests/fuzz
run: |
./test-afl.sh 800 64 manifest12
- name: Run pet fuzz tests
working-directory: tests/fuzz
run: |
./test-afl.sh 400 64 pet
- name: Rename fuzz failures
if: ${{ failure() }}
working-directory: tests/fuzz/build-afl/output/default/crashes/
run: |
for i in ./* ; do mv "$i" "${i//:/_}_1"; done
- name: Upload fuzz failures
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: fuzz-failures
path: tests/fuzz/build-afl/output/default/crashes/
- name: Upload release files
uses: actions/upload-artifact@v4
with:
name: zcbor-release-$ZCBOR_VERSION
path: dist/*
release-test-2:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Release tests 2 (Python ${{ matrix.python-version }}${{ matrix.asserts != '' && ' with asserts' || '' }})
needs:
- merge-test-1
- merge-test-1-win
- merge-test-2
- merge-test-2-win
- merge-test-3
if: "github.event_name == 'schedule' || (github.event_name == 'pull_request' && startswith(github.head_ref, 'release/'))"
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_install'
- name: Prepare and run tests
uses: ./.github/actions/prepare_and_run_tests
with:
twister_arguments: "--timestamps --platform native_posix --platform native_posix/native/64 --platform mps2/an521/cpu0 --platform qemu_malta/qemu_malta/be ${{ matrix.asserts }}"
zephyr_toolchain: zephyr
zephyr_toolchain_arch: arm,mips
release-test-3:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Release tests 3 (Python ${{ matrix.python-version }}${{ matrix.asserts != '' && ' with asserts' || '' }})
needs:
- merge-test-1
- merge-test-1-win
- merge-test-2
- merge-test-2-win
- merge-test-3
if: "github.event_name == 'schedule' || (github.event_name == 'pull_request' && startswith(github.head_ref, 'release/'))"
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_develop'
- name: Run python tests on samples
working-directory: tests/scripts
run: |
python3 -m unittest test_repo_files.TestSamples