Skip to content

ci: test across optimize modes, add a format gate, harden the workflow - #5

Merged
itsakeyfut merged 3 commits into
mainfrom
ci/reliability-matrix
Jul 23, 2026
Merged

ci: test across optimize modes, add a format gate, harden the workflow#5
itsakeyfut merged 3 commits into
mainfrom
ci/reliability-matrix

Conversation

@itsakeyfut

@itsakeyfut itsakeyfut commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Harden CI so codegen-dependent bugs surface continuously: run the suite across four optimize modes on both runnable OSes, add a zig fmt gate, per-job timeouts, and cancel-in-progress concurrency. CI-config only — no source or build.zig changes.

Changes

  • Optimize matrixos: {ubuntu-latest, windows-latest} × optimize: {Debug, ReleaseSafe, ReleaseFast, ReleaseSmall} (8 cells, fail-fast: false). The inline-asm context switch is sensitive to optimization; ReleaseSafe also adds Zig's safety checks on optimized code. Each cell runs zig build and zig build test with -Doptimize=<mode>.
  • Format gate — a separate fmt job running zig fmt --check ..
  • Timeoutstimeout-minutes: 10 on both jobs. A broken switch hangs a while (state != .done) resume loop rather than crashing, so without a timeout a hung cell would inherit GitHub's 6-hour default.
  • Concurrency — top-level cancel-in-progress so superseded runs stop instead of finishing the 8-cell matrix.

macOS stays excluded (x86_64-only library; GitHub macOS runners are ARM64), with the reason kept as an inline comment on the matrix.

Notes

Deliberately out of scope: cross-target compile checks (Zig lacks bundled BSD libc; the only supported x86_64 targets are already exercised), sanitizers (high cost/noise on a hand-swapped custom stack), and supply-chain hardening (permissions: / SHA-pinned actions — a separate future concern). No CHANGELOG entry (dev-infra).

Test Plan

  • zig build -Doptimize=<mode> and zig build test -Doptimize=<mode> pass locally for all four modes (Windows)
  • zig fmt --check . passes
  • All 8 test cells + the fmt job green in CI (the matrix is proven here)

Catch codegen-dependent bugs (the inline-asm context switch is sensitive to
optimization) by running the suite in Debug, ReleaseSafe, ReleaseFast, and
ReleaseSmall on ubuntu-latest and windows-latest. Add a zig fmt --check gate,
a 10-minute per-job timeout (a broken switch hangs a resume loop rather than
crashing), and cancel-in-progress concurrency so superseded runs stop.
@itsakeyfut itsakeyfut self-assigned this Jul 23, 2026
The new optimize-mode CI matrix surfaced a crash: the FP-control test's
getMxcsr helper returned a value with spurious reserved bits (16-31) set under
optimized codegen on x86_64-linux (the Debug build and every Windows mode were
clean), and setMxcsr then fed it to ldmxcsr, which raises #GP if any reserved
bit is set. MXCSR only defines bits 0-15, so mask the value on both read and
write. This is a test-helper fix only: the library's SysV switch uses raw naked
asm over already-clean values and is unaffected.
The mask alone did not stop the crash: the #GP was the ldmxcsr memory operand's
ADDRESS, not its value. Zig 0.16 lowers the candidate operand forms
inconsistently on x86_64-linux — the "m"/"=m" constraint yields a wrong
address under optimized codegen (runtime #GP), while the (%reg) dereference form
fails to assemble in Debug (invalid memory operand). Move rsp below the red zone
with lea (flags untouched), address the scratch as (%rsp), and pass values in
register operands, dodging operand lowering entirely.

Verified locally by cross-compiling the tests to x86_64-linux (all four optimize
modes compile) and running natively on Windows (all four pass).
@itsakeyfut
itsakeyfut merged commit 1f370c3 into main Jul 23, 2026
9 checks passed
@itsakeyfut
itsakeyfut deleted the ci/reliability-matrix branch July 23, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant