Repository navigation
CI fails when it grows slower or starts more jobs than its written budget - #2988
Merged
Merged
Conversation
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 5, 2026 04:08
davidmckayv
force-pushed
the
ci/time-budget
branch
from
December 5, 2026 04:14
0d15150 to
1d0b871
Compare
…dget .github/ci-budgets.json now carries the repository's limits: at most 82 jobs for one push to a pull request, no job allowed past 30 minutes, no job's budget over 8 minutes, no run's over 11. A test fails a pull request that goes over any of them, counted from the workflow files as GitHub would start them on a pull request. CI watch holds each job to its budget by its median over its last five runs in the merge queue and on main, where timings are steady, instead of by any single run: one slow run no longer opens an issue, a job that has crept stays over, keeps its ci-budget issue current and fails CI watch until it is back under, when the issue is closed. A pull request's run that starts more jobs than its workflow files allow does the same.
davidmckayv
force-pushed
the
ci/time-budget
branch
from
December 5, 2026 04:24
1d0b871 to
cdcbea2
Compare
This was referenced Dec 5, 2026
davidgilmoursp
pushed a commit
to davidgilmoursp/OpenBot
that referenced
this pull request
Dec 5, 2026
… branch older than the limits (CopilotKit#3009) Two fixes from openbot-backend CopilotKit#1249 and CopilotKit#1250, the same code here. A job over budget in the merge queue or on main failed CI watch, which marks main's commit not green; Staging's pick of green main (the backend's scripts/staging-green.ts, which reads this repository too) then skipped every commit until the job was fast again, though every real check passed. It now keeps its ci-budget issue and prints a `CI over budget` warning, and CI watch stays green. A pull request still fails the budget test and the job count. On a pull request's run CI watch reads that branch's own .github/ci-budgets.json. A branch cut before the file had `limits` (CopilotKit#2988) crashed it ("undefined is not an object (evaluating 'file.limits[key]')"). Its job count is now skipped, with a note.
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 now fails when it grows slower or starts more jobs than a written budget, so it cannot creep back unnoticed.
The budget (
.github/ci-budgets.json,limits), set from the run after #2986 (whole run 8.1 min, slowest job 6.1, unit shards 3-6, WebKit 4-5, desktop setup window 4.3):changes,verifyand a runner's waittimeout-minutesDesktop's installer builds (13-17 min on Windows and Mac) aren't in this round's targets. They name their own limits, with the reason, so they're held where they are today. Two jobs are lowered to fit the 30-minute limit: Desktop upgrade (60 → 30, takes about 3 min) and Model lock (60 → 30, takes 1-7 min).
On every PR (
scripts/ci-budget.test.ts, which runs in the unit suite): the jobs a push to a PR can start are counted from the workflow files as GitHub would start them on a PR from this repository. The count uses GitHub's own expression parser (@actions/expressions, already a dev dependency). A job that is off on every PR is left out. A job that depends on what the run finds is counted, along with every leg of its matrix. A called workflow counts its jobs. The test fails if any of these happens:On real runs (
ci-watch): after each run in the merge queue or on main, where timings are steady, each job is held to its budget by its median over its last five runs there, not by any single run.ci-budgetissue (or updates the body of the open one, with no comment spam), and CI watch fails until the job is back under budget. Then the issue is closed..githubfolder as data (sparse checkout, never run). This catches a matrix that grows at run time past its cap.This replaces the per-run rule, which opened an issue whenever any one run of any job went over, PR runs included. That rule left about 60
ci-budgetissues open, so they were all ignored. The first steady run after merge closes the ones that aren't over budget by median.No Slack and no email: the signal is a red CI watch run and the issue.
What to expect after merge
The median window still holds the merge queue's runs from before #2986 (WebKit 12.5, desktop setup window 10.9, whole run 14.9). CI watch will be red, with those three issues current, until about three merge-queue runs after #2986 have landed. Then it clears by itself.
Where it runs
GitHub Actions and its scripts only:
ci-watch.yml, twotimeout-minutes,.github/ci-budgets.jsonandscripts/. No app, server, API, database or release-policy change.Changelog
none
Proof
scripts/ci-budget.test.ts(12 tests), on real data:bun teston ci-budget, ci-budgets, ci-watch, workflow-concurrency, ci-runners, ci-changes, ci-run-tests: 240 pass.ci-watch.ts --dry-runagainst live runs: merge-queue run 47476732864 would update the WebKit, desktop-setup-window and whole-run issues and close 44 stale ones. PR run 47471673283: 34 jobs started, within the 55 CI allows.openbot-ubuntu-16corein desktop-upgrade.yml.How the leaders do it (searched 2026-12-04)