Build and smoke-test the firmware simulator in CI #3

Merged
paudrow merged 1 commit from claude/wizardly-gates-q0o1df into main 2026-09-29 10:05:49 -05:00
paudrow commented 2026-09-29 09:21:20 -05:00 (Migrated from github.com)

Adds a simulator job to CI (GitHub and the identical Forgejo workflow). It keeps sim/clock.wasm, the firmware running on the 3D viewer's touchscreen, in step with src/main.cpp.

The job

  1. Installs Zig, pinned: pip install ziglang==0.16.0.
  2. Builds the firmware for the browser (python3 sim/build.py). If main.cpp starts using an M5Unified call the shim doesn't cover, this fails and names the call.
  3. Checks the committed sim/clock.wasm matches the source. A firmware change without a rebuilt simulator fails here, with a message saying what to run.
  4. Runs node sim/smoke_test.js at 616 × 284, 600 × 450 and 320 × 240. For each size it checks:
    • the clock face draws a time;
    • tapping the gear opens the menu;
    • 5,000 frames of random touches and time jumps cause no crash or invalid draw call;
    • saved settings load after a reboot.

Making the build reproducible

Step 3 needs the same source to always produce the same bytes. It didn't: main.cpp stamps a blank RTC with __DATE__/__TIME__, and that stamp was compiled in. The earlier "byte-identical" check only passed because Zig reused its cache.

build.py now sets SOURCE_DATE_EPOCH to pin the stamp. The simulator's RTC always has the time, so the stamp is never used there. clock.wasm is rebuilt with it.

Also in build.py: on a cold cache, Zig compiles its own libc++ and prints thousands of warning lines. The build now shows only warnings from our own files, and the full log only on failure.

Verified locally

  • Reproducible: identical bytes from a different checkout path, a cold Zig cache, and a fresh pip install into the system Python (the CI path).
  • Each failure mode caught, tested on a scratch copy:
    • Renaming a menu item without rebuilding fails the match check.
    • After a rebuild, the smoke test fails with tapping the gear didn't show "Sound".
    • Adding M5.Display.setRotation(1) fails the build with no member named 'setRotation' in 'SimDisplay'.
  • Smoke test passes on the real source at all three sizes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CL9u8wcccZXQeAVwboNhNa


Generated by Claude Code

Adds a `simulator` job to CI (GitHub and the identical Forgejo workflow). It keeps `sim/clock.wasm`, the firmware running on the 3D viewer's touchscreen, in step with `src/main.cpp`. ## The job 1. **Installs Zig**, pinned: `pip install ziglang==0.16.0`. 2. **Builds the firmware for the browser** (`python3 sim/build.py`). If `main.cpp` starts using an M5Unified call the shim doesn't cover, this fails and names the call. 3. **Checks the committed `sim/clock.wasm` matches the source.** A firmware change without a rebuilt simulator fails here, with a message saying what to run. 4. **Runs `node sim/smoke_test.js`** at 616 × 284, 600 × 450 and 320 × 240. For each size it checks: - the clock face draws a time; - tapping the gear opens the menu; - 5,000 frames of random touches and time jumps cause no crash or invalid draw call; - saved settings load after a reboot. ## Making the build reproducible Step 3 needs the same source to always produce the same bytes. It didn't: `main.cpp` stamps a blank RTC with `__DATE__`/`__TIME__`, and that stamp was compiled in. The earlier "byte-identical" check only passed because Zig reused its cache. `build.py` now sets `SOURCE_DATE_EPOCH` to pin the stamp. The simulator's RTC always has the time, so the stamp is never used there. `clock.wasm` is rebuilt with it. Also in `build.py`: on a cold cache, Zig compiles its own libc++ and prints thousands of warning lines. The build now shows only warnings from our own files, and the full log only on failure. ## Verified locally - **Reproducible:** identical bytes from a different checkout path, a cold Zig cache, and a fresh `pip install` into the system Python (the CI path). - **Each failure mode caught,** tested on a scratch copy: - Renaming a menu item without rebuilding fails the match check. - After a rebuild, the smoke test fails with `tapping the gear didn't show "Sound"`. - Adding `M5.Display.setRotation(1)` fails the build with `no member named 'setRotation' in 'SimDisplay'`. - **Smoke test passes** on the real source at all three sizes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01CL9u8wcccZXQeAVwboNhNa --- _Generated by [Claude Code](https://claude.ai/code/session_01CL9u8wcccZXQeAVwboNhNa)_
Sign in to join this conversation.
No description provided.