Skip to content

Retry a failed test once in CI, and set flaky tests aside until they are steady, with no token in a test step - #2992

Merged
davidmckayv merged 4 commits into
mainfrom
ci/flaky-tests-set-aside-reland
Dec 5, 2026
Merged

davidmckayv merged 4 commits into
mainfrom
ci/flaky-tests-set-aside-reland

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

#2987 (flaky tests retried once and set aside) broke main and was reverted in #2990. This lands it again, fixed at the cause. Main's push run 47477429817 and merge groups 47477444820 / 47477446193 failed in the same three places. I read every failing job's log in those runs: only shards 1 and 5 failed on their own, and tests and verify failed because of them.

  1. tests/upstream-upgrade-checks.test.ts: "ci.yml test step 7 env GH_TOKEN is not a literal value". The upstream upgrade runs the test job's run steps itself (scripts/integrate-upstream.ts, ciChecks), and it refuses an expression.
  2. scripts/ci-run-tests.test.ts, "changed desktop browser tests", 3 times, each timing out at 5 s. The test step held GH_TOKEN, and the tests inherited it. The test runs ci-run-tests.ts, which then asked GitHub through the suite's closed network until it timed out.
  3. api/client-boundary.test.ts: the script's fetch() was not on the allowlist.

The fix

  • The token stays out of every step that runs tests. Each test job reads the list of tests set aside once, in a uses step of its own: .github/actions/flaky-tests-quarantine. That step runs bun scripts/flaky-tests.ts quarantine <file> with the job's token and writes flaky-tests-quarantine.json to the runner's temporary folder.
    • test-ci.ts, ci-run-tests.ts and the real-browser wrapper read that file and never ask GitHub, so no test they run can either.
    • The upstream upgrade skips uses steps, so it runs the shard's steps exactly as before.
    • The step writes no GITHUB_ENV line, which zizmor flags as dangerous.
  • The allowlist entry is the one from fix-flaky-tests-allowlist (c29f977), cherry-picked: third-party, like scripts/ci-watch.ts.
  • The sweep runs on a timer and reads less. As live in openbot-backend, the watch ran after every CI run and read the annotations of every job, one request at a time; its first sweeps there ran past their 10 minutes and spent the repository's shared token budget (fixed there in CopilotKit/openbot-backend#1231). Here it runs every 20 minutes, one at a time, reads only the jobs that run tests (JOBS), eight at a time, and stops at 400 requests, keeping the newest runs. With no workflow_run trigger, zizmor needs no exception for it. A test holds JOBS to every ci.yml job that runs tests, and no other.
  • Everything else is as reviewed in Retry a failed test once in CI, and set flaky tests aside until they are steady #2987:
    • retry once;
    • only issues the watch marked set a test aside, so the 55 existing issues keep blocking;
    • the watch adopts an issue on a recorded fail-then-pass;
    • release after 60 clean runs.

Regression tests (each fails on #2987 as it landed, dca88040f, and passes here)

  • scripts/flaky-tests.test.ts: "a test step never asks GitHub, even with a token in its environment". The fake GitHub receives no request.
  • scripts/flaky-tests.test.ts: "every job that runs tests reads the list first, and no step that runs tests holds a token". It reads ci.yml.
  • The checks Retry a failed test once in CI, and set flaky tests aside until they are steady #2987 broke, which now pass: tests/upstream-upgrade-checks.test.ts, the three scripts/ci-run-tests.test.ts tests and api/client-boundary.test.ts.

All of the above was run locally with CI's environment (GITHUB_ACTIONS, GITHUB_REPOSITORY, GH_TOKEN set): 31 pass. Also passing:

  • the ci-changes, ci-budgets, workflow-concurrency, ci-runners, test-ci, ci-watch, stop-on-failure and release tests (279 pass);
  • biome format and lint;
  • actionlint, which reports nothing new;
  • zizmor, with no findings.

Changelog

none

@davidmckayv davidmckayv added the full-ci Run the slow image builds on this PR label Dec 5, 2026
@davidmckayv davidmckayv added the full-ci Run the slow image builds on this PR label Dec 5, 2026
#2987 gave each test step GH_TOKEN, so its runner could read the open flaky-test issues. On main
that broke three things, and #2990 reverted it:

- The test shard's step held a value the upstream upgrade cannot run (scripts/integrate-upstream.ts
  refuses an expression in a step's env).
- The tests inherited the token. scripts/ci-run-tests.test.ts runs ci-run-tests.ts, which then
  asked GitHub through the suite's closed network and timed out at 5 seconds, three times.
- api/client-boundary.test.ts did not know the script's fetch() (fixed in the commit before).

Now each test job reads the list once, in a `uses` step of its own
(.github/actions/flaky-tests-quarantine, `bun scripts/flaky-tests.ts quarantine <file>`), into
flaky-tests-quarantine.json in the runner's temporary folder. The test steps read that file and
never ask GitHub, and hold no token. The upstream upgrade skips `uses` steps, so it runs the shard's
steps as before.

Regression tests: a test step with a token in its environment makes no request to GitHub, and
every ci.yml job that runs tests reads the list first and has no token in a test step. Both fail
on #2987 as it landed, as do the upstream checks and ci-run-tests tests it broke.
…equests

Live in openbot-backend, the sweep ran after every run of CI, End to end and Main images. It listed
the runs of every workflow, and read the annotations of every job of each one, one request at a
time. Its first sweeps ran past their 10 minutes, and spent the requests the repository's token
shares with every other workflow.

Now it:
- runs every 20 minutes, one at a time, from where the last sweep on the timer left off;
- lists only the watched workflows' runs;
- reads only the jobs JOBS names (the ones that run tests), eight at a time;
- never makes more than 400 requests. Past that it keeps the newest runs and says how many older
  ones it left unread.

No `workflow_run` trigger is left, so zizmor's exception for it goes. A test holds JOBS to every
ci.yml job that runs tests, and to no other.
@davidmckayv
davidmckayv force-pushed the ci/flaky-tests-set-aside-reland branch from 1ad527e to 0921644 Compare December 5, 2026 04:45
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 5, 2026
Merged via the queue into main with commit 52182d5 Dec 5, 2026
64 checks passed
@davidmckayv
davidmckayv deleted the ci/flaky-tests-set-aside-reland branch December 5, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the slow image builds on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant