Public: anyone can read this; the crew can change it.

Every gate run times each test and names those over the budget (20 s a file, 2 s a test); a breach is red on the fast tier for files the pull changed #12110

Parked opened this
Closed without merging

Every gate run now times each test as well as each file, and holds both to a budget: 20 s for a file, 2 s for a single test. A breach fails the check only on the fast tier, and only in a test file the pull changed. On the full tier it is reported and does not fail the check; the next step of #1242 turns that on.

Notes

opened this

Every gate run now times each test as well as each file, and holds both to a budget: 20 s for a file, 2 s for a single test. A breach fails the check only on the fast tier, and only in a test file the pull changed. On the full tier it is reported and does not fail the check; the next step of #1242 turns that on.

Expect this pull's check to be red because of main, not this change. Main currently fails tests this change doesn't touch. Run on this tree, these three fail:

  • test/header-width.test.ts: over-wide header comments in src/web/pages/home_flow.ts, src/flow/lanes*.ts and test/surfaces-adversarial.test.ts.
  • test/cookie-flags.test.ts: two tests.

Other open pulls (e.g. #12099) also fail different tests from main. Any change under scripts/ puts a pull on the full tier, and the check only clears a red main shares on the fast tier, so these reds will count here. I did not fix them in this pull: they are outside the issue, and the earlier attempt that tried to fix them (#12091) still went red.

What changed

  • scripts/test-budget.ts (new), plain data in and out:
    • breaches({files, tests}, slow) returns each file over 20 s and each test over 2 s. It sets aside files listed in SLOW, and also returns the five slowest tests with their share of all the tests' time.
    • budgetBinds(tier, changed, file) decides whether a breach fails the run.
    • budgetLines writes the summary lines.
    • parseJunit reads Bun's JUnit report. Bun escapes the describe-block name twice, so it is decoded twice.
  • scripts/gate.ts: adds SLOW (file → issue number and reason), empty for now.
  • scripts/test-shards.ts:
    • Each bun test it starts also writes --reporter=junit --reporter-outfile=<shard dir>/junit-N.xml. If you pass a --reporter of your own, this is skipped.
    • A file run on its own is timed by its process; a file sharing a shard is timed by adding up its tests.
    • The summary now ends with the five slowest tests, then over the budget: N, SLOW aside: M, then each breach marked red:, said: or SLOW:.
    • A green run merges the per-test times into .forge-cache/test-times-tests.json.
    • A breach that binds fails the run with a line naming the rule.
  • test/test-budget-run.test.ts checks the rules on fixture times, with no real test run:
    • a run under budget passes;
    • a file over 20 s and a test over 2 s are named;
    • a SLOW file is set aside;
    • the five slowest are picked with their share;
    • a full-tier breach, or one in a file the pull didn't change, does not fail;
    • SLOW entries are sound;
    • the JUnit report parses correctly.

Checks run

  • I checked the flags against Bun 1.3.14: the console still prints its (fail) and Ran N tests across M files lines with the JUnit report on, so the output the check already reads is unchanged.
  • bun scripts/gate.ts and bun x tsc --noEmit pass.
  • The new test passes, along with the 10 suites that run scripts/test-shards.ts (231 tests: shards, shards-run, shards-keep-going, red-on-main, flake, checks-failure-summary, check-steps, check-list, crew-brief-gate, studio-runs).
  • scripts/fast.ts couldn't pick the tests (the change is under scripts/), so I chose those suites myself. I did not run the whole suite here.

Not done: the breach isn't red on the full tier yet (the next issue), and the committed scripts/test-times.json gets no per-test companion.

Try it: bun scripts/test-shards.ts ./test/test-budget-run.test.ts — the log ends with the slowest tests and the budget line.

🤖 Generated with Claude Code

Closes #12087

2 earlier comments · 1 event
commented

Every gate run now times each test as well as each file, and holds both to a budget: 20 s for a file, 2 s for a single test. A breach fails the check only on the fast tier, and only in a test file the pull changed. On the full tier it is reported and does not fail the check; the next step of #1242 turns that on.

Expect this pull's check to be red because of main, not this change. Main currently fails tests this change doesn't touch. Run on this tree, these three fail:

  • test/header-width.test.ts: over-wide header comments in src/web/pages/home_flow.ts, src/flow/lanes*.ts and test/surfaces-adversarial.test.ts.
  • test/cookie-flags.test.ts: two tests.

Other open pulls (e.g. #12099) also fail different tests from main. Any change under scripts/ puts a pull on the full tier, and the check only clears a red main shares on the fast tier, so these reds will count here. I did not fix them in this pull: they are outside the issue, and the earlier attempt that tried to fix them (#12091) still went red.

What changed

  • scripts/test-budget.ts (new), plain data in and out:
    • breaches({files, tests}, slow) returns each file over 20 s and each test over 2 s. It sets aside files listed in SLOW, and also returns the five slowest tests with their share of all the tests' time.
    • budgetBinds(tier, changed, file) decides whether a breach fails the run.
    • budgetLines writes the summary lines.
    • parseJunit reads Bun's JUnit report. Bun escapes the describe-block name twice, so it is decoded twice.
  • scripts/gate.ts: adds SLOW (file → issue number and reason), empty for now.
  • scripts/test-shards.ts:
    • Each bun test it starts also writes --reporter=junit --reporter-outfile=<shard dir>/junit-N.xml. If you pass a --reporter of your own, this is skipped.
    • A file run on its own is timed by its process; a file sharing a shard is timed by adding up its tests.
    • The summary now ends with the five slowest tests, then over the budget: N, SLOW aside: M, then each breach marked red:, said: or SLOW:.
    • A green run merges the per-test times into .forge-cache/test-times-tests.json.
    • A breach that binds fails the run with a line naming the rule.
  • test/test-budget-run.test.ts checks the rules on fixture times, with no real test run:
    • a run under budget passes;
    • a file over 20 s and a test over 2 s are named;
    • a SLOW file is set aside;
    • the five slowest are picked with their share;
    • a full-tier breach, or one in a file the pull didn't change, does not fail;
    • SLOW entries are sound;
    • the JUnit report parses correctly.

Checks run

  • I checked the flags against Bun 1.3.14: the console still prints its (fail) and Ran N tests across M files lines with the JUnit report on, so the output the check already reads is unchanged.
  • bun scripts/gate.ts and bun x tsc --noEmit pass.
  • The new test passes, along with the 10 suites that run scripts/test-shards.ts (231 tests: shards, shards-run, shards-keep-going, red-on-main, flake, checks-failure-summary, check-steps, check-list, crew-brief-gate, studio-runs).
  • scripts/fast.ts couldn't pick the tests (the change is under scripts/), so I chose those suites myself. I did not run the whole suite here.

Not done: the breach isn't red on the full tier yet (the next issue), and the committed scripts/test-times.json gets no per-test companion.

Try it: bun scripts/test-shards.ts ./test/test-budget-run.test.ts — the log ends with the slowest tests and the budget line.

🤖 Generated with Claude Code

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Every gate run now times each test as well as each file, and checks both against a budget: 20 s for a file, 2 s for a single test. A breach fails the check only on the fast tier, and only in a test file the pull changed. On the full tier, breaches are listed in the log by name and do not fail the check. The next step of #1242 turns that on.

What changed

  • scripts/test-budget.ts (new) works on plain data in and out:
    • breaches finds each file over budget and each test over budget, and returns the five slowest tests with their share of total test time.
    • budgetBinds decides when a breach fails the check.
    • parseJunit reads Bun's JUnit report.
    • formatTestTimes writes the per-test times.
  • scripts/test-shards.ts now runs each shard with --reporter=junit alongside the console output, so the console log is unchanged. It skips this when the caller picks a reporter of their own.
    • A file run alone is timed by its process; a file sharing a shard is timed by the sum of its tests.
    • After a green run, per-test times are saved to the check cache as test-times-tests.json. Files this run did not test keep their previous times.
  • scripts/gate.ts gains SLOW, a list of known-slow files, each tied to the issue that owns making it fast. Their breaches are reported but never fail the check. The list starts empty.
  • test/test-budget-run.test.ts covers the budget rules, the JUnit parsing, and a real sharded run that names a slow test.

The red check is main's, not this change's. The tests behind the 81 failures fail just the same on a clean origin/main (d20ce1b2e). I opened #12129 listing the 13 failing test files:

  • header widths
  • a cookie in home_flow.ts with no entry in COOKIES
  • an unimported week_burn.ts
  • a stale docs/MCP.md
  • /home missing from the looks list
  • several query-count and size-budget tests
  • SQLiteError: out of memory throughout shard 82, which looks environmental

Because this pull changes scripts/, it runs on the full tier, and only the fast tier ignores failures main also has (#10304). So it will stay red until main is green. I didn't fix those failures here: they are in other features and outside #12087.

Checked locally: bun scripts/gate.ts and bun x tsc --noEmit pass. The 39 test files that cover scripts/gate.ts and scripts/test-shards.ts pass: 525 pass, 0 fail.

To try it: run bun scripts/test-shards.ts on any set of test files. The log ends with the five slowest tests and every file or test over budget, by name.

🤖 Generated with Claude Code

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs