Repository navigation
Flaky tests read the issues once a run, and the watch reads only its own run - #2997
Merged
Merged
Conversation
…own run The backend's Flaky tests workflow spent the repository's token for the hour, scanning hours of runs, and held up a deploy. Here: - ci.yml's `changes` reads the open flaky-test issues once a run, in one request, and hands the list to every test job; the test jobs make no request and hold no token. Any API error, a rate limit included, sets nothing aside with a warning and never fails a step. - The watch reads only the run that woke it (the workflow_run event's): its jobs, and the notes of at most 12 test jobs, then the issues and the writes only when there are notes. At most 25 requests, it stops when the token's hour has under 300 left, and it never fails. Pull requests' runs skip it; one job-level concurrency group keeps runs from piling up.
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb and
tylerslaton
as code owners
December 5, 2026 05:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The backend's Flaky tests workflow ran out the repository's Actions token for the hour. Its run 47482972426 got "API rate limit exceeded for installation" while scanning hours of runs, and that held up Staging's deploy. The workflow is disabled in both repos until this lands. This PR changes OpenBot's copy so it can't happen here; CopilotKit/openbot-backend has the twin PR.
What changes
Test steps: one request per run, and an error costs nothing.
changesreads the open flaky-test issues once per run, with one request (bun scripts/flaky-tests.ts quarantine), and passes the list to every test job as an output.flaky-tests-quarantinestep only writes that list to a file. Test jobs make no request and hold no token, so they no longer needissues: read.::warning::. The step still exits 0.Watcher: reads only the run that woke it. It reads only
github.event.workflow_run(watchRun). There is no time-window scan and no history pagination. The clean-run count stays in the issue's state block.::warning::, and the watch exits 0.flaky-tests, withcancel-in-progress: false, so runs don't pile up. It checks out only the two scripts it runs.What one CI run costs in API requests (GITHUB_TOKEN)
GitHub's rate limit for
GITHUB_TOKENis "1,000 requests per hour per repository", or 15,000 for an Enterprise Cloud account's resources.x-ratelimit-remainingshows what is left in the hour. Source: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-apichanges(the list of tests set aside)Run volume (measured 2026-12-05, last 24 hours): 269 CI runs, of which 149 pull request, 64 merge queue and 56 main. The busiest hour had 39 runs, 14 of them queue or main.
At the busiest hour:
All three are under the 1,000. The watcher also stops at 300 remaining, so it never drains the last of the hour.
Before this PR, a sweep scanned every run of the last hours. On the backend it ran past its 10 minutes and spent the hour.
Regression tests
scripts/flaky-tests.test.tsruns against fakes of GitHub's API with the same response shapes, including the 403 GitHub sends once a token's hour is spent.changesreads the issues, and every test job takes the list from it.All of these fail on main, which has #2992's version.
Run locally, one file at a time:
scripts/flaky-tests.test.ts(19 pass)api/client-boundary.test.tsscripts/ci-run-tests.test.tstests/upstream-upgrade-checks.test.tsscripts/ci-changes.test.tsscripts/stop-on-failure.test.tsscripts/ci-budgets.test.tsscripts/workflow-concurrency.test.tsbiome format and lint pass. actionlint reports nothing new. zizmor has no findings.
The workflow stays disabled; it is re-enabled after merge.
Changelog
none