-
Notifications
You must be signed in to change notification settings - Fork 30
426 lines (379 loc) · 13.7 KB
/
ci.yml
File metadata and controls
426 lines (379 loc) · 13.7 KB
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
name: CI pipeline
on:
push:
branches: [master]
tags:
- "*"
pull_request:
branches: [master]
env:
BUILD_TYPE: Debug
jobs:
# Python formatting and linting
py_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install ruff
run: pip install ruff
- name: Check Python formatting and linting
run: scripts/format_py.sh check
# Build C++ and Build Wheels
build_x86:
needs: py_lint
name: Build C++ (${{ matrix.os }}${{ matrix.preset && format(' - {0}', matrix.preset) || '' }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
preset: full
configure_args: "--with=unit_tests --with=code_coverage --with=af_xdp"
apt_packages: "gcovr lcov libxdp-dev libbpf-dev clang"
coverage: true
- os: ubuntu-latest
preset: bare
configure_args: "--with=unit_tests"
apt_packages: "libtinyxml2-dev"
coverage: false
test_install: true
- os: windows-latest
coverage: false
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-conan-action
- name: Install system dependencies
if: matrix.apt_packages
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.apt_packages }}
- name: Setup build (Linux)
if: runner.os == 'Linux'
run: |
scripts/configure.sh ${{github.workspace}}/build -ni ${{ matrix.configure_args }}
./scripts/setup_build.sh ${{github.workspace}}/build --build-type ${{env.BUILD_TYPE}}
shell: bash
- name: Setup build (Windows)
if: runner.os == 'Windows'
run: |
conan install conan/conanfile.py -of=build/ -pr:b conan/profile_windows_x86_64.txt -pr:h conan/profile_windows_x86_64.txt -o "&:unit_tests=True" --build=missing -s build_type=${{env.BUILD_TYPE}}
mkdir -p ${{github.workspace}}/build
cmake -B build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBUILD_UNIT_TESTS=ON \
-G "MinGW Makefiles"
shell: bash
- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}
- name: Unit Test
working-directory: ${{github.workspace}}/build
run: |
if [ "$RUNNER_OS" == "Linux" ] && [ "${{ matrix.coverage }}" == "true" ]; then
make coverage_xml
else
ctest . --output-on-failure
fi
shell: bash
- name: Install smoke test (find_package + pkg-config + KICKCAT_INSTALL=OFF)
if: matrix.test_install
run: ./scripts/test_install.sh build
shell: bash
- name: Upload Build Artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: build-linux-${{ matrix.preset }}
path: build/
retention-days: 1
- name: Upload coverage artifact
if: matrix.os == 'ubuntu-latest' && matrix.coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: build/coverage_xml.xml
if-no-files-found: error
build_arm64:
needs: py_lint
name: Build C++ (ARM64 - ${{ matrix.preset }})
runs-on: ubuntu-24.04-arm
strategy:
matrix:
include:
- preset: full
configure_args: "--with=af_xdp"
apt_packages: "libxdp-dev libbpf-dev clang"
- preset: bare
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-conan-action
- name: Install system dependencies
if: matrix.apt_packages
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.apt_packages }}
- name: Setup build
run: |
${{ matrix.configure_args && format('scripts/configure.sh {0}/build -ni {1}', github.workspace, matrix.configure_args) || '' }}
./scripts/setup_build.sh ${{github.workspace}}/build --build-type ${{env.BUILD_TYPE}}
shell: bash
- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}
- name: Upload Build Artifacts (ARM64)
uses: actions/upload-artifact@v4
with:
name: build-arm64-${{ matrix.preset }}
path: build/
retention-days: 1
build-wheels:
needs: py_lint
name: Build Python Wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
env:
CIBW_ARCHS: native
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v3.1.0
with:
output-dir: wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheelhouse-kickcat-${{ matrix.os }}
path: wheelhouse/*.whl
# Build Conan Package
build-conan-package:
needs: build_x86
name: Build Conan Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-conan-action
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-linux-full
path: build/
- name: Determine version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
echo "PKG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "PKG_VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Conan Create
run: |
conan create conan/all --build=missing --version ${{ env.PKG_VERSION }} -pr:b build/profile.txt -pr:h build/profile.txt
- name: Export Conan package
run: |
conan cache save "kickcat/${{ env.PKG_VERSION }}:*" --file kickcat-${{ env.PKG_VERSION }}-linux-x86_64.tgz
- name: Upload Conan package artifact
uses: actions/upload-artifact@v4
with:
name: conan-package
path: kickcat-${{ env.PKG_VERSION }}-linux-x86_64.tgz
if-no-files-found: error
# Simulation Tests
simulation_test:
needs: [build_x86, build-wheels]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_case:
- name: easycat
example_bin: build/examples/master/easycat/easycat_example
slave_config: simulation/slave_configs/freedom-k64f.json simulation/slave_configs/xmc4800.json
- name: easycat_py
example_bin: py_bindings/examples/easycat.py
slave_config: simulation/slave_configs/freedom-k64f.json simulation/slave_configs/xmc4800.json
- name: freedom-k64f
example_bin: build/examples/master/freedom-k64f/freedom_k64f_static_map_example
slave_config: simulation/slave_configs/freedom-k64f.json
- name: freedom-k64f_py
example_bin: py_bindings/examples/freedom-k64f.py
slave_config: simulation/slave_configs/freedom-k64f.json
- name: wdc-foot
example_bin: build/examples/master/wdc_foot/wdc_foot_example
slave_config: simulation/slave_configs/xmc4800.json
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install AF_XDP runtime deps
run: sudo apt-get update && sudo apt-get install -y libxdp1 libbpf1
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-linux-full
path: build/
- name: Download Wheels
uses: actions/download-artifact@v4
with:
pattern: wheelhouse-kickcat-*
path: wheelhouse
merge-multiple: true
- name: Install KickCAT Wheel
run: |
pip install kickcat --no-index --find-links wheelhouse
- name: Fix permissions
run: |
chmod +x build/simulation/network_simulator
chmod +x ${{ matrix.test_case.example_bin }}
- name: Run Simulation Test (${{ matrix.test_case.name }})
shell: bash
run: |
# 1. Start simulator in background
./build/simulation/network_simulator -i tap:server -s ${{ matrix.test_case.slave_config }} > simulator.log 2>&1 &
SIM_PID=$!
# 2. Wait a bit for simulator to start
sleep 2
# 3. Run example with timeout
timeout 15s ${{ matrix.test_case.example_bin }} -i tap:client > test_output.log 2>&1 || true
# 4. Stop simulator
kill $SIM_PID || true
# 5. Check results
echo "--- Summary of Test Output (last 20 lines) ---"
tail -n 20 test_output.log
echo "----------------------------------------------"
# Check OPERATIONAL reached
if grep -qi "operational" test_output.log; then
echo "SUCCESS: Reached OPERATIONAL state."
else
echo "FAILURE: Did NOT reach OPERATIONAL state."
exit 1
fi
# Check example actually ran (not exited immediately)
LINE_COUNT=$(wc -l < test_output.log)
if [ "$LINE_COUNT" -gt 15 ]; then
echo "SUCCESS: Runtime output detected."
else
echo "FAILURE: Output too short — example likely did not run."
exit 1
fi
echo "Test passed!"
- name: Upload Simulation Logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: simulation-logs-${{ matrix.test_case.name }}
path: |
test_output.log
simulator.log
# NuttX Builds
build_NuttX:
needs: py_lint
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.nuttx.label == 'master' }}
strategy:
fail-fast: false
matrix:
board:
- xmc4800-relax
- arduino-due
- freedom-k64f
nuttx:
- label: stable
ref: nuttx-12.12.0
- label: master
ref: master
env:
arm_none_eabi_version: 13.2.Rel1/binrel/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi
steps:
- name: Checkout KickCAT
uses: actions/checkout@v4
with:
path: "KickCAT"
- name: Cache NuttX
id: cache-nuttx
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/nuttxspace/nuttx
key: nuttx_${{ matrix.nuttx.ref }}
- if: ${{ steps.cache-nuttx.outputs.cache-hit != 'true' }}
name: Checkout NuttX (${{ matrix.nuttx.label }})
uses: actions/checkout@v4
with:
repository: apache/nuttx
path: "nuttxspace/nuttx"
ref: "${{ matrix.nuttx.ref }}"
- name: Cache NuttX Apps
id: cache-nuttx-apps
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/nuttxspace/apps
key: nuttx-apps_${{ matrix.nuttx.ref }}
- if: ${{ steps.cache-nuttx-apps.outputs.cache-hit != 'true' }}
name: Checkout NuttX Apps (${{ matrix.nuttx.label }})
uses: actions/checkout@v4
with:
repository: apache/nuttx-apps
path: "nuttxspace/apps"
ref: "${{ matrix.nuttx.ref }}"
- name: Install Kconfig dependencies
run: sudo apt-get update && sudo apt-get install -y kconfig-frontends
- name: Cache ARM GCC Toolchain
id: cache-arm-none-eabi
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/gcc-arm-none-eabi
key: ${{ env.arm_none_eabi_version }}
- if: ${{ steps.cache-arm-none-eabi.outputs.cache-hit != 'true' }}
name: Download ARM GCC Toolchain
run: |
mkdir gcc-arm-none-eabi
curl -s -L "https://developer.arm.com/-/media/Files/downloads/gnu/${{ env.arm_none_eabi_version }}.tar.xz" \
| tar -C gcc-arm-none-eabi --strip-components=1 -xJ
- name: Build ${{ matrix.board }}
run: |
export PATH="${{ github.workspace }}/gcc-arm-none-eabi/bin:$PATH"
KickCAT/scripts/build_slave_bin.sh \
${{ matrix.board }} \
${{ github.workspace }}/nuttxspace/nuttx
- name: Upload firmware binary for ${{ matrix.board }} (nuttx ${{ matrix.nuttx.label }})
uses: actions/upload-artifact@v4
with:
name: firmware-${{ matrix.board }}-nuttx-${{ matrix.nuttx.label }}
path: KickCAT/build_${{ matrix.board }}/*.bin
if-no-files-found: error
retention-days: 1
# Release
release:
needs: [build-wheels, simulation_test, build-conan-package, build_arm64]
if: startsWith(github.ref, 'refs/tags/') # Only run on tag pushes
runs-on: ubuntu-24.04
environment:
name: maintainer
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download wheels artifact
uses: actions/download-artifact@v4
with:
pattern: wheelhouse-kickcat-*
path: wheelhouse
merge-multiple: true
- name: Download Conan package artifact
uses: actions/download-artifact@v4
with:
name: conan-package
path: conan-package
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" wheelhouse/*.whl conan-package/*.tgz \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes
- name: Publish the wheels on PyPI
uses: pypa/gh-action-pypi-publish@v1.12.4
with:
packages-dir: wheelhouse
verify-metadata: true
attestations: true
print-hash: true
skip-existing: true