Repository navigation
ci: portable test bundles from ctest json-v1 + serial runner (#277 phase A) - #279
Conversation
14f88f1 to
8bd70e4
Compare
|
Heads-up on the red
The fix already exists, unmerged, on Worth noting for #277 or a follow-up: a gate whose path filter excludes the files that can break it is the same shape as the seven dead gates in docs/ci-gates.md. |
No workflow in this repo had a `concurrency` group, so every push to a PR
branch left the previous push's jobs queued and competing for the same
runners. Measured over the last 20 runs, `cross.yml`'s Apple rows executed
in 8-9 seconds and waited up to 5h26m (arm64) and 6h13m (Intel).
Every workflow now declares one. `cancel-in-progress` is true only where a
cancelled run costs nothing but the answer it would have given:
true amalgamation-drift, asan, benchmark-sentinel, c-unit, cross,
doc-snippets, fuzz, python-lint, rust-native, zero-tracking
false auto-release (already), release, stale, star-history (already),
and the four benchmark-* producers (already, and they deliberately
share one `benchmark-stats-production` group to serialise against
each other -- left untouched)
Three of those deserve a note:
* release.yaml arrived from upstream with cancel-in-progress: true while
uploading release assets. Flipped: a cancelled run leaves the release
half-populated.
* stale.yaml closes and labels issues and PRs; a half-run leaves the repo
partly swept.
* fuzz.yml has a `schedule:` trigger, and a scheduled run carries
ref=refs/heads/main. Its group includes github.event_name so the nightly
2,000,000-iteration run and a main push cannot cancel each other.
docs/ci-gates.md gains the policy and the measured numbers behind it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
`ci/ci_queue_wait.py` is the before/after instrument for the concurrency change: for the last N runs of the given workflows it reads the Actions API through `gh` and prints, grouped by the job's `labels` (what `runs-on:` resolved to), p50/p90/max of `started_at - created_at` (queue wait) and `completed_at - started_at` (execution), plus the job count. Fetching is separated from arithmetic so the unit tests drive `parse_jobs`, `percentile` and `summarise` from a fixture in the real `/actions/runs/<id>/jobs` shape; `--jobs-json` replays that same fixture through the CLI, so nothing in the test suite touches the network. One caveat is documented in the tool and in docs/ci-gates.md rather than papered over: a job with `needs:` is created when the run is created, so a `cross.yml` `test (*)` row measures pool wait plus upstream build time. `c-unit.yml` and `rust-native.yml` have no `needs:` edges and measure pool wait alone. Cancelled and skipped jobs are excluded -- a cancelled job's completed_at is when the cancellation landed, not when work finished -- while failed jobs are kept, because a red job still occupied a runner for its whole execution. ruff, `ruff format --check` and `pyright --strict` (0 errors) all pass. pyright needed `uv run --with 'pyright[nodejs]==1.1.411' pyright`: the `[nodejs]` extra ships its own Node, which is what makes it runnable on a box with none. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
…ase A) #277 wants the macOS and Windows test binaries built once on Linux and executed on one runner per OS. That needs a *test bundle*: a directory a runner can execute with no CMake and no repo checkout. This is the format and the two scripts that produce and replay it. `ci/bundle_tests.py <build-dir> <out-dir> [--config C]` runs `ctest --show-only=json-v1` and writes `tests.json` (name, argv, env, cwd, timeout, expect_nonzero, expect_text, labels) plus every referenced executable and every `libmimalloc*` / `mimalloc*.dll` / `mimalloc-redirect*.dll`. ctest does not emit a list of plain executables. On the MI_DEBUG_FULL tree 7 of 31 tests invoke `cmake` itself, and both shapes are lowered into manifest fields so the runner needs no CMake: * `cmake -E env K=V ... <exe>` -> `env` + the real argv (test-stress-dynamic sets MIMALLOC_VERBOSE and LD_PRELOAD this way) * `cmake -D... -P test/run-negative.cmake` -> argv, expect_nonzero, expect_text, timeout 10 -- the 6 negative controls The negative-control semantics are copied from test/run-negative.cmake exactly, including the part that is easy to get backwards: a timeout is a FAILURE, not the expected non-zero exit ("negative control timed out instead of failing fast"), and the expected substring is searched in the combined stdout+stderr so a control that fails for the wrong reason stays red. Absolute build-tree paths appear in argv AND in env values, so both are rewritten to a `${BUNDLE}` placeholder the runner expands, and the files are flattened into the bundle root -- a Windows DLL must sit beside its exe, and a flat directory is what lets LD_LIBRARY_PATH/DYLD_LIBRARY_PATH override the build-tree RPATH baked into the executables. A basename collision is a hard error, never a silent overwrite. Everything the bundler cannot lower is a hard error naming the test: an unknown `cmake` argv shape, a `cmake -E env` option, an unrecognised run-negative variable, a test property outside the allowlist (ENVIRONMENT, TIMEOUT, WORKING_DIRECTORY, LABELS, WILL_FAIL, DISABLED), an executable outside the build tree, and an empty suite. A bundle that quietly carries fewer tests than ctest ran would report green while verifying less, which is exactly the failure mode docs/ci-gates.md exists to prevent. `ci/run_test_bundle.py <bundle>` replays serially with a ctest-shaped summary, `--only`, `--env`, `--timeout-scale`, `--junit`, and `--compare-junit`, which asserts the same test names and the same pass/fail as a `ctest --output-junit` run. Comparing JUnit rather than parsing LastTest.log keeps the comparison deterministic and testable from fixtures. Verified locally, in both cases with the build tree renamed away first so the RPATH cannot rescue a broken bundle: Debug MI_PPROF=ON MI_DEBUG_FULL=ON 31/31 passed, same 31 names as ctest Release MI_PPROF=ON 24/24 passed, same 24 names as ctest Correction to #277 for the record: the issue says "12 of 32 tests invoke cmake: 6 `cmake -E env` and 6 `-P run-negative.cmake`". The MI_DEBUG_FULL tree has 31 tests of which 7 invoke cmake -- 6 negative controls and 1 `cmake -E env`. The Release tree has 24 tests and none. pyright --strict could not be run locally (no Node); python-lint is the check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
The bundle format is only worth anything if the bundle runs exactly the tests ctest runs and gets exactly the same results. This job proves it on the config where every awkward command shape lives -- MI_DEBUG_FULL is the only one that emits `cmake -P run-negative.cmake` controls and the `cmake -E env` LD_PRELOAD wrapper. Sequence: configure/build, `ctest --output-junit ctest.xml` as the reference, bundle, **move the build tree away**, replay with `--compare-junit`. The `mv` is load-bearing: the executables carry an RPATH into the build tree, so without it a broken bundle would pass on the build machine by loading the original libraries and the portability claim would go untested on the only machine that can check it. The bundle and both JUnit files are uploaded as an artifact. Uses `python3` like every other workflow here; the scripts are stdlib-only, so `uv run ci/run_test_bundle.py` behaves identically. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
`field(default_factory=dict)` hands strict mode a `dict[Unknown, Unknown]` factory even when the field is annotated `dict[str, str]`. PEP 585 generics are callable at runtime on the oldest Python this repo targets, so `default_factory=dict[str, str]` is both correct and checkable. Verified with `uv run --with 'pyright[nodejs]==1.1.411' pyright` (0 errors) -- the `[nodejs]` extra ships its own Node, which is what made pyright runnable on a machine with none. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
`ctest --output-junit` resolves a relative path against the **build directory**, not the working directory. The bundle-roundtrip job wrote `ctest.xml`, which landed in `build/`, and then `mv build build.moved-away` carried the reference off with it -- so the comparison step died on a bare FileNotFoundError from inside ElementTree. The bundle itself was fine: it ran 31/31 green with the build tree gone, which is the thing the job exists to prove. Two changes: the workflow passes `$GITHUB_WORKSPACE/ctest.xml`, and `run_test_bundle.py` now names the gotcha instead of letting a stack trace out. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
`ci/verify_local.py` landed on main (#276) with a drift gate that fails when a Linux CI job references a `ci/*.py` script the local mirror does not, so the new `bundle-roundtrip` job needs a matching config -- which is the useful outcome anyway: `uv run ci/verify_local.py --only bundle` now reproduces the whole gate locally. The runner mirrors the job 1:1: configure, build, reference `ctest --output-junit` (absolute path -- ctest resolves a relative one against the build directory), bundle, move the build tree away, replay with `--compare-junit`, move it back. `exclude_slow=False` regardless of `--slow`, because a comparison against a partial reference proves nothing. `ctest_run` gains a `junit=` parameter; it resolves the path so no caller can hit the relative-path trap. Measured here: `bundle PASS 103.6s`, 32/32 in both the reference and the bundle, "same 32 test names, same results". Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
aff4dfb to
efd5522
Compare
|
Opus review: APPROVE. Roundtrip re-run by the reviewer: Debug FULL 32/32 and Release 25/25, bundle matches ctest by name and result both ways; zero absolute paths in the produced Follow-ups filed on #277 (Phase A polish, before Phase B ships bundles cross-host):
Merging with macOS jobs still queued for the same reason as #278. |
Phase A of #277: the portable test-bundle format, the two scripts, and the gate that
proves a bundle runs exactly what ctest runs.
What a bundle is
A directory a macOS or Windows runner can execute with no CMake and no repo checkout:
every test executable, every
libmimalloc*/mimalloc*.dll/mimalloc-redirect*.dll,and a
tests.jsonmanifest.One entry per test:
name,argv,env,cwd,timeout,expect_nonzero,expect_text,labels.Lowering rules
ctest --show-only=json-v1does not emit a list of plain executables. Bothcmakeshapes are lowered into manifest fields so the runner needs no CMake:
cmake -E env K=V … <exe> [args]env+ the realargv;K=Vtokens consumed up to the first token that is not onecmake -D TEST_EXE=… -D TEST_ARG=… -D EXPECTED_TEXT=… -P test/run-negative.cmakeargv = [TEST_EXE, TEST_ARG?],expect_nonzero: true,expect_text: EXPECTED_TEXT,timeout: 10The negative-control semantics come straight from
test/run-negative.cmake, including thetwo that are easy to get backwards:
"negative control timed out instead of failing fast". A hung control proves nothing.
for the wrong reason stays red (
"failed for the wrong reason (result=…)"upstream).TEST_ARGis optional; the effective timeout is the cmake script's 10 s, not the test'sTIMEOUT 15.Failing loudly
Everything the bundler cannot lower is a hard error naming the test, and all problems
are reported in one message rather than one per run:
cmakeargv shape (cmake -E rm, an unrecognised-Pscript)cmake -E envoption (--unset=,--modify) rather than a plain assignmentrun-negative.cmakevariableENVIRONMENT,TIMEOUT,WORKING_DIRECTORY,LABELS,WILL_FAIL,DISABLED.PASS_REGULAR_EXPRESSION,SKIP_RETURN_CODE,RESOURCE_LOCKand friends are refused, not silently dropped.The reason is the one
docs/ci-gates.mdis built around: a bundle that quietly carriesfewer tests than ctest ran reports green while verifying less. That is precisely the shape
of all seven dead gates this repo has already found.
Path handling
Absolute build-tree paths appear in argv and in env values (
LD_PRELOAD=/abs/build/…,DYLD_INSERT_LIBRARIES=/abs/build/…); both are rewritten to a${BUNDLE}placeholder therunner expands. Files are flattened into the bundle root, because a Windows DLL must
sit beside the exe that loads it and a flat directory is what lets
LD_LIBRARY_PATH/DYLD_LIBRARY_PATHoverride the build-tree RPATH baked into theexecutables. Symlinks are recreated as symlinks so the
libmimalloc-debug.so → .so.3 → .so.3.4SONAME chain survives.The
bundle-roundtripjob (c-unit.yml, ubuntu)MI_PPROF=ON MI_DEBUG_FULL=ON, mirroring the existingctest-debug-fullubuntu row:configure → build →
ctest --output-junit ctest.xml(the reference) → bundle →mv build build.moved-away→ replay with--compare-junit. The bundle and both JUnit files uploadas an artifact.
The
mvis the load-bearing step. The executables carry an RPATH into the build tree, sowithout it a broken bundle passes on the build machine by loading the original libraries
and the portability claim goes untested on the only machine that can check it.
--compare-junitcompares againstctest --output-junitrather than parsingLastTest.log: it is a stable documented format, so the comparison is deterministic andtestable from fixtures. It asserts the same name set and the same pass/fail per test.
Local verification (this machine, Linux x86-64)
Both runs had the build tree renamed away before replaying:
Corrections to #277
MI_DEBUG_FULLtree, 12 of 32 tests invokecmake: 6 arecmake -E envand 6 arecmake -P run-negative.cmake". Actual: 31 tests, 7 of whichinvoke
cmake— 6 negative controls plus exactly onecmake -E env(
test-stress-dynamic). The Release tree has 24 tests and none. The lowering rules theissue asks for are all still needed; only the counts were off.
WILL_FAILand noPASS_REGULAR_EXPRESSIONin use; the liveproperties are
ENVIRONMENT,TIMEOUT,WORKING_DIRECTORY; absolute paths really doappear in env values.
WILL_FAILandDISABLEDare implemented anyway, since they areone line each and the alternative is a future
add_testbreaking the bundler.Tests and checks
ci/tests/test_test_bundles.py, 42 tests: the two lowering rules, every refusal path,path relativisation in argv and in env (
LD_PRELOADandDYLD_INSERT_LIBRARIES),basename collisions, the negative-control semantics end to end (wrong reason → red, zero
exit → red, timeout → red even with
expect_nonzero), loader-path injection,--only/--env/--timeout-scale/--junit/--compare-junit, and a roundtrip on a tinyfake bundle whose build tree is deleted before replay.
pytest ci/tests: 139 passed, 0 failed.ruff check ci/+ruff format --check ci/clean on the CI pin (0.12.10).pyright --strictis clean. It initially could not run here (no system Node);uv run --with 'pyright[nodejs]==1.1.411' pyrightships its own Node and works, which caught fourreal strict errors that are fixed in the last commit. That command is worth knowing for
anyone else hacking on
ci/from a Node-less box.uv run ci/verify_local.py --list—ci/verify_local.pydid not exist onmainwhenthis work started; feat: bump upstream overlay pin to 6def7be9 (Bun merge-base) + glibc 2.44 free(NULL) fix #276 landed it mid-flight, along with a drift gate that fails when a
Linux CI job references a
ci/*.pythe local mirror does not. Sobundle-roundtripnowhas a matching
bundleconfig, and the gate is reproducible locally:python3, matching every existing workflow here; the scripts are stdlib-only, souv runbehaves identically.One CI-only bug this caught
The first CI run failed and it was worth having:
ctest --output-junitresolves arelative path against the build directory, not the working directory, so the
reference
ctest.xmllanded inbuild/and themvcarried it away. Locally the roundtriphad always been run with an absolute path, so it never showed. The workflow now passes
$GITHUB_WORKSPACE/ctest.xml,run_test_bundle.pynames the gotcha instead of leaking anElementTree stack trace,
ctest_run()inverify_local.pyresolves the path so no callercan repeat it, and there is a test. The bundle itself ran 31/31 green with the build tree
gone on that failing run — the thing the job exists to prove.
Not in scope
No toolchain work: the cross lanes are phase B/C/D (soldr lanes, #277 §2). Nothing outside
ci/,.github/workflows/c-unit.ymlanddocs/ci-gates.mdis touched, so rule 2 holds.Refs #277.
🤖 Generated with Claude Code
https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S