Repository navigation
fix(ci): bound every workflow job with a timeout-minutes (#531) - #534
Conversation
No job in any of the five workflows declared `timeout-minutes`, so all 24 inherited GitHub's default of 360 minutes. Nothing in this repository takes anything like that: the whole gate is under five minutes of wall clock and the longest job anywhere is `docker-build-push` at 917 seconds. So a job that reaches the default has not run long, it has hung — a test deadlocked on a channel, an apt-get waiting on a prompt that will never come, a curl to a host that stopped answering — and while it does it holds this repository's required checks. `cancel-in-progress` does not rescue it: a new push cancels the run rather than the wait, and starts its own six-hour clock. Each of the 23 eligible jobs now carries a bound sized from its worst observed run, with a floor of 10 minutes so ordinary runner variance never trips one — `test` 15, `packaging` 20, `coverage`/`lint`/`install-script` 15, 10 for the rest of ci.yml; `security` 20; pages 15/10; dependabot 10; and on the release path `artifacts` 20, `docker-build-push` 45, `security-scan` 15, `publish` 20. The 24th job cannot have one. `release.yml`'s `gate` is `uses: ./.github/workflows/ci.yml`, and Actions rejects `timeout-minutes` beside `uses:` — the allowed set is name, uses, with, secrets, needs, if and permissions, and an eighth key fails the whole file before any job starts, so there is no log and nothing runs. Verified with actionlint rather than recalled. The exemption is not a hole: the gate is the sum of ci.yml's own jobs, every one of which is bounded here. `TestEveryWorkflowJobHasATimeout` walks `.github/workflows` instead of naming files, on the same reasoning as `TestNoPullRequestTriggerFiltersItsBaseBranch` — the job that arrives without a timeout is by definition one nobody thought to add to a list. It also bounds the value at 1..60 rather than only checking presence, because `timeout-minutes: 360` passes a presence check while bounding nothing, and it checks the `uses:` exemption is a caller with no `steps:` rather than a blanket skip. Verified by mutation, six ways: deleting one job's timeout, setting one to 360, writing one as an expression instead of a literal, adding one to `gate`, giving a stepped job a `uses:` key to see whether the exemption swallows it, and breaking the `jobs:` lookup. Each produced its own specific diagnosis, and the last one hit the non-vacuity floor rather than passing on zero jobs.
…l bound Two corrections to the one job that cannot carry `timeout-minutes`. The exemption was sound for the wrong reason. It covered any `uses:` job, and a job calling `owner/repo/.github/workflows/x.yml@ref` has the same shape as `release.yml`'s `gate` while being bounded by nothing this repository can see: the key is still rejected, and the called workflow's jobs live in another repo at a ref no test here reads. That is a six-hour hole wearing the legitimate exemption's clothes. The test now requires the target to be a local `./.github/workflows/*.yml` that exists, and fails on anything else — there is no way to bound such a job, so the honest outcome is to make someone decide rather than wave it through. And the bound was described as the sum of ci.yml's jobs, which would be 155 minutes. `grep -c '^ needs:' .github/workflows/ci.yml` returns 0: all fifteen jobs are independent, so they run in parallel and the caller's wall clock is the longest of them, `packaging` at 20. A child that hangs dies at its own bound and fails the gate. Both the job comment and the test's doc say that now, with the condition attached — if a `needs:` chain is added to ci.yml the bound becomes the critical path and the reasoning needs rereading. Verified by mutation: pointing `gate` at an external workflow and at a nonexistent local one each fail with their own diagnosis, and the exempt count stays 1 so neither is silently reclassified.
|
Follow-up in addcd33, on the 24th job — the Recommendation: leave it uncapped, because there is no lever, and tighten the exemption so it cannot spread. GitHub has no workflow-level timeout — the only knobs are Two things changed instead:
Mutation-checked both ways: pointing |
Closes #531.
What was wrong
Not one job in any of the five workflows declared
timeout-minutes, so all 24 inherited GitHub'sdefault of 360 minutes. Nothing here takes anything like that — the whole CI gate is under five
minutes of wall clock, and the longest job anywhere is
docker-build-pushat 917 seconds.So a job that reaches the default has not run long, it has hung: a test deadlocked on a channel, an
apt-getwaiting on a prompt that will never come, acurlto a host that stopped answering. Andwhile it hangs it holds this repository's required checks.
cancel-in-progressdoes not rescue it,because a new push cancels the run rather than the wait, and then starts its own six-hour clock.
Sizing
A generous multiple of each job's worst observed run, floor 10 minutes so ordinary runner variance
never trips one. The aim is that a hang fails in minutes and a slow day never fails at all.
testpackagingcoveragelintinstall-scriptfuzz-smokecross-buildbuild-tagssdk-metricsmodulefileslabelsdeploy-manifestsdocs-siteconfig-examplessystemd-unitsecuritybuild/deploydependabotdocker-build-pushpublishartifactssecurity-scanThe one job that cannot have one
release.yml'sgateisuses: ./.github/workflows/ci.yml, and Actions rejectstimeout-minutesbesideuses:. The allowed set isname,uses,with,secrets,needs,ifand
permissions; an eighth key fails the whole file before any job starts, so there would be no joband no log. Verified with
actionlintagainst a mutated copy rather than recalled:The exemption is not an unbounded hole — the gate is ci.yml's jobs, and every one of them is
bounded here. The reason is recorded at the job itself so the next person does not "fix" it and break
the whole file.
The test
internal/config/job_timeouts_test.gowalks.github/workflowsrather than naming files, on thesame reasoning as
TestNoPullRequestTriggerFiltersItsBaseBranchnext to it: a list checks the jobsthat existed when it was written, and the job that arrives without a timeout is by definition one
nobody thought to add to a list.
Two details that are the point rather than polish:
timeout-minutes: 360passes a presence checkwhile bounding nothing — it is the default this change exists to displace. The ceiling is three
times the longest job in the repo; raising it should come with the measurement.
uses:exemption is checked, not assumed: a caller hasuses:and nosteps:. A job withboth is not a caller and does not get out of the rule.
Verification
Mutation, six ways — each produced its own specific diagnosis rather than a generic failure:
test's timeoutci.yml: job test has no timeout-minutesoutside 1..60${{ }}expressionnot a literal integergatecalls a reusable workflow with uses: and also sets timeout-minutesuses:keyjobs:lookupchecked 0 jobs ... expected at least 20Also:
actionlintclean on all five files (only pre-existing shellcheckinfonotes),go test ./internal/config/green,GOOS=linux golangci-lint run ./internal/config/→ 0 issues.