-
Notifications
You must be signed in to change notification settings - Fork 0
292 lines (255 loc) · 9.68 KB
/
ci.yml
File metadata and controls
292 lines (255 loc) · 9.68 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
python:
name: Python Tests & Lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Lint with ruff
run: ruff check python/
- name: Type check with mypy
run: mypy python/arbiter/
- name: Run tests
run: pytest tests/python -v
- name: Validate sample model
run: arbiterc validate samples/battery_policy/models/battery.arb.yaml --strict
- name: Profile validation — compile all samples on standard profile
run: |
for model in samples/*/models/*.arb.yaml; do
echo "--- $model ---"
arbiterc compile "$model" --profile standard --out-c /dev/null --out-h /dev/null
done
clang-tidy:
name: clang-tidy Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clang-tidy
run: sudo apt-get install -y --no-install-recommends clang-tidy
- name: Run clang-tidy on engine sources
run: |
clang-tidy \
lib/arbiter_engine.c \
lib/arbiter_eval.c \
lib/arbiter_fact_store.c \
lib/arbiter_trace.c \
lib/arbiter_blob.c \
lib/arbiter_action.c \
-- \
-I include \
-isystem tools/clang-tidy-stubs \
-std=c11 \
-DCONFIG_ARBITER_LOG_LEVEL=3 \
-DCONFIG_ARBITER_MAX_FACTS=64 \
-DCONFIG_ARBITER_MAX_ACTIONS_PER_EVAL=16 \
-DCONFIG_ARBITER_MAX_TRACE_ENTRIES=64 \
-DCONFIG_ARBITER_MAX_TRACE_INPUTS=8
spdx:
name: SPDX Header Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check SPDX headers
run: |
missing=0
for f in $(find lib/ include/ subsys/ python/ -name '*.c' -o -name '*.h' -o -name '*.py' | grep -v __pycache__); do
if ! head -5 "$f" | grep -q 'SPDX-License-Identifier'; then
echo "Missing SPDX header: $f"
missing=1
fi
done
exit $missing
misra:
name: MISRA-C Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cppcheck
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends cppcheck
- name: Run cppcheck with MISRA C 2012 rules
run: |
# cppcheck's MISRA addon may not be available on ubuntu-latest;
# fall back to built-in checks if the addon fails.
if cppcheck --addon=misra --version 2>/dev/null; then
cppcheck --addon=misra \
--suppress=misra-c2012-1.1 \
--suppress=misra-c2012-20.9 \
--suppress=misra-c2012-21.6 \
-I include/ \
-isystem tools/clang-tidy-stubs \
--error-exitcode=1 \
--inline-suppr \
lib/*.c
else
echo "MISRA addon not available — falling back to built-in checks"
cppcheck \
--enable=all \
--suppress=missingIncludeSystem \
-I include/ \
-isystem tools/clang-tidy-stubs \
--error-exitcode=1 \
--inline-suppr \
lib/*.c
fi
docs:
name: Doxygen API Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install doxygen
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends doxygen
- name: Generate API docs
run: doxygen Doxyfile
- name: Upload API docs
uses: actions/upload-artifact@v4
with:
name: api-docs
path: docs/api/html/
zephyr:
name: Zephyr Twister Tests
runs-on: ubuntu-latest
env:
# native_sim uses host GCC; skip cross-compiler toolchain lookup.
ZEPHYR_TOOLCHAIN_VARIANT: host
# Tell Zephyr's module system where arbiter lives. west skips
# cloning the manifest project to its declared module path, so
# ZEPHYR_EXTRA_MODULES is the clean solution. Now that the
# Kconfig symbol (ARBITER) and CMake guard (CONFIG_ARBITER) match,
# and sources use CMAKE_CURRENT_LIST_DIR, this resolves fully.
ZEPHYR_EXTRA_MODULES: ${{ github.workspace }}/app
steps:
- uses: actions/checkout@v4
with:
# west.yml declares self.path: app — match it so west module
# resolution works correctly alongside modules/lib/arbiter/
path: app
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install west
run: pip install west
# Cache the Zephyr tree and west state keyed on west.yml.
# All three paths are saved/restored together so a partial
# hit cannot leave the workspace in an inconsistent state.
- name: Cache west workspace
id: cache-west
uses: actions/cache@v4
with:
path: |
zephyr
modules
.west
key: west-${{ hashFiles('app/west.yml') }}
restore-keys: west-
# Only run init+update on a cache miss; .west/config is
# restored from cache and is sufficient for subsequent steps.
- name: West init
if: steps.cache-west.outputs.cache-hit != 'true'
run: west init -l app
# --narrow: only fetch projects in our top-level manifest
# (zephyr + arbiter), skipping Zephyr's full HAL set.
# -o=--depth=1: shallow clone to keep the runner fast.
# native_sim needs only the Zephyr core tree, no HALs.
- name: West update
if: steps.cache-west.outputs.cache-hit != 'true'
run: west update --narrow -o=--depth=1
# native_sim/native targets 32-bit by default; gcc-multilib provides
# the 32-bit glibc headers (bits/libc-header-start.h) on ubuntu-latest.
- name: Install native_sim build dependencies
run: sudo apt-get install -y --no-install-recommends gcc-multilib g++-multilib
- name: Install Zephyr Python requirements
run: pip install -r zephyr/scripts/requirements.txt
# Zephyr CMake requires find_package(Zephyr-sdk) even for native_sim
# (host tools: DTC, cmake config files). The minimal bundle is ~10 MB
# and contains no cross-compiler — only the cmake registration files.
# setup.sh -c writes ~/.cmake/packages/Zephyr-sdk/ so CMake finds it.
# SDK 1.0.1 matches pinned Zephyr v4.4.0 (Zephyr v4.4.0 requires >= 1.0.0).
# sdk-version file does not exist in v4.4.0; version is hardcoded here.
- name: Install Zephyr SDK (minimal, cmake files only)
env:
SDK_VER: "1.0.1"
run: |
wget -q \
"https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${SDK_VER}/zephyr-sdk-${SDK_VER}_linux-x86_64_minimal.tar.xz" \
-O /tmp/zephyr-sdk-minimal.tar.xz
mkdir -p ~/zephyr-sdk
tar -xf /tmp/zephyr-sdk-minimal.tar.xz --strip-components=1 -C ~/zephyr-sdk
~/zephyr-sdk/setup.sh -c
# Unit tests run as native executables on native_sim.
# -fstack-usage emits .su files for stack analysis.
- name: Twister — unit tests
run: |
west twister \
-T app/tests/unit \
-p native_sim \
--inline-logs -v \
-O twister-out/unit \
-- -DEXTRA_CFLAGS=-fstack-usage
- name: Check stack usage (max 512 bytes per function)
run: |
echo "--- Stack usage analysis ---"
err=0
while IFS= read -r sufile; do
while IFS=$'\t' read -r func bytes type; do
if [ "${bytes:-0}" -gt 512 ] 2>/dev/null; then
echo "STACK EXCEEDED: $sufile: $func $bytes $type"
err=1
fi
done < "$sufile"
done < <(find twister-out/unit -name '*.su' 2>/dev/null)
if [ $err -ne 0 ]; then
echo "::error::One or more functions exceed 512-byte stack limit"
exit 1
fi
echo "All functions within 512-byte stack limit"
# Benchmarks execute on native_sim; Twister captures timing output
# as an artifact. pass/fail is gated on the final log line regex.
- name: Twister — benchmarks
run: |
west twister \
-T app/tests/benchmarks \
-p native_sim \
--inline-logs -v \
-O twister-out/benchmarks
# Parse benchmark timing and print summary table.
# No fail threshold yet — we need baseline data first.
- name: Benchmark timing summary
if: always()
run: python app/tools/parse_benchmark.py twister-out/benchmarks/
# All 17 samples are build_only; CI proves they compile clean.
- name: Twister — samples
run: |
west twister \
-T app/samples \
-p native_sim \
--inline-logs -v \
-O twister-out/samples
- name: Upload Twister results
if: always()
uses: actions/upload-artifact@v4
with:
name: twister-results
path: twister-out/
- name: Upload stack usage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: stack-usage-reports
path: twister-out/**/*.su
if-no-files-found: ignore