Repository navigation
347 lines (321 loc) · 15.1 KB
/
Copy pathpython-tests.yml
File metadata and controls
347 lines (321 loc) · 15.1 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
# Issue #904 — CI that actually runs the Python test suites.
#
# Three jobs:
#
# 1. "unit" — every PR + push to main. Fast, no browser: the flask
# test-client suites, the aim/ IK gates, the wire-parity suites,
# the renderer gates, the HinksPix controller suites, and the docs
# validators. ~7 min (measured 2026-09-24; the renderer and HinksPix
# steps added ~2 min to the ~5 before them).
#
# 2. "linux-install" — every PR + push to main (#948). Runs
# desktop/linux/install.sh in clean Ubuntu/Debian containers and
# drives the installed service as its non-root user.
#
# 3. "regression" — weekly cron (+ manual dispatch). Installs
# Playwright chromium and runs tests/regression/run_all.py (the
# stage-setup → layout → bake → 3D-runtime end-to-end flow), plus
# the HinksPix SPA suites (they render the served SPA in a real
# browser, so they need the chromium this job installs). NOT
# --live-rig: those suites need a calibrated physical mover + two
# camera nodes and self-skip when SLYLED_LIVE_RIG is unset.
#
# Data isolation (#907): SLYLED_DATA is set at the job level so no
# spawned parent_server can ever touch a real project dir. The suites
# below also self-isolate (tests/conftest.py, run_all.py), but the job
# env is what covers direct `python3 tests/test_foo.py` script runs.
name: python-tests
on:
pull_request:
paths:
- 'desktop/**'
- 'tests/**'
- 'main/**' # UDP protocol headers — wire-parity suites read these
- 'tools/docs/**'
- '.github/workflows/python-tests.yml'
push:
branches: [main]
paths:
- 'desktop/**'
- 'tests/**'
- 'main/**'
- 'tools/docs/**'
- '.github/workflows/python-tests.yml'
schedule:
- cron: '0 5 * * 0' # Sunday 05:00 UTC — weekly regression sweep
workflow_dispatch: {}
permissions:
contents: read
# Keyed on event_name too so a push to main never cancels a running
# weekly regression sweep (both would otherwise share refs/heads/main).
concurrency:
group: python-tests-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHONIOENCODING: utf-8
jobs:
unit:
if: github.event_name != 'schedule'
# #948 — the orchestrator is a first-class macOS/Linux platform; every
# unit suite runs on both. Docs validators stay Linux-only (they need
# apt's git-restore-mtime and are OS-independent anyway).
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
env:
SLYLED_DATA: /tmp/slyled-ci-data
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history: git restore-mtime needs commit dates
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/setup-node@v4
# The renderer-parity gate runs spa/js under node and prints
# [SKIP] (exit 0) without it — pin node so the macOS leg (#948)
# enforces parity instead of silently skipping.
with:
node-version: '20'
- name: Install dependencies
# No single requirements.txt covers the test surface —
# desktop/windows/requirements.txt includes Windows-only deps
# (pystray, sounddevice) that fail headless, and the docker
# image installs only flask+qrcode. This is the verified set the
# suites below pass with (mirrors a dev machine minus hardware
# extras); pyserial/paramiko/cryptography gate optional
# parent_server paths that test_parent.py exercises.
run: |
pip install "flask>=3.0" "qrcode>=7.0" requests numpy tzdata \
opencv-python-headless "cryptography>=41.0" pyyaml \
"paramiko>=3.0" "pyserial>=3.5" "psutil>=5.9" "esptool>=4.7" \
"waitress>=3.0"
- name: Restore commit-time file mtimes
if: runner.os == 'Linux'
# tools/docs/validate_screenshots.py's freshness check and
# drift_check.py's review-freshness check compare file mtimes.
# A fresh checkout stamps every file with checkout time (order
# effectively random), which makes both checks meaningless/
# flaky. git restore-mtime resets each file to its last-commit
# time, which is the semantic the checks want in CI.
run: |
sudo apt-get update -q
sudo apt-get install -y -q git-restore-mtime
git restore-mtime
- name: Core unit suites
# Each suite gets a FRESH data dir (overriding the job-level
# SLYLED_DATA): suites that seed fixtures (radar, calibration)
# pollute later suites' worlds if the dir is shared — observed
# locally as test_910 failing after test_913 in one shell.
run: |
for t in tests/test_persistence_atomic.py \
tests/test_893_cors.py \
tests/test_896_fused_id_rebind.py \
tests/test_mmwave_wire_parity.py \
tests/test_899_fixture_registry.py \
tests/test_900_fusion_sources.py \
tests/test_901_udp_dispatch.py \
tests/test_910_mmw_handler.py \
tests/test_911_radar_fixture.py \
tests/test_912_radar_fusion.py \
tests/test_913_radar_calibration.py \
tests/test_b2_serving.py \
tests/test_platform_paths.py \
tests/test_net_ifaces.py \
tests/test_firmware_platform.py \
tests/test_platform_smoke.py \
tests/test_linux_packaging.py \
tests/test_send_recv_handoff.py \
tests/test_870_ota_app_only.py \
tests/test_camera_bump_version.py \
tests/test_no_bom.py \
tests/test_bootstrap_guard.py \
tests/test_965_remote_ollama.py \
tests/test_966_peer_orchestrators.py \
tests/test_966_two_orchestrators.py \
tests/test_web_http.py \
tests/test_30_combos.py; do
echo "== $t"
SLYLED_DATA=$(mktemp -d) python3 -X utf8 "$t"
done
- name: Show scheduler suites (#954)
# solar + the pure evaluator + the engine with a fake clock, then
# the routes/integration suite (sACN routed to 127.0.0.1; asserts
# no dark frame across a show→wash hand-off). The browser half,
# test_schedule_spa.py, runs with chromium below.
run: |
for f in tests/test_solar.py tests/test_schedule_eval.py \
tests/test_schedule_engine.py tests/test_schedule_routes.py \
tests/test_schedule_compile.py tests/test_schedule_offline.py \
tests/test_963_offline_eligibility.py; do
echo "== $f"
SLYLED_DATA=$(mktemp -d) python3 -X utf8 "$f"
done
- name: Renderer gates (tests/test_pixel_renderer*.py)
# The Python renderer and its byte-identical twin in the SPA.
# test_pixel_renderer_parity.py runs spa/js/pixel_renderer.js
# under node and compares 3024 cases pixel by pixel — it is the
# only thing enforcing that the two renderers agree, and it
# was in no workflow until now.
#
# Verified it is a real gate before wiring it: a forced mismatch
# exits 1, and with node off PATH it prints [SKIP] and exits 0
# rather than a false red. ubuntu-latest ships node, so the
# parity half actually runs here.
run: |
for f in tests/test_pixel_renderer.py tests/test_pixel_renderer_parity.py; do
echo "== $f"
SLYLED_DATA=$(mktemp -d) python3 -X utf8 "$f"
done
- name: HinksPix suites (tests/test_hinkspix_*.py)
# The controller suites run against in-process fakes on
# 127.0.0.1 — no hardware, no network, nothing reached. Each
# gets its own data dir for the same reason as the core
# suites; they are also re-runnable in a shared one since #945
# (fresh_store()), but the fresh dir is what CI has always
# done and costs nothing.
#
# *_spa.py is skipped here: those two render the served SPA in
# a real browser (unguarded playwright import), so they run in
# the regression job where chromium is installed.
run: |
for f in tests/test_hinkspix_*.py; do
case "$f" in
*_spa.py) continue ;;
esac
echo "== $f"
SLYLED_DATA=$(mktemp -d) python3 -X utf8 "$f"
done
- name: Aim gates (tests/aim/)
run: |
python3 -X utf8 tests/aim/test_sphere.py
python3 -X utf8 tests/aim/test_stage_frame.py
python3 -X utf8 tests/aim/test_profile_mechanics.py
python3 -X utf8 tests/aim/test_routes.py
- name: Wire-parity suites (tests/test_parity_*.py)
# Glob loop must tolerate matching nothing — the parity corpus
# is still being added to.
run: |
for f in tests/test_parity_*.py; do
[ -e "$f" ] || continue
echo "== $f"
python3 -X utf8 "$f"
done
- name: test_parent.py (exact total, network skips only)
# #942: the total is fixed. Every branch-gated check records a
# skip() instead of vanishing, and the data dir is always fresh, so
# test_parent.py emits exactly EXPECTED assertions on any machine.
# This step fails on ANY failure, on a total other than EXPECTED
# (a test was added or removed: update EXPECTED in the same
# commit), or on a skip outside NETWORK_SKIPS (a precondition that
# should always hold did not).
run: |
SLYLED_DATA=$(mktemp -d) python3 -X utf8 tests/test_parent.py | tee "$RUNNER_TEMP/test_parent.out" || true
python3 - "$RUNNER_TEMP/test_parent.out" <<'EOF'
import io, re, sys
EXPECTED = 782
NETWORK_SKIPS = {
"Firmware check has latest version",
"OTA trigger returns board=esp32",
"OTA trigger returns version",
}
out = io.open(sys.argv[1], encoding="utf-8").read()
summary = re.search(r"(\d+) passed, (\d+) failed, (\d+) skipped out of (\d+) tests", out)
if not summary:
sys.exit("test_parent.py produced no summary line — suite crashed?")
passed, failed, skipped, total = map(int, summary.groups())
fails = [m.group(1).rstrip()
for m in re.finditer(r"^\s*\[FAIL\] (.+?)(?: \(.*)?$", out, re.M)]
skips = [m.group(1).rstrip()
for m in re.finditer(r"^\s*\[SKIP\] (.+?)(?: \(.*)?$", out, re.M)]
print(f"summary: {passed} passed, {failed} failed, {skipped} skipped of {total}")
problems = []
if fails:
problems.append("failures:\n " + "\n ".join(fails))
if total != EXPECTED:
problems.append(f"total {total} != EXPECTED {EXPECTED}")
bad_skips = [s for s in skips if s not in NETWORK_SKIPS]
if bad_skips:
problems.append("unexpected skips:\n " + "\n ".join(bad_skips))
if problems:
sys.exit("\n".join(problems))
print("test_parent.py OK")
EOF
- name: Docs — screenshot validation
if: runner.os == 'Linux'
# --skip-freshness: any SPA edit stales every capture until a
# live-rig recapture; the weekly strict run keeps that reminder.
run: python3 tools/docs/validate_screenshots.py --skip-freshness
- name: Docs — drift parity checks
if: runner.os == 'Linux'
# --mode parity = EN↔FR filename parity + FR review freshness
# (deterministic; needs the restored mtimes above). The PR-diff
# drift nudge already runs in docs-drift.yml — not duplicated
# here.
run: python3 tools/docs/drift_check.py --mode parity
linux-install:
# #948 Phase 2 — desktop/linux/install.sh in clean containers: the
# supported floor (22.04 / Bookworm, python 3.10/3.11) and the newest
# target (26.04, python 3.14 — what the kdocker3 bench runs). The test
# starts the unit's own ExecStart as its own User= and checks /status,
# data placement, SIGKILL persistence and --uninstall/--purge.
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
image: ['ubuntu:22.04', 'debian:bookworm', 'ubuntu:26.04']
steps:
- uses: actions/checkout@v4
- name: install.sh in ${{ matrix.image }}
run: python3 -X utf8 tests/test_linux_install_docker.py --image '${{ matrix.image }}'
regression:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 60
continue-on-error: false
env:
SLYLED_DATA: /tmp/slyled-ci-data
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install "flask>=3.0" "qrcode>=7.0" requests numpy tzdata \
opencv-python-headless "cryptography>=41.0" pyyaml \
"paramiko>=3.0" "pyserial>=3.5" playwright
playwright install --with-deps chromium
- name: Docs — screenshot validation incl. freshness (warnings)
# All four checks. Freshness is reported as warnings (#898): any SPA
# change stales every capture until the next recapture, and the
# rig-only shots (walkthrough, calibration, Android) wait for a rig
# session. Broken links, orphans and weak alt text still fail.
run: |
sudo apt-get update -q && sudo apt-get install -y -q git-restore-mtime
git restore-mtime
python3 tools/docs/validate_screenshots.py --warn-freshness
- name: HinksPix SPA suites (tests/test_hinkspix_*_spa.py)
# The browser half of the HinksPix set. Both stub the
# orchestrator's fetch and drive the real served SPA, so they
# belong with chromium rather than in the unit job; the other
# eight suites run there per-PR instead.
run: |
for f in tests/test_hinkspix_*_spa.py tests/test_schedule_spa.py tests/test_880_profiles_spa.py \
tests/test_963_offline_spa.py tests/test_965_remote_ollama_spa.py \
tests/test_966_peer_banner_spa.py \
tests/test_edit_rotation.py tests/test_unified_3d.py; do
echo "== $f"
SLYLED_DATA=$(mktemp -d) python3 -X utf8 "$f"
done
- name: Regression suite (stage setup → layout → bake → 3D runtime)
# run_all.py spawns one parent_server per suite and the
# Playwright suites drive headless chromium against it — fully
# self-managed, no external display or rig needed. Live-rig
# suites self-skip (no --live-rig / SLYLED_LIVE_RIG here).
run: python3 -X utf8 tests/regression/run_all.py