Repository navigation
CI watch makes four API requests a run, and stops green when GitHub refuses - #2996
Merged
Merged
Conversation
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 5, 2026 05:25
…efuses The Actions token has 1,000 API requests an hour for the whole repository, and CI watch runs after every run of CI. Holding jobs to their median meant reading the jobs of the last fifteen runs on every run in the merge queue or on main: about twenty requests each, a few hundred an hour at the busiest. Each workflow's recent times now live in its `CI budget record: <workflow>` issue, a table a person reads with the times CI watch reads back. A run adds its own jobs' times to it, so it reads only the run it watches: its jobs, an earlier failed run of its commit, the open ci-budget issues, and the record's update. A job newly over budget opens its issue once; an issue already open costs nothing more; stale issues close five at a time. A request GitHub refuses or fails (a rate limit, an outage) now ends CI watch with a warning and a green run: it reports on CI, it is not CI.
davidmckayv
force-pushed
the
ci/watch-api-calls
branch
from
December 5, 2026 05:27
18939a1 to
012838f
Compare
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.
What this changes
CI watch now makes 4 API requests per run in the merge queue or on main, down from about 21. When GitHub refuses a request, it stops with a warning and a green run.
Why: the Actions token gets 1,000 API requests an hour, and every workflow in the repository shares them. The backend hit the limit on 4-5 December. CI watch runs after every run of CI and Desktop. Since #2988, it held each job to its median by reading the jobs of the last 15 runs on every steady run: about 21 requests per run (the run's jobs, an earlier failed run of the same commit, the run list, 15 runs' jobs, the issues, and an update to each open over-budget issue).
Per run, before and after:
At the busiest hour of the last 24 (46 watched runs, 15 of them steady):
How:
CI budget record: <workflow>issue. The body has a table people read (median, budget, last five times per job) and the same times as data in an HTML comment that CI watch reads back. Each run adds its own jobs' times, so it never re-reads history.CI watch stopped, and exit 0. A budget breach still turns the run red.Where it runs
scripts/ci-watch.tsandscripts/ci-budget.ts, which only GitHub Actions runs. No workflow, app, server or API change.Changelog
none
Proof
scripts/ci-watch-requests.test.tsrunsscripts/ci-watch.tsas CI runs it, with theworkflow_runevent, against a stand-in forgh api(scripts/ci-watch.fixtures/fake-gh.ts). The stand-in answers from this repository's real merge-queue and PR runs and logs every request.ci-watch.ts, the same test fails 5 of 6: 11 requests where 4 are allowed, 15 where 5 are, and exit 1 on a rate limit.bun teston ci-watch-requests, ci-budget, ci-watch, ci-budgets, ci-changes, workflow-concurrency and flaky-tests: 236 pass.