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

No flaky tests: ten green runs to join the gate, a nightly flake hunt in random order, mechanical quarantine #1268

Closed opened this in answer to
Closed without merging

Flaky tests now have an admission bar, a nightly hunt, mechanical quarantine and a ban on retries. I ran the new and cross tests locally (flake, check-list, shards, hollow) and they pass. I couldn't run tsc here, so the type check is untested and rests on the forge's check.

Notes

stopped closed without shipping deploy 547139b

opened this

Flaky tests now have an admission bar, a nightly hunt, mechanical quarantine and a ban on retries. I ran the new and cross tests locally (flake, check-list, shards, hollow) and they pass. I couldn't run tsc here, so the type check is untested and rests on the forge's check. I also haven't run the hunt or its workflow, so the quarantine-and-pull step is untested.

  • Admission: bun scripts/flake-hunt.ts admit test/x.test.ts runs the file ten times with --randomize and a fresh seed each time, beside one busy loop per core. It prints a record of the seeds to paste into the admitting pull and exits non-zero unless all ten are green. I tried it with two runs on test/qr.test.ts; both were green and it exited 1 because fewer than ten ran. The header of scripts/gate.ts, README.md and CLAUDE.md now say ten runs, in the pull.
  • Nightly hunt: .forgejo/workflows/flake-hunt.yml runs at 02:17 UTC and on demand. It runs the whole gate five times with --randomize and a fresh seed each time, and the hunt logic lives in scripts/flake.ts and scripts/flake-hunt.ts.
  • What counts as flaky: a test that fails in some runs and passes in others. A test red in every run is reported as broken, not flaky.
  • Quarantine: for each flaky file the hunt files an issue with the failure text, the seed and the failing run. It then moves the file from GATE to EXCLUDED under that issue and pushes a flake/<date> branch with a pull. Nobody edits the list by hand.
  • Issue template: it lists the five root causes (shared port, real clock, order dependence, leaked server, timeout near the real duration), each with its fix. It says a retry is not a fix.
  • No retry: test/flake.test.ts, which is now in GATE, fails on --retry, a retry = in bunfig, or a { retry: N } option. It scans forge.json, bunfig.toml, package.json, the workflows, two scripts and every file in GATE.

Not done:

  • Whether a pull really carries ten green runs isn't checked by machine. The admit command makes the evidence cheap, and a reviewer reads it.
  • I did not re-run existing GATE files through admission or fix the known flaky ones (apps-ws, apps-idle, signin-throttle, …). The first nightly hunt will find and quarantine whichever are flaky.
  • The hunt's load is the runner's own plus the gate itself; hunt doesn't add burner processes (admit does).

To try it:

  • bun test test/flake.test.ts
  • bun scripts/flake-hunt.ts admit test/qr.test.ts --runs 2
  • bun scripts/flake-hunt.ts hunt --runs 2 to run the hunt without filing anything. --quarantine needs FORGE_API, FORGE_REPO and FORGE_TOKEN.

🤖 Generated with Claude Code

Closes #1243

commented

This pull adds ten-run admission, a nightly random-order flake hunt, mechanical quarantine and a no-retry guard. I ran only test/flake.test.ts (11 pass); the hunt and admit have not been run here. The forge's check runs the full gate on push.

  • Admission: bun scripts/flake-hunt.ts admit test/x.test.ts runs the file ten times with --randomize and a fresh seed each, beside one busy loop per core. It prints the record for the admitting pull and exits non-zero unless all ten runs are green. The README now says ten runs, where it said three.
  • Nightly hunt: .forgejo/workflows/flake-hunt.yml runs the whole gate five times with --randomize and a fresh seed each. A test red in some runs and green in others counts as flaky.
  • Quarantine: for each flaky file, --quarantine files an issue carrying the failure text, the seed and the run. The issue also names the usual root causes: a shared port, a real clock, order dependence, a leaked server, a timeout set near the real duration. The hunt then moves the file from GATE to EXCLUDED in scripts/gate.ts and proposes that as a pull.
  • No retry: test/flake.test.ts fails on --retry, a bunfig retry, or { retry: N } anywhere in the gate.

On @trevato's comment about Bun-native flags: --randomize --seed=N is used for every hunt and admission run, and the existing --shard N/M is passed through. I did not adopt two others, and the README now says why:

  • --rerun-each: it reuses one seed for all reruns, so ten reruns would explore a single order. Admission needs ten different seeds.
  • --parallel: it implies --isolate, which would change the load the gate is judged under. scripts/shards.ts keeps balancing shards by recorded duration.

Not done: the hunt does not use --timings, and I did not build the coverage-based impact map.

To try it: bun scripts/flake-hunt.ts admit test/flake.test.ts --runs 2, or trigger the workflow with workflow_dispatch.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs