feat(run): keep a timings history that CI can cache
e2e run already starts the longest files first, but it read the previous run's durations from report.json, which a fresh CI checkout never has. This writes a small versioned history a CI cache can restore and save.
- Every run that reaches its tests writes
<output>/timings.json(timings-1):target::fileto milliseconds. It merges into the existing file with a moving average (a run moves an entry a third of the way), and drops files that are gone and targets the config no longer has. - A file is timed only when the run carried out all of it, once. A
--grep,--last-failed, interrupted (including a retry cut short after a failure), or limit-cut run leaves that file's entry alone, and repeats past the first do not count. - A key is a target name, then a project-relative POSIX file with no
..segment. The schema and the reader use the same pattern, and a table test keeps them in step. - With one worker the file is still written, but files are ordered only with more than one. Files with no recorded time start first, then the rest longest first.
- Advisory: a missing, corrupt, or schema-invalid file is no history, never an error. An absent file falls back to
report.json, so nothing regresses. A restored cache can reorder files, never change a result. --timings <file>moves it.--last-failedstill readsreport.jsononly.- Docs:
actions/cacherecipe indocs/ci/github-actions.mdx(the key ends ingithub.run_attempt, since a rerun sharesrun_idandactions/cachenever overwrites a key), the provider-neutral rule indocs/ci.mdx.timings.jsonjoins thee2e initand repo.gitignoreentries. - Wire format:
schema/timings-v1.schema.jsonwith a valid and an invalid fixture, in the same change as the producer.
Not here: duration-balanced --shard, a timings.file config key, and dogfooding the recipe in benchmark.yml.
flowchart LR
A[restore .e2e/timings.json] --> B[e2e run: longest files first]
B --> C[merge measured files into history]
C --> D[save .e2e/timings.json]
Refs ENG-1111
Verified
Ran it locally: yes
- testbed, built CLI,
e2e run tests/check.e2e.ts tests/click.e2e.ts tests/controls.e2e.ts tests/browser.e2e.ts --workers 2, once with no history and once seeded with thetimings.jsonthe first run wrote:
| no history | with timings.json | |
|---|---|---|
controls (16 s file) starts | 2.5 s | 0 s |
click (14 s file) starts | 1.3 s | 0 s |
check, browser (short) start | 0 s | 14 s, 16 s |
| run | 19.4 s | 17.5 s |
One run per cell on one machine, so the size of the gain is indicative. The order is the point.
- Same CLI, edge cases: a valid-JSON file with another schema version, a string value, an array, or a
__proto__key is ignored and rewritten, tests still pass. ANO_TESTSrun writes nothing.--last-failedreadsreport.json, nottimings.json(NO_LAST_RUNwith only a timings file). An unwritable--timingspath is one stderr line and exit 0.--grepon one test leaves the file byte for byte unchanged. pnpm check,pnpm test, the testbed suite (587 passed), and the web benchmark (91 passed) are green locally.pnpm testran before the review fixes; after them I reranpnpm check, the unit suite (3447 passed), the new integration file, and the testbed ordering check. CI is green on the final head.- Not verified: the GitHub Actions recipe against a real workflow, and that a PR can read the base branch's cache but not write it. The page states GitHub's documented rule; I did not run it.
Review
A fresh-context review found two things, both fixed in the second commit (cubic-dev-ai then raised nine smaller points, all fixed in the third and fourth): partial runs wrote non-comparable durations (a --last-failed rerun of one 2 s test cut a 60 s entry to about 40 s), and nothing tested the runner wiring. The new integration test fails with the partial guard removed. The review also noted --timings is not confined to the project root like --output; left as is, since the path is one the user names on their own command line and test code already runs with full authority.
CI notes
packages/acpexecutor.test.ts"retries the session directory removal after the agent exits" failed ontest (22),(24), and(22.22.3)in earlier runs of this PR (kill ESRCHafter a 500 ms wait), and onoskar/fix-main-failing-testsbefore it. It does not reproduce locally and this PR does not touchpackages/acp; reruns passed. It needs its own fix.- The Android agentic
Huge Virtualized Liststep failed once withREPLAY_STALEand passed on rerun, with nothing in this diff that reaches it.
š¤ Generated with Claude Code