@avi2dg/checks 0.64.0 → 0.65.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  Every release of `@avi2dg/checks`, newest first, written by the release from its conventional commits.
4
4
 
5
+ ## 0.65.1
6
+
7
+ Released 2026-11-03.
8
+
9
+ ### Fixes
10
+
11
+ - allow weekly advisory scan in any public repository [#42](https://github.com/avi2d/checks/pull/42)
12
+
13
+ ## 0.65.0
14
+
15
+ Released 2026-11-03.
16
+
17
+ ### Features
18
+
19
+ - **ci-wiring:** one CI run per pull request, refuse schedules and long jobs [#41](https://github.com/avi2d/checks/pull/41)
20
+
5
21
  ## 0.64.0
6
22
 
7
23
  Released 2026-11-03.
package/docs/bins.md CHANGED
@@ -44,7 +44,7 @@ The night-run workflow runs them with `checks-lint --night`, which hands each ra
44
44
  These bins run on their own:
45
45
 
46
46
  - [`checks-test`](gates/checks-test.md) runs the suite as `scripts.test` and refuses a skip without a reason at its test site.
47
- - [`checks-flake`](gates/checks-flake.md) runs the suite on a schedule and records the seeds a flaky test fails with.
47
+ - [`checks-flake`](gates/checks-flake.md) runs the suite when started by hand and records the seeds a flaky test fails with.
48
48
  - [`checks-mutation`](gates/checks-mutation.md) runs Stryker for scoped checks and refuses a full run outside CI.
49
49
  - [`checks-mutation-compare`](gates/checks-mutation-compare.md) compares the mutants of two reports and lists each one that regresses.
50
50
  - [`checks-mutation-baseline`](gates/checks-mutation-baseline.md) restores the newest mutation baseline from `main`, saves it on a self-hosted runner's disk in place of an artifact, and deletes superseded baselines after a `main` run.
package/docs/design.md CHANGED
@@ -204,7 +204,8 @@ A daily release pull request would leave each merged change unpublished until a
204
204
  Only then does it move `main` to it without a force, so `main` only ever gains a release commit whose checks passed.
205
205
  It tags the commit it landed and nothing else.
206
206
  A repository that is no package keeps the release pull request, and it opens only when someone runs the workflow.
207
- No release runs on a schedule, in a package or not, since a schedule cuts releases no one asked for.
207
+ Only a public package that publishes to npm may release on a schedule, at most once a day.
208
+ A schedule elsewhere cuts releases no one asked for.
208
209
  `checks-release-pr` writes only to the `release/<branch>` branch it owns, and rebuilds that branch on `main` rather than merging `main` into it, so the changelog it carries is the one the build writes.
209
210
  `checks-release-tag` writes only the `v*` tag of a release commit that already landed.
210
211
  The `github-release` job's `contents: write` creates or updates the GitHub release from the tag's `CHANGELOG.md` section.
@@ -281,7 +282,7 @@ A group or other write bit fails the run, because another user could have edited
281
282
 
282
283
  `checks-advisories` compares the advisories at both ends of a range instead of failing on every advisory at the head.
283
284
  An advisory published against a package that landed a month earlier would otherwise fail every open pull request, including one that touches only docs.
284
- The scheduled `--all` run finds those advisories, and `advisory-acks.json` carries the ones a repository accepts for a while.
285
+ The weekly `--all` run finds those advisories, and `advisory-acks.json` carries the ones a repository accepts for a while.
285
286
 
286
287
  The gate runs OSV-Scanner rather than Trivy, Grype or `bun audit`.
287
288
  Trivy 0.74.0 reads a nested `bun.lock` entry such as `mkdirp/minimist` under a name no advisory carries, so it misses every package bun nests.
@@ -14,7 +14,7 @@ It ignores aliases, because two live advisories can list each other as aliases.
14
14
  An advisory published against a package the base already held shows at both ends, so it fails no range, and `--all` reports it instead.
15
15
  Each failure names the package, its version, the advisory id, its severity and its summary.
16
16
  A range that leaves `bun.lock` unchanged runs no scan.
17
- A run `checks-lint` starts defers the scan to the scheduled `--all` run instead, so the desk and the pull request neither fetch the database nor scan.
17
+ A run `checks-lint` starts defers the scan to the weekly `--all` run instead, so the desk and the pull request neither fetch the database nor scan.
18
18
  It also holds `advisory-acks.json` to the rules in [The acknowledgement file](#the-acknowledgement-file) on every run.
19
19
 
20
20
  ## What it reads
@@ -63,7 +63,7 @@ An entry whose `until` falls more than 30 days after that moment fails the run a
63
63
  Once that moment passes `until`, the entry fails every run until it is deleted or renewed with a later `until`, whether or not the range touches `bun.lock`.
64
64
  Delete it once the package is upgraded.
65
65
  When a scan runs, an entry that matches no advisory at the head fails, so the file holds only live entries.
66
- A deferred run still holds each entry to its day, while an entry that matches nothing waits for the scheduled run.
66
+ A deferred run still holds each entry to its day, while an entry that matches nothing waits for the weekly run.
67
67
  A file that does not decode as that list exits 2.
68
68
 
69
69
  ## Arguments
@@ -99,18 +99,20 @@ advisories: 1 acknowledgement(s) in advisory-acks.json do not hold:
99
99
  ## When it runs
100
100
 
101
101
  `checks-lint` runs it over each pull request's range in a repository that tracks `bun.lock`, as [checks-lint](checks-lint.md) says.
102
- That run defers the scan to the scheduled run, so it fetches no database and reports the deferral instead of a verdict.
102
+ That run defers the scan to the weekly run, so it fetches no database and reports the deferral instead of a verdict.
103
103
  A range that leaves `bun.lock` unchanged runs in under a second, and a direct run over a range that changes `bun.lock` scans for about 10 seconds on a warm cache.
104
104
 
105
105
  ## Running it on a schedule
106
106
 
107
- A range never fails on an advisory published after its package landed, so a scheduled `--all` run finds those.
108
- A consuming repository pins advisories between 05:00 and 06:00 UTC at a minute chosen so repositories do not start together:
107
+ A range never fails on an advisory published after its package landed, so a weekly `--all` run finds those.
108
+ Only a public repository runs it on a schedule, as [checks-ci-wiring](checks-ci-wiring.md#schedules) requires.
109
+ Any other repository starts the same workflow by hand with `gh workflow run`, with no `schedule` trigger.
110
+ A package scans on Monday between 05:00 and 06:00 UTC, at a minute chosen so repositories do not start together:
109
111
 
110
112
  ```yaml
111
113
  on:
112
114
  schedule:
113
- - cron: "15 5 * * *"
115
+ - cron: "15 5 * * 1"
114
116
  workflow_dispatch:
115
117
  jobs:
116
118
  advisories:
@@ -86,7 +86,8 @@ Each refusal names the workflow file and line, the version found and where it wa
86
86
 
87
87
  ### Release schedule
88
88
 
89
- It refuses a workflow that triggers on `schedule` and releases, in every repository, whether or not it publishes to npm.
89
+ It refuses a workflow that triggers on `schedule` and releases, unless the repository is a public package that publishes to npm.
90
+ That release runs at most once a day.
90
91
  A workflow releases when a run step calls `checks-release-pr`, `checks-release-push`, `checks-release-tag` or `checks-release-publish`.
91
92
  A call counts directly, through `bunx`, or through `bun` or `bun run` with the bin's path or its source file.
92
93
  A call through a `package.json` script counts, as `bun run <script>` where the named script releases.
@@ -94,12 +95,34 @@ A call through a local reusable workflow counts, as a job that uses a file under
94
95
  A call through a repository shell script counts, as a path inside the repository whose file releases.
95
96
  A workflow also releases when a run step publishes to npm, as [checks-release-preflight](checks-release-preflight.md) reads it, directly or through one of those paths.
96
97
  Text that only names a release bin, such as an `echo`, never counts.
97
- A release runs when someone starts it, as [checks-release-pr](checks-release-pr.md#when-it-runs) says.
98
- Each refusal names the workflow file and the line of its `schedule` trigger.
98
+ A repository publishes to npm when one of its workflows runs `npm publish` or `checks-release-publish`, the same ways a release call counts, and its `package.json` does not set `private` to `true`.
99
+ A run outside CI cannot read whether the repository is private, so there it refuses only for the `package.json` field or the missing publish step.
100
+ A daily release has one `cron` entry with one minute and one hour.
101
+ Any other release runs when someone starts it, as [checks-release-pr](checks-release-pr.md#when-it-runs) says.
102
+ Each refusal names the workflow file, the line of its `schedule` trigger and what to change.
103
+
104
+ ### Schedules
105
+
106
+ It refuses every other workflow that triggers on `schedule`, since a test, mutation, flake, browser or night run starts only by hand, with `gh workflow run`.
107
+ The one schedule it keeps is a weekly advisory scan in a public repository.
108
+ A workflow scans advisories when a run step calls `checks-advisories`, the same ways a release call counts, and every other run step is a `bun install`.
109
+ A weekly scan has one `cron` entry with one minute, one hour and one weekday, and `*` for the day of the month and the month.
110
+ It refuses an advisory scan that runs more often, and any scheduled advisory scan in a private repository.
111
+ A run outside CI cannot read whether the repository is private, so it refuses a scan there only for the cron.
112
+ A workflow that releases on a schedule is judged only by the release rule above.
113
+ Each refusal names the workflow file, the line of its `schedule` trigger and what to change.
114
+
115
+ ### Job timeouts
116
+
117
+ Every job sets `timeout-minutes` to a number of at most 60, so no job runs for hours.
118
+ A job without one would hold its runner for GitHub's 360-minute default when a step hangs.
119
+ It refuses a job that sets no `timeout-minutes`, sets more than 60, or sets an expression it cannot read before the run.
120
+ A job that calls a reusable workflow with `uses` sets no timeout, and the called workflow's jobs are judged in their own file.
121
+ Each refusal names the workflow file, the job and the limit.
99
122
 
100
123
  ## What it reads
101
124
 
102
- The bin reads `.github/workflows/*.yml`, `*.yaml`, the `scripts` and `checks` runners in `package.json` and the shell scripts those steps and scripts run from the working tree.
125
+ The bin reads `.github/workflows/*.yml`, `*.yaml`, the `scripts`, `private` and `checks` runners in `package.json` and the shell scripts those steps and scripts run from the working tree.
103
126
  It reads each file a setup-bun step names for its version.
104
127
  It reads the fleet pin from the kit's own `.bun-version`.
105
128
  It reads the target branch from `GITHUB_BASE_REF`, then from `refs/remotes/origin/HEAD` and then from the event file `GITHUB_EVENT_PATH` names.
@@ -115,7 +138,7 @@ It takes no arguments.
115
138
  | Code | Result |
116
139
  | --- | --- |
117
140
  | 0 | Every required command has a reachable step. |
118
- | 1 | A required command is missing or blocked, a job runs on the wrong runner, a workflow names a missing workflow or job, a setup-bun step drifts from the fleet bun version, or a workflow that releases runs on a schedule. |
141
+ | 1 | A required command is missing or blocked, a job runs on the wrong runner, a workflow names a missing workflow or job, a setup-bun step drifts from the fleet bun version, a workflow that releases runs on a schedule outside a public npm package or more than once a day, a workflow other than a weekly public advisory scan runs on a schedule, or a job can run for more than 60 minutes. |
119
142
  | 2 | A workflow or `package.json` cannot be decoded, or the kit's own `.bun-version` is missing, unreadable or blank. |
120
143
 
121
144
  ## Sample output
@@ -142,11 +165,26 @@ ci-wiring: 1 reference(s) name a missing workflow or job:
142
165
  .github/workflows/daily-release.yml line 31: names missing workflow commitlint.yml
143
166
  ```
144
167
 
145
- A workflow that releases on a schedule produces a report like this:
168
+ A workflow that releases on a schedule in a repository that publishes nothing to npm produces a report like this:
146
169
 
147
170
  ```
148
171
  ci-wiring: 1 workflow(s) release on a schedule:
149
- .github/workflows/daily-release.yml line 3: drop the schedule, so a release runs only when someone starts it
172
+ .github/workflows/daily-release.yml line 3: only a public package that publishes to npm releases on a schedule; drop the schedule, so a release runs only when someone starts it
173
+ ```
174
+
175
+ A scheduled test run and a daily advisory scan produce a report like this:
176
+
177
+ ```
178
+ ci-wiring: 2 workflow(s) run on a schedule:
179
+ .github/workflows/advisories.yml line 3: the advisory scan runs more than once a week; keep one cron at a minute, an hour and a weekday, such as "15 5 * * 1"
180
+ .github/workflows/night-run.yml line 4: drop the schedule, so it runs only when someone starts it with gh workflow run
181
+ ```
182
+
183
+ A job that sets no timeout produces a report like this:
184
+
185
+ ```
186
+ ci-wiring: 1 job(s) can run for hours:
187
+ .github/workflows/ci.yml job checks: the job sets no timeout-minutes, so a hung run holds its runner for GitHub's 360 minute default; set timeout-minutes to a number of at most 60
150
188
  ```
151
189
 
152
190
  ## When it runs
@@ -4,7 +4,7 @@ audience: consumers
4
4
  ---
5
5
  # checks-flake
6
6
 
7
- `checks-flake` is the scheduled run that finds flaky tests and records the seeds each one fails with.
7
+ `checks-flake` is the run someone starts by hand that finds flaky tests and records the seeds each one fails with.
8
8
 
9
9
  ## What it checks
10
10
 
@@ -100,21 +100,20 @@ Rerunning a seed with bun test --randomize --seed=<seed> --parallel=4 reproduces
100
100
 
101
101
  ## When it runs
102
102
 
103
- Only a schedule the repository writes runs it.
103
+ Only a workflow the repository starts by hand runs it.
104
104
 
105
- ## Running it on a schedule
105
+ ## Running it by hand
106
106
 
107
- A repository runs it on a schedule and keeps the record of a failed run as an artifact.
108
- A repository schedules it at minute 27 of its tier's 30 minute night window, so repositories do not start together:
107
+ A repository runs it from a workflow someone starts with `gh workflow run`, and keeps the record of a failed run as an artifact.
108
+ The workflow holds no schedule, since [checks-ci-wiring](checks-ci-wiring.md#schedules) refuses one:
109
109
 
110
110
  ```yaml
111
111
  on:
112
- schedule:
113
- - cron: "27 22 * * *"
114
112
  workflow_dispatch:
115
113
  jobs:
116
114
  flake:
117
115
  runs-on: ubuntu-latest
116
+ timeout-minutes: 60
118
117
  steps:
119
118
  - uses: actions/checkout@v5
120
119
  - uses: oven-sh/setup-bun@v2
@@ -18,7 +18,7 @@ A test file classifies as TypeScript, so its change runs every applicable gate t
18
18
  Gates requiring tracked TypeScript files begin running when the repository tracks TypeScript.
19
19
  `checks-lint-coverage` and `checks-graphwalk` also begin running when the repository tracks an `.astro` file.
20
20
  `checks-advisories` begins running when the repository tracks `bun.lock`.
21
- `checks-lint` defers its scan to the scheduled run, so the desk and the pull request fetch no database.
21
+ `checks-lint` defers its scan to the weekly run, so the desk and the pull request fetch no database.
22
22
  `checks-frontend-syntax` begins running when the repository tracks `frontend-syntax.json` at its root.
23
23
  `checks-copy` begins running when the repository tracks `copy.json` at its root.
24
24
  `checks-css-size` begins running when the repository tracks a `*.css` file.
@@ -38,7 +38,7 @@ Stryker writes no source without mutants into the report, so a mutated source th
38
38
  When a unit test changed, each such source that exists at `HEAD` enters the scope.
39
39
  A change under `tests/e2e/` changes no unit test, so it needs no baseline report.
40
40
  The scope trusts the coverage edges of the latest full baseline.
41
- So a helper, fixture or preload changed on `main` since that baseline can hide a lost kill until the scheduled full baseline refreshes.
41
+ So a helper, fixture or preload changed on `main` since that baseline can hide a lost kill until the next full baseline refreshes.
42
42
 
43
43
  ## What it reads
44
44
 
@@ -98,6 +98,7 @@ jobs:
98
98
  contents: read
99
99
  actions: read
100
100
  runs-on: [self-hosted, gpu, x64]
101
+ timeout-minutes: 60
101
102
  steps:
102
103
  - uses: actions/checkout@v5
103
104
  with:
@@ -127,15 +127,14 @@ checks-night-run: recorded 42 file score(s) in reports/night-run.json
127
127
 
128
128
  Only a night workflow the repository writes runs it, after that workflow's full mutation run, its long test tiers and its nightly lint gates.
129
129
 
130
- ## Running it at night
130
+ ## Running it by hand
131
131
 
132
- A repository runs it from a workflow named `night-run` on a schedule, and starts the same workflow by hand with `gh workflow run night-run`:
132
+ A repository runs it from a workflow named `night-run`, which someone starts with `gh workflow run night-run`.
133
+ The workflow holds no schedule, since [checks-ci-wiring](checks-ci-wiring.md#schedules) refuses one:
133
134
 
134
135
  ```yaml
135
136
  name: night-run
136
137
  on:
137
- schedule:
138
- - cron: "7 22 * * *"
139
138
  workflow_dispatch:
140
139
  permissions:
141
140
  contents: read
@@ -160,6 +159,7 @@ jobs:
160
159
  retention-days: 1
161
160
  tests:
162
161
  runs-on: ubuntu-latest
162
+ timeout-minutes: 20
163
163
  steps:
164
164
  - uses: actions/checkout@v5
165
165
  - uses: oven-sh/setup-bun@v2
@@ -176,6 +176,7 @@ jobs:
176
176
  retention-days: 1
177
177
  gates:
178
178
  runs-on: ubuntu-latest
179
+ timeout-minutes: 20
179
180
  steps:
180
181
  - uses: actions/checkout@v5
181
182
  with:
@@ -194,6 +195,7 @@ jobs:
194
195
  needs: [mutation, gates, tests]
195
196
  if: ${{ !cancelled() && needs.tests.result == 'success' }}
196
197
  runs-on: ubuntu-latest
198
+ timeout-minutes: 15
197
199
  permissions:
198
200
  contents: read
199
201
  actions: read
@@ -228,8 +230,6 @@ jobs:
228
230
  retention-days: 90
229
231
  ```
230
232
 
231
- The cron starts the run at 22:07 UTC, inside the kit's own night window from 22:00 to 22:30 UTC.
232
- A repository takes minute 7 of its own tier's 30 minute night window, so repositories do not start together.
233
233
  The tests job runs each long tier the repository holds, `live` and `pixel` as [checks-test](checks-test.md#test-tiers) names them, and keeps each JUnit report.
234
234
  Each `|| true` lets the job go on to the upload after a failing test, since that test becomes an issue.
235
235
  A tier that writes no report fails the report job, because `checks-night-run` cannot read it.
@@ -240,7 +240,7 @@ The download names the artifact by `pattern`, which downloads nothing rather tha
240
240
  A full run too long for one job splits into a matrix of shards.
241
241
  Each shard uploads its own artifact under the one pattern, and each report gets its own `--mutation`.
242
242
  It passes `--gates` only when the gates job succeeded, and the failed gates job still fails the run.
243
- The concurrency group queues a run started by hand behind the scheduled one, so two runs never file the same finding twice.
243
+ The concurrency group queues a run behind one already going, so two runs never file the same finding twice.
244
244
  A dispatch on a branch runs both jobs and lists its findings in the report job's log, and `if-no-files-found: ignore` lets that run upload no record.
245
245
  `issues: write` on the report job is the one permission beyond reading the repository and its runs.
246
246
  A public repository keeps `runs-on: ubuntu-latest` on every job.
@@ -62,6 +62,7 @@ permissions:
62
62
  jobs:
63
63
  preflight:
64
64
  runs-on: ubuntu-latest
65
+ timeout-minutes: 10
65
66
  permissions:
66
67
  contents: read
67
68
  steps:
@@ -77,6 +78,7 @@ jobs:
77
78
  publish:
78
79
  needs: preflight
79
80
  runs-on: ubuntu-latest
81
+ timeout-minutes: 15
80
82
  steps:
81
83
  - uses: actions/checkout@v5
82
84
  with:
@@ -99,6 +101,7 @@ jobs:
99
101
  github-release:
100
102
  needs: publish
101
103
  runs-on: ubuntu-latest
104
+ timeout-minutes: 10
102
105
  permissions:
103
106
  contents: write
104
107
  steps:
@@ -130,6 +133,7 @@ permissions:
130
133
  jobs:
131
134
  preflight:
132
135
  runs-on: ubuntu-latest
136
+ timeout-minutes: 10
133
137
  permissions:
134
138
  contents: read
135
139
  steps:
@@ -145,6 +149,7 @@ jobs:
145
149
  github-release:
146
150
  needs: preflight
147
151
  runs-on: ubuntu-latest
152
+ timeout-minutes: 10
148
153
  permissions:
149
154
  contents: write
150
155
  steps:
@@ -78,8 +78,9 @@ release-pr: https://github.com/acme/widget/pull/12 releases 0.4.0 from 3f2a9c81d
78
78
 
79
79
  The `release-pr` workflow below runs it on the default branch when someone starts it with `gh workflow run release-pr`.
80
80
  The workflow has no schedule, so a release is cut only when someone asks for one.
81
+ A public package that publishes to npm may add one daily `cron` to it instead, such as `"7 3 * * *"`.
81
82
  A package published to npm releases each push to `main` through [checks-release-push](checks-release-push.md) instead, with no pull request.
82
- [checks-ci-wiring](checks-ci-wiring.md#release-schedule) refuses a schedule on any workflow that releases.
83
+ [checks-ci-wiring](checks-ci-wiring.md#release-schedule) refuses a schedule on any other workflow that releases, and one that runs more than once a day.
83
84
 
84
85
  ## Running it in CI
85
86
 
@@ -15,7 +15,7 @@ It refuses when `v<version>` of the next version already tags a commit, since a
15
15
  It writes the next version into `package.json` and runs `bun run build`, which writes `CHANGELOG.md`.
16
16
  It commits both as `chore: release <version>` on top of `HEAD` through the GitHub API, as `checks-release-pr` does.
17
17
  It points the branch `release/<branch>` at that commit and dispatches every check workflow its arguments name there.
18
- It waits up to 45 minutes in all for those workflows to finish on the release commit.
18
+ It waits up to 22 minutes in all for those workflows to finish on the release commit.
19
19
  It reads the newest run of each, so a rerun stands in for the run it repeats.
20
20
  A failed read of the runs list does not end the wait.
21
21
  The wait retries the read at the same interval.
@@ -26,7 +26,8 @@ When all of them pass, it moves `<branch>` to the release commit without a force
26
26
  GitHub refuses that update when `<branch>` moved while the checks ran.
27
27
  The run then ends cleanly, since the run of the push that moved it releases the new head.
28
28
  When the update fails but `<branch>` already holds the release commit, the update landed and the run goes on.
29
- It then tags the release commit `v<version>`, pushes the tag and dispatches the release workflow on it, and waits up to 45 minutes for that workflow's run on the release commit to finish.
29
+ It then tags the release commit `v<version>`, pushes the tag and dispatches the release workflow on it.
30
+ It waits up to 22 minutes for that workflow's run on the release commit to finish.
30
31
  When that run concludes short of success, or does not finish in time, the bin fails, though `<branch>` already holds the release and the tag exists.
31
32
  When `HEAD` is itself a release commit, it tags it as [checks-release-tag](checks-release-tag.md) does, and waits for the release workflow it dispatches the same way.
32
33
  So a rerun after a failed tag push finishes the release.
@@ -104,7 +105,7 @@ jobs:
104
105
  release:
105
106
  if: github.ref == 'refs/heads/main'
106
107
  runs-on: ubuntu-latest
107
- timeout-minutes: 120
108
+ timeout-minutes: 55
108
109
  concurrency:
109
110
  group: release-push
110
111
  cancel-in-progress: false
@@ -25,6 +25,8 @@ The workflow always runs `bun run lint`, `bun run typecheck` and `bun run test`.
25
25
  A `build` script there also brings a `git diff --exit-code` step.
26
26
  Other scripts a `package.json` it finds already holds stay, but the workflow never schedules them.
27
27
  The workflow always ends with a `bunx checks-commit-title` step for the pull request title.
28
+ It runs on pull requests alone, so a merge to the default branch does not run the suite a second time.
29
+ A newer push to the same pull request cancels the run in progress.
28
30
  A `--private` run pins each job to `${{ vars.CI_RUNS_ON || 'ubuntu-latest' }}`.
29
31
  Setting the `CI_RUNS_ON` variable to a self-hosted runner label then lands the jobs there.
30
32
  A public run pins each job to `ubuntu-latest`.
@@ -45,13 +45,14 @@ A skipped test or a todo without `skipReason` fails in every environment.
45
45
  ## What it reads
46
46
 
47
47
  `checks-test` reads test source files and the JUnit report written by its own run.
48
+ A pull request run also reads the event file, the git history between the base and the head, the tracked sources, `package.json` and `bunfig.toml`.
48
49
  It reads no skip list from `package.json`, only the smoke list.
49
50
  It counts a run as `ci` when `CI` is true and as `local` otherwise.
50
51
  A local run covers `./tests/unit` plus the smoke list the repository declares.
51
52
  The smoke list lives in `package.json` under `checks.smoke` as an array of test file paths.
52
53
  A repository with no smoke list runs the unit tier alone outside CI.
53
54
  A local run with no unit test and no smoke list runs nothing and passes.
54
- A `ci` run covers the full default suite.
55
+ A `ci` run covers the full default suite, unless a pull request narrows it, as [Pull request runs](#pull-request-runs) says.
55
56
  A smoke entry that names no test file fails the run.
56
57
  A smoke entry under `tests/quarantine/`, `tests/live/` or `tests/pixel/` fails the run, since Bun's ignored paths would drop it.
57
58
 
@@ -71,6 +72,32 @@ A unit or e2e run keeps Bun's ignored paths, runs only `./tests/unit` or `./test
71
72
 
72
73
  Files under `tests/quarantine/` are not run or judged, as [checks-test-layout](checks-test-layout.md) says.
73
74
 
75
+ ## Pull request runs
76
+
77
+ A `ci` run on a `pull_request` event runs only the test files the pull request reaches.
78
+ It reads the base and head from the event file `GITHUB_EVENT_PATH` names and the changed paths since their merge base from git.
79
+ A test reaches a changed file when it imports it, names its path, runs its `package.json` bin or imports the package by name.
80
+ A test also reaches a file through a test helper or a source that reaches it, at any depth.
81
+ A source reaches only what it imports, so a registry that lists every bin's path does not make each of its importers reach every bin.
82
+ A test that names a fixture's directory reaches each fixture under it.
83
+ A changed test always reaches itself.
84
+
85
+ A shared file runs the whole suite instead:
86
+
87
+ - a lockfile, `package.json`, a `*.config.*` or `tsconfig` file, `bunfig.toml`, or a tool pin such as `.bun-version`
88
+ - a file Bun preloads into every test, or a file a preload imports
89
+ - a test helper, which is a file under `tests/` that is neither a test nor a fixture
90
+ - a stylesheet, a font, or a layout under `layouts/` or named `layout.*`
91
+
92
+ A dependency bump changes `package.json` or the lockfile, so it runs the whole suite in every repository.
93
+ A workflow under `.github/` is not a shared file, since the suite runs under it rather than reading it.
94
+ A pull request that changes no file a test reaches runs no test and passes.
95
+ The run names how many test files it reached, or which shared file made it run the whole suite.
96
+ A change whose paths cannot be read runs the whole suite.
97
+ A run on any other event, such as `workflow_dispatch` for a release, runs the whole suite.
98
+ `--full` and the live and pixel tiers always run whole.
99
+ A narrowed run judges only the skips the files it ran declare.
100
+
74
101
  ## Test tiers
75
102
 
76
103
  Tests that need a live machine go in `tests/live/`, and tests that need a screen go in `tests/pixel/`.
@@ -83,9 +83,13 @@ To run the gates in CI:
83
83
  ```yaml
84
84
  on:
85
85
  pull_request:
86
+ concurrency:
87
+ group: ci-${{ github.event.pull_request.number }}
88
+ cancel-in-progress: true
86
89
  jobs:
87
90
  checks:
88
91
  runs-on: ubuntu-latest
92
+ timeout-minutes: 30
89
93
  steps:
90
94
  - uses: actions/checkout@v5
91
95
  with:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avi2dg/checks",
3
- "version": "0.64.0",
3
+ "version": "0.65.1",
4
4
  "description": "Deterministic checks shared across a set of TypeScript repositories",
5
5
  "author": {
6
6
  "name": "avi2d",
@@ -44,6 +44,7 @@
44
44
  "src/delivery/release-pr.ts",
45
45
  "src/delivery/release-preflight.ts",
46
46
  "src/delivery/release-schedule.ts",
47
+ "src/delivery/schedule-policy.ts",
47
48
  "src/delivery/release-publish.ts",
48
49
  "src/delivery/release-push.ts",
49
50
  "src/delivery/release-tag.ts",
@@ -53,6 +54,7 @@
53
54
  "src/testing/block-screens.ts",
54
55
  "src/testing/test.ts",
55
56
  "src/testing/test-skips.ts",
57
+ "src/testing/affected-tests.ts",
56
58
  "src/core/swc.ts",
57
59
  "src/testing/test-report.ts",
58
60
  "src/testing/flake.ts",
@@ -76,11 +78,13 @@
76
78
  "src/delivery/workflow-references.ts",
77
79
  "src/delivery/bun-pin.ts",
78
80
  "src/delivery/mutation-job.ts",
81
+ "src/delivery/job-timeout.ts",
79
82
  "src/delivery/runner-policy.ts",
80
83
  "src/delivery/secrets.ts",
81
84
  "src/delivery/secrets-pack.ts",
82
85
  "src/delivery/pr-text.ts",
83
86
  "src/delivery/setup.ts",
87
+ "src/delivery/setup-workflow.ts",
84
88
  "src/delivery/gitleaks.ts",
85
89
  "src/delivery/gitleaks.toml",
86
90
  "src/quality/comment-matchers.ts",
@@ -4,9 +4,11 @@ import { defaultBranch, git } from "../core/git.ts";
4
4
  import { runMain } from "../core/main.ts";
5
5
  import { ENTRY_POINT, KIT_GATES, type KitGate } from "../core/gates.ts";
6
6
  import { findBunPinFaults, formatBunPinReport, readBunPinPolicy } from "./bun-pin.ts";
7
+ import { findLongJobs, formatLongJobReport } from "./job-timeout.ts";
7
8
  import { readScheduleFiles, readShellFiles } from "./mutation-job.ts";
8
9
  import { findScheduledReleases, formatScheduleReport } from "./release-schedule.ts";
9
10
  import { findRunnerFaults, formatRunnerReport, jobRuns, readRunnerConfig } from "./runner-policy.ts";
11
+ import { findScheduledRuns, formatScheduledRunReport } from "./schedule-policy.ts";
10
12
  import { invokes, mentions, plainCommand, type Command } from "./shell-command.ts";
11
13
  import { findMissingWorkflows, formatMissingReport, isRecord, names, workflowJobs, type Workflow } from "./workflow-references.ts";
12
14
 
@@ -65,6 +67,7 @@ const TITLE_LINT = "bunx checks-commit-title";
65
67
  const TITLE_CALLS = ["bun src/delivery/commit-title.ts", "./node_modules/.bin/commitlint"];
66
68
  const ScriptsManifest = Schema.Struct({
67
69
  scripts: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
70
+ private: Schema.optionalKey(Schema.Boolean),
68
71
  });
69
72
  // Without these a pull_request workflow never sees the commits a pull request pushes.
70
73
  const GATING_TYPES = ["opened", "synchronize"];
@@ -271,16 +274,19 @@ export const parseWorkflow = (path: string, text: string): Effect.Effect<Workflo
271
274
  catch: (error) => new WiringError({ message: `cannot parse ${path}: ${String(error)}` }),
272
275
  });
273
276
 
274
- const readScripts = Effect.fn("readScripts")(function* (root: string) {
277
+ const readManifest = Effect.fn("readManifest")(function* (root: string) {
275
278
  const fs = yield* FileSystem.FileSystem;
276
279
  const file = (yield* Path.Path).join(root, "package.json");
277
- const { scripts = {} } = (yield* fs.exists(file))
280
+ return (yield* fs.exists(file))
278
281
  ? yield* fs.readFileString(file).pipe(
279
282
  Effect.flatMap(Schema.decodeUnknownEffect(Schema.fromJsonString(ScriptsManifest))),
280
283
  Effect.mapError((cause) => new WiringError({ message: `cannot read ${file}: ${cause.message}` })),
281
284
  )
282
285
  : ScriptsManifest.make({});
283
- return new Map(Object.entries(scripts));
286
+ });
287
+
288
+ const readScripts = Effect.fn("readScripts")(function* (root: string) {
289
+ return new Map(Object.entries((yield* readManifest(root)).scripts ?? {}));
284
290
  });
285
291
 
286
292
  export const readDeclaration = Effect.fn("readDeclaration")(function* (root: string) {
@@ -322,17 +328,24 @@ const wiring = Effect.gen(function* () {
322
328
  yield* gaps.length > 0 ? Console.error(gapReport) : Console.log(gapReport);
323
329
  const missing = findMissingWorkflows(workflows);
324
330
  if (missing.length > 0) yield* Console.error(formatMissingReport(missing));
325
- const scripts = yield* readScripts(root);
331
+ const manifest = yield* readManifest(root);
332
+ const scripts = new Map(Object.entries(manifest.scripts ?? {}));
333
+ const visibility = yield* readVisibility;
326
334
  const runs = workflows.flatMap((workflow) => workflowJobs(workflow).flatMap(([, job]) => jobRuns(workflow, job)));
327
335
  const runners = yield* readRunnerConfig(root);
328
- const faults = findRunnerFaults({ visibility: yield* readVisibility, scripts, files: yield* readShellFiles(root, scripts, runs), runners }, workflows);
336
+ const faults = findRunnerFaults({ visibility, scripts, files: yield* readShellFiles(root, scripts, runs), runners }, workflows);
329
337
  if (faults.length > 0) yield* Console.error(formatRunnerReport(faults));
330
338
  const bunFaults = findBunPinFaults(yield* readBunPinPolicy(root, workflows), workflows);
331
339
  if (bunFaults.length > 0) yield* Console.error(formatBunPinReport(bunFaults));
332
340
  const scheduleFiles = yield* readScheduleFiles(root, scripts, runs);
333
- const scheduled = findScheduledReleases(workflows, { scripts, files: scheduleFiles });
341
+ const owner = { visibility, publishes: manifest.private !== true };
342
+ const scheduled = findScheduledReleases(workflows, { scripts, files: scheduleFiles }, owner);
334
343
  if (scheduled.length > 0) yield* Console.error(formatScheduleReport(scheduled));
335
- return gaps.length === 0 && faults.length === 0 && missing.length === 0 && bunFaults.length === 0 && scheduled.length === 0;
344
+ const scheduledRuns = findScheduledRuns(workflows, { scripts, files: scheduleFiles }, owner);
345
+ if (scheduledRuns.length > 0) yield* Console.error(formatScheduledRunReport(scheduledRuns));
346
+ const longJobs = findLongJobs(workflows);
347
+ if (longJobs.length > 0) yield* Console.error(formatLongJobReport(longJobs));
348
+ return [gaps, faults, missing, bunFaults, scheduled, scheduledRuns, longJobs].every((found) => found.length === 0);
336
349
  });
337
350
 
338
351
  if (import.meta.main) runMain("ci-wiring", wiring);
@@ -0,0 +1,30 @@
1
+ import { workflowJobs, type Workflow } from "./workflow-references.ts";
2
+
3
+ export type LongJob = {
4
+ readonly location: string;
5
+ readonly fault: string;
6
+ };
7
+
8
+ const LIMIT = 60;
9
+ const SET = `set timeout-minutes to a number of at most ${LIMIT}`;
10
+
11
+ function timeoutFault(timeout: unknown): string | undefined {
12
+ if (timeout === undefined) return "the job sets no timeout-minutes, so a hung run holds its runner for GitHub's 360 minute default; " + SET;
13
+ if (typeof timeout !== "number") return "its timeout-minutes cannot be shown to stay within an hour before the run; " + SET;
14
+ return timeout > LIMIT ? `its timeout-minutes of ${timeout} lets the job run for hours; ${SET}` : undefined;
15
+ }
16
+
17
+ // A job that calls a reusable workflow cannot set timeout-minutes, and the called workflow's own jobs are judged where it lives.
18
+ export function findLongJobs(workflows: readonly Workflow[]): readonly LongJob[] {
19
+ return workflows.flatMap((workflow) =>
20
+ workflowJobs(workflow).flatMap(([id, job]) => {
21
+ if (job["uses"] !== undefined) return [];
22
+ const fault = timeoutFault(job["timeout-minutes"]);
23
+ return fault === undefined ? [] : [{ location: `${workflow.path} job ${id}`, fault }];
24
+ }),
25
+ );
26
+ }
27
+
28
+ export function formatLongJobReport(jobs: readonly LongJob[]): string {
29
+ return [`ci-wiring: ${jobs.length} job(s) can run for hours:`, ...jobs.map(({ location, fault }) => ` ${location}: ${fault}`)].join("\n");
30
+ }
@@ -12,7 +12,7 @@ const LABEL = "release-push";
12
12
  const USAGE = "usage: release-push.ts <release-workflow> <workflow>...";
13
13
  const UNTAGGED = "tag the release commit with checks-release-tag, whose refusal says what to fix";
14
14
  const POLL = Duration.seconds(15);
15
- const POLLS = 180;
15
+ const POLLS = 88;
16
16
 
17
17
  const Run = Schema.Struct({ path: Schema.String, status: Schema.String, conclusion: Schema.NullOr(Schema.String), html_url: Schema.String });
18
18
  type Run = typeof Run.Type;