@mark1russell7/conventions 0.7.0 → 0.8.0
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/README.md +4 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/{run-MyvUGD5l.js → run-d-5ceKnT.js} +236 -8
- package/build/run-d-5ceKnT.js.map +1 -0
- package/package.json +1 -1
- package/build/run-MyvUGD5l.js.map +0 -1
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ The rules come from the invariants audit of 2026-10-26 (strategy item s38). The
|
|
|
38
38
|
| `typed-files` | Each TypeScript file that git keeps (`.ts`, `.tsx`, `.mts`, `.cts`, not `.d.ts`) is in the program of a tsconfig that a `typecheck` script names: the tests, the e2e specs, the scripts, the benches and the configs too. The rule reads the configs of each `tsc`, `tsgo` or `vue-tsc` (`-p`, `--project`, `-b`, or `tsconfig.json`) and of `svelte-check --tsconfig`, follows their `references`, and lists the files with `tsc --listFilesOnly`. A file that a covered file imports is covered. A config that does not exist, and a repository where no typecheck names a config, are a break. | fleet `fail-closed` (STRATEGY.md, 2026-10-30). |
|
|
39
39
|
| `tests-required` | No test runner passes when it finds no test: no `passWithNoTests: true` in a config of vitest, vite, jest or Playwright, and no `--passWithNoTests` in `package.json`. With the option, a broken include pattern turns the test gate green with no test run. | fleet `fail-closed` (STRATEGY.md, 2026-10-30). |
|
|
40
40
|
| `roadmap-parses` | Each call of the Pages workflow of the template (`reusable-pages.yml`) gives a `roadmap`, or `site-pages: false`. Without it, the Status page shows no item of the plan. Each roadmap that a workflow gives to the Status page (a `roadmap:` key) parses as `@mark1russell7/site-pages` reads it. The rule uses the parser of site-pages. Thus a pull request finds a bad row, and the Pages job on `main` does not stop on it. | fleet `fail-closed` (STRATEGY.md, 2026-10-30). |
|
|
41
|
+
| `runner-budget` | All repositories of the account share 40 runners. Each `strategy` with a `matrix` has a `max-parallel` of 3 or less. Each workflow has a concurrency group at the top or in each job. A job that calls a shared workflow of the option `grouped` gets its group from that workflow, and each job of that workflow has a group. The minute of each `cron` comes from a hash of the repository and the file (1 to 59), so the schedules of the repositories do not start together. The repository comes from `GITHUB_REPOSITORY` or from the remote `origin`. | fleet `runner-slots` (STRATEGY.md, 2026-10-30). |
|
|
41
42
|
|
|
42
43
|
The rule `release-files` needs the base of the change. On a pull request, the checkout is a merge commit, and the rule reads its two parents (`fetch-depth` 2 or more). In other runs, give `--base <ref>`. Without a base, the rule shows `skip`.
|
|
43
44
|
|
|
@@ -88,6 +89,9 @@ An unknown rule, an unknown option, or an exception or a changed option without
|
|
|
88
89
|
| `typed-scripts.shellLines` | `1` | The most lines of code of a shell script (a launcher). Empty lines and comments do not count. |
|
|
89
90
|
| `typed-files.configs` | `[]` | More tsconfig files, relative to the root, that CI examines with another command (for example a script that the typecheck starts). |
|
|
90
91
|
| `roadmap-parses.roadmaps` | `[]` | More roadmap files, relative to the root, for a roadmap that no workflow names. |
|
|
92
|
+
| `runner-budget.maxParallel` | `3` | The largest `max-parallel` of a matrix. |
|
|
93
|
+
| `runner-budget.minute` | `true` | When `false`, the rule does not examine the minute of the schedules. |
|
|
94
|
+
| `runner-budget.grouped` | `["reusable-ai-review.yml", "reusable-codex-review.yml"]` | The shared workflows that give a concurrency group in each of their jobs. |
|
|
91
95
|
|
|
92
96
|
## Commands
|
|
93
97
|
|
package/build/cli.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -155,6 +155,15 @@ export declare const requiredScripts: Rule;
|
|
|
155
155
|
/** This function gives the value of a `roadmap: <file>` line, or undefined for another line, an empty value or an expression. */
|
|
156
156
|
export declare function roadmapOfLine(line: string): string | undefined;
|
|
157
157
|
export declare const roadmapParses: Rule;
|
|
158
|
+
/**
|
|
159
|
+
* This function gives the minute (1 to 59) of the schedules of a workflow: the FNV-1a hash of the repository and the
|
|
160
|
+
* file. Two repositories with the same workflow thus start at different minutes, and no schedule starts at minute 0,
|
|
161
|
+
* where GitHub has the most load.
|
|
162
|
+
*/
|
|
163
|
+
export declare function scheduleMinute(repository: string, file: string): number;
|
|
164
|
+
/** This function gives `owner/name` from a git remote URL, or undefined for a URL that is not of GitHub. */
|
|
165
|
+
export declare function repositoryOfRemote(url: string): string | undefined;
|
|
166
|
+
export declare const runnerBudget: Rule;
|
|
158
167
|
/** This function gives each path in the value of an entry field (a string, or the strings in an object). */
|
|
159
168
|
export declare function pathsOf(value: unknown): string[];
|
|
160
169
|
/** This function tells if a path is a source file: a file in `src/`, or a TypeScript file that is not a declaration file. */
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;;KAIC;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN;;WAEA,aAAa;;WAEb,mBAAmB;;WAEnB,KAAK,SAAS;;WAEd;;EAET;;EAEA,IAAI;;;KAIM,uBAAuB;WAAqB;;;UAGvC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB,SAAS,SAAS,eAAe;EAC1C,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;qBAMxC,WAAY,gBAAgB;;qBAG5B,YAAa;;wBAGV,WAAW,cAAc;;;;;;wBASzB,WAAW;;wBA2BX,UAAU;;wBAUV,OAAO,cAAc;;qBAOxB,UAAW,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UC9K9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;qBC/FX,eAAe;;qBCYf;;qBAGA,wBAAwB;qBAOxB,cAAc;;wBCnBX,eAAe;;;;;wBAaf,SAAS,cAAc;qBAqB1B,eAAe;qBCEf,cAAc;qBCrBd,iBAAiB;;wBCqCd,cAAc;qBAajB,eAAe;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;;KAIC;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN;;WAEA,aAAa;;WAEb,mBAAmB;;WAEnB,KAAK,SAAS;;WAEd;;EAET;;EAEA,IAAI;;;KAIM,uBAAuB;WAAqB;;;UAGvC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB,SAAS,SAAS,eAAe;EAC1C,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;qBAMxC,WAAY,gBAAgB;;qBAG5B,YAAa;;wBAGV,WAAW,cAAc;;;;;;wBASzB,WAAW;;wBA2BX,UAAU;;wBAUV,OAAO,cAAc;;qBAOxB,UAAW,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UC9K9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;qBC/FX,eAAe;;qBCYf;;qBAGA,wBAAwB;qBAOxB,cAAc;;wBCnBX,eAAe;;;;;wBAaf,SAAS,cAAc;qBAqB1B,eAAe;qBCEf,cAAc;qBCrBd,iBAAiB;;wBCqCd,cAAc;qBAajB,eAAe;;;;;;wBCnBZ,eAAe,oBAAoB;;wBAUnC,mBAAmB;qBAqGtB,cAAc;;wBC5JX,QAAQ;;wBAQR,aAAa;qBAKhB,YAAY;qBCVZ,eAAe;;wBCHZ,SAAS,0BAA0B;qBAKtC,cAAc;;wBC4CX,gBAAgB;;;;;wBA4BhB,UAAU,SAAS,SAAS,0BAA0B,cAAc,OAAM;qBA+C7E,YAAY;qBChGZ,cAAc;qBC9Bd,mBAAmB;;qBCYnB,gBAAgB;;UCRZ;WACN;WACA;WACA;;WAEA;WACA,iBAAiB;;WAEjB;;WAEA;;;UAIM;WACN,gBAAgB;;WAEhB;;;UAIM;;WAEN;;WAEA;;WAEA;WACA,MAAM,SAAS;;WAEf,iBAAiB;;;wBAaZ,WAAW,cAAc,iBAAgB,SAAiB;;wBAO1D,cAAc,cAAc,QAAQ,mBAAmB,UAAS,KAAK,gCAAqC;;wBAwB1G,UAAU,SAAS,eAAe;;wBA0ClC,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBAwBG,OAAO,yBAAyB,IAAI;;;;;;wBCxNpC,aAAa,eAAe;;;;;wBA+C5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { M as DEFAULT_ALLOWED, R as DEPENDENCY_FIELDS, N as HOME_PATTERNS, u as RULES, I as STRICT_OPTIONS, t as USAGE, n as annotations, z as cleanPath, B as codePackages, p as configsOfScript, r as createContext, L as cuePreset, et as defaultOptions, i as formatResult, X as globFolders, Z as globToRegExp, V as hasFile, g as hasTests, H as inFolder, k as isGitSpecifier, A as isPinned, y as isSourcePath, U as keyLine, W as lineOf, a as listRules, G as matchesAny, F as noBuildOutput, P as noLocalPaths, Q as packageFolders, tt as parseConfig, K as parseJsonc, b as pathsOf, j as pinnedGitDeps, o as readConfig, q as readJsonc, O as releaseFiles, S as repositoryOfRemote, D as requiredScripts, T as roadmapOfLine, E as roadmapParses, s as runChecks, c as runCli, J as runGit, C as runnerBudget, w as scheduleMinute, m as scriptsOf, x as sourceMain, Y as specifiersOf, l as summaryMarkdown, v as testsRequired, _ as tsconfigTest, h as typedFiles, f as typedScripts, $ as workspaceGlobs, d as workspaceProtocol } from "./run-d-5ceKnT.js";
|
|
@@ -1611,7 +1611,7 @@ if (board) {
|
|
|
1611
1611
|
* The rule `roadmap-parses`: each roadmap that a workflow gives to the Status page parses, on the pull request.
|
|
1612
1612
|
*/
|
|
1613
1613
|
/** A workflow file. */
|
|
1614
|
-
const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1614
|
+
const WORKFLOW$1 = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1615
1615
|
/** This function tells if a line calls the Pages workflow of the template (`uses: ...reusable-pages.yml`). */
|
|
1616
1616
|
function callsPages(line) {
|
|
1617
1617
|
let text = line.trimStart();
|
|
@@ -1620,7 +1620,7 @@ function callsPages(line) {
|
|
|
1620
1620
|
const value = text.slice(5).trim();
|
|
1621
1621
|
return /(?:^|\/)reusable-pages\.ya?ml(?:@|$|\s)/.test(value);
|
|
1622
1622
|
}
|
|
1623
|
-
const indentOf = (line) => line.length - line.trimStart().length;
|
|
1623
|
+
const indentOf$1 = (line) => line.length - line.trimStart().length;
|
|
1624
1624
|
/** This function tells if a line is `site-pages: false`: the site has no Status page. */
|
|
1625
1625
|
function noStatusPage(line) {
|
|
1626
1626
|
const text = line.trimStart();
|
|
@@ -1642,8 +1642,8 @@ function callsWithoutRoadmap(lines) {
|
|
|
1642
1642
|
const found = [];
|
|
1643
1643
|
lines.forEach((line, index) => {
|
|
1644
1644
|
if (!callsPages(line)) return;
|
|
1645
|
-
const indent = indentOf(line);
|
|
1646
|
-
const inJob = (text) => text.trim() === "" || indentOf(text) >= indent;
|
|
1645
|
+
const indent = indentOf$1(line);
|
|
1646
|
+
const inJob = (text) => text.trim() === "" || indentOf$1(text) >= indent;
|
|
1647
1647
|
let first = index;
|
|
1648
1648
|
while (first > 0 && inJob(lines[first - 1] ?? "")) first -= 1;
|
|
1649
1649
|
let last = index;
|
|
@@ -1685,7 +1685,7 @@ const roadmapParses = {
|
|
|
1685
1685
|
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
1686
1686
|
const named = [];
|
|
1687
1687
|
const breaks = [];
|
|
1688
|
-
for (const file of files.filter((path) => WORKFLOW.test(path)).sort(byCode)) {
|
|
1688
|
+
for (const file of files.filter((path) => WORKFLOW$1.test(path)).sort(byCode)) {
|
|
1689
1689
|
const lines = readFileSync(join(context.root, file), "utf8").split(/\r?\n/);
|
|
1690
1690
|
lines.forEach((line, index) => {
|
|
1691
1691
|
const roadmap = roadmapOfLine(line);
|
|
@@ -1735,6 +1735,233 @@ const roadmapParses = {
|
|
|
1735
1735
|
return breaks;
|
|
1736
1736
|
}
|
|
1737
1737
|
};
|
|
1738
|
+
// src/rules/runner-budget.ts
|
|
1739
|
+
/**
|
|
1740
|
+
* The rule `runner-budget`: the workflows share the runners of the account. Each matrix has a `max-parallel`, each
|
|
1741
|
+
* workflow has a concurrency group, and each schedule starts at the minute of its repository and file.
|
|
1742
|
+
*/
|
|
1743
|
+
/** A workflow file. */
|
|
1744
|
+
const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1745
|
+
const indentOf = (line) => line.length - line.trimStart().length;
|
|
1746
|
+
/** This function removes a comment at the end of a value, and the quotes around it. */
|
|
1747
|
+
function valueOf(raw) {
|
|
1748
|
+
const comment = raw.indexOf(" #");
|
|
1749
|
+
let value = (comment >= 0 ? raw.slice(0, comment) : raw).trim();
|
|
1750
|
+
const quote = value.charAt(0);
|
|
1751
|
+
if (value.length >= 2 && (quote === "\"" || quote === "'") && value.endsWith(quote)) value = value.slice(1, -1).trim();
|
|
1752
|
+
return value;
|
|
1753
|
+
}
|
|
1754
|
+
/** This function gives the value of the key `key` on a line, or undefined when the line has another key. */
|
|
1755
|
+
function keyValue(line, key) {
|
|
1756
|
+
let text = line.trimStart();
|
|
1757
|
+
if (text.startsWith("- ")) text = text.slice(2).trimStart();
|
|
1758
|
+
if (!text.startsWith(`${key}:`)) return void 0;
|
|
1759
|
+
return valueOf(text.slice(key.length + 1));
|
|
1760
|
+
}
|
|
1761
|
+
/** This function gives the lines of the block under the line `index`: the next lines with a larger indent. */
|
|
1762
|
+
function blockEnd(lines, index) {
|
|
1763
|
+
const indent = indentOf(lines[index] ?? "");
|
|
1764
|
+
let end = index + 1;
|
|
1765
|
+
while (end < lines.length) {
|
|
1766
|
+
const line = lines[end] ?? "";
|
|
1767
|
+
if (line.trim() !== "" && indentOf(line) <= indent) break;
|
|
1768
|
+
end += 1;
|
|
1769
|
+
}
|
|
1770
|
+
return end;
|
|
1771
|
+
}
|
|
1772
|
+
/** This function gives the indent of the first key of the block under the line `index`, or undefined for an empty block. */
|
|
1773
|
+
function childIndent(lines, index) {
|
|
1774
|
+
const end = blockEnd(lines, index);
|
|
1775
|
+
for (let i = index + 1; i < end; i++) if ((lines[i] ?? "").trim() !== "") return indentOf(lines[i] ?? "");
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* This function gives the minute (1 to 59) of the schedules of a workflow: the FNV-1a hash of the repository and the
|
|
1779
|
+
* file. Two repositories with the same workflow thus start at different minutes, and no schedule starts at minute 0,
|
|
1780
|
+
* where GitHub has the most load.
|
|
1781
|
+
*/
|
|
1782
|
+
function scheduleMinute(repository, file) {
|
|
1783
|
+
let hash = 2166136261;
|
|
1784
|
+
for (const char of `${repository.toLowerCase()}/${file}`) {
|
|
1785
|
+
hash ^= char.codePointAt(0) ?? 0;
|
|
1786
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
1787
|
+
}
|
|
1788
|
+
return hash % 59 + 1;
|
|
1789
|
+
}
|
|
1790
|
+
/** This function gives `owner/name` from a git remote URL, or undefined for a URL that is not of GitHub. */
|
|
1791
|
+
function repositoryOfRemote(url) {
|
|
1792
|
+
const text = url.trim();
|
|
1793
|
+
for (const prefix of [
|
|
1794
|
+
"git@github.com:",
|
|
1795
|
+
"ssh://git@github.com/",
|
|
1796
|
+
"https://github.com/",
|
|
1797
|
+
"http://github.com/",
|
|
1798
|
+
"git+https://github.com/"
|
|
1799
|
+
]) {
|
|
1800
|
+
if (!text.startsWith(prefix)) continue;
|
|
1801
|
+
let rest = text.slice(prefix.length);
|
|
1802
|
+
if (rest.endsWith("/")) rest = rest.slice(0, -1);
|
|
1803
|
+
if (rest.endsWith(".git")) rest = rest.slice(0, -4);
|
|
1804
|
+
const parts = rest.split("/");
|
|
1805
|
+
return parts.length === 2 && parts.every((part) => part !== "") ? rest : void 0;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
/** This function tells if a workflow is a shared workflow (`on: workflow_call`). Its caller gives the concurrency group. */
|
|
1809
|
+
function isShared(lines) {
|
|
1810
|
+
return lines.some((line) => {
|
|
1811
|
+
const text = line.trimStart();
|
|
1812
|
+
return text.startsWith("workflow_call:") || text === "workflow_call" || text === "- workflow_call" || text.startsWith("on:") && text.includes("workflow_call");
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
/** This function gives the jobs of a workflow. */
|
|
1816
|
+
function jobsOf(lines) {
|
|
1817
|
+
const jobs = lines.findIndex((line) => indentOf(line) === 0 && line.startsWith("jobs:"));
|
|
1818
|
+
if (jobs < 0) return [];
|
|
1819
|
+
const jobIndent = childIndent(lines, jobs);
|
|
1820
|
+
const end = blockEnd(lines, jobs);
|
|
1821
|
+
const found = [];
|
|
1822
|
+
for (let i = jobs + 1; i < end; i++) {
|
|
1823
|
+
const line = lines[i] ?? "";
|
|
1824
|
+
if (line.trim() === "" || indentOf(line) !== jobIndent) continue;
|
|
1825
|
+
const keyIndent = childIndent(lines, i);
|
|
1826
|
+
const keys = lines.slice(i + 1, blockEnd(lines, i)).filter((text) => indentOf(text) === keyIndent);
|
|
1827
|
+
const uses = keys.map((text) => keyValue(text, "uses")).find((value) => value !== void 0);
|
|
1828
|
+
const at = uses === void 0 ? -1 : uses.indexOf(".github/workflows/");
|
|
1829
|
+
const calls = uses === void 0 || at < 0 ? void 0 : uses.slice(at + 18).split("@")[0] ?? "";
|
|
1830
|
+
found.push({
|
|
1831
|
+
name: line.trim().replace(/:$/, ""),
|
|
1832
|
+
line: i + 1,
|
|
1833
|
+
grouped: keys.some((text) => keyValue(text, "concurrency") !== void 0),
|
|
1834
|
+
...calls === void 0 ? {} : { calls }
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
return found;
|
|
1838
|
+
}
|
|
1839
|
+
const hasTopGroup = (lines) => lines.some((line) => indentOf(line) === 0 && line.startsWith("concurrency:"));
|
|
1840
|
+
/**
|
|
1841
|
+
* This function gives the breaks of the concurrency groups. A workflow with no group at the top needs one in each job.
|
|
1842
|
+
* A job that calls a shared workflow of `grouped` gets its group from the jobs of that workflow. A shared workflow gets
|
|
1843
|
+
* its group from its caller, but a shared workflow of `grouped` has a group in each job.
|
|
1844
|
+
*/
|
|
1845
|
+
function concurrencyBreaks(file, lines, grouped) {
|
|
1846
|
+
const name = file.slice(file.lastIndexOf("/") + 1);
|
|
1847
|
+
const jobs = jobsOf(lines);
|
|
1848
|
+
if (isShared(lines)) {
|
|
1849
|
+
if (!grouped.includes(name)) return [];
|
|
1850
|
+
return jobs.filter((job) => !job.grouped).map((job) => ({
|
|
1851
|
+
file,
|
|
1852
|
+
line: job.line,
|
|
1853
|
+
message: `${file}: the job ${job.name} has no concurrency group, and its callers rely on it (the option grouped).`
|
|
1854
|
+
}));
|
|
1855
|
+
}
|
|
1856
|
+
if (hasTopGroup(lines)) return [];
|
|
1857
|
+
return jobs.filter((job) => !job.grouped && !(job.calls !== void 0 && grouped.includes(job.calls))).map((job) => ({
|
|
1858
|
+
file,
|
|
1859
|
+
line: job.line,
|
|
1860
|
+
message: `${file}: the job ${job.name} has no concurrency group, and the workflow has none.`
|
|
1861
|
+
}));
|
|
1862
|
+
}
|
|
1863
|
+
/** This function gives the breaks of the matrices: each `strategy` with a `matrix` has a `max-parallel` of `limit` or less. */
|
|
1864
|
+
function matrixBreaks(file, lines, limit) {
|
|
1865
|
+
const breaks = [];
|
|
1866
|
+
lines.forEach((line, index) => {
|
|
1867
|
+
if (keyValue(line, "strategy") === void 0) return;
|
|
1868
|
+
const keyIndent = childIndent(lines, index);
|
|
1869
|
+
const keys = lines.slice(index + 1, blockEnd(lines, index)).filter((text) => indentOf(text) === keyIndent);
|
|
1870
|
+
if (!keys.some((text) => keyValue(text, "matrix") !== void 0)) return;
|
|
1871
|
+
const raw = keys.map((text) => keyValue(text, "max-parallel")).find((value) => value !== void 0);
|
|
1872
|
+
const value = raw === void 0 ? NaN : Number(raw);
|
|
1873
|
+
if (raw === void 0) breaks.push({
|
|
1874
|
+
file,
|
|
1875
|
+
line: index + 1,
|
|
1876
|
+
message: `${file}: a matrix has no max-parallel.`
|
|
1877
|
+
});
|
|
1878
|
+
else if (!Number.isInteger(value) || value < 1 || value > limit) breaks.push({
|
|
1879
|
+
file,
|
|
1880
|
+
line: index + 1,
|
|
1881
|
+
message: `${file}: a matrix has max-parallel ${raw}, and the most is ${String(limit)}.`
|
|
1882
|
+
});
|
|
1883
|
+
});
|
|
1884
|
+
return breaks;
|
|
1885
|
+
}
|
|
1886
|
+
/** This function gives the breaks of the schedules: the minute of each `cron` is the minute of the repository and the file. */
|
|
1887
|
+
function cronBreaks(file, lines, minute) {
|
|
1888
|
+
const breaks = [];
|
|
1889
|
+
lines.forEach((line, index) => {
|
|
1890
|
+
const value = keyValue(line, "cron");
|
|
1891
|
+
if (value === void 0) return;
|
|
1892
|
+
const fields = value.split(" ").filter((field) => field !== "");
|
|
1893
|
+
if (fields[0] === String(minute)) return;
|
|
1894
|
+
const expected = [String(minute), ...fields.slice(1)].join(" ");
|
|
1895
|
+
breaks.push({
|
|
1896
|
+
file,
|
|
1897
|
+
line: index + 1,
|
|
1898
|
+
message: `${file}: the schedule "${value}" starts at minute ${fields[0] ?? "?"}, and the minute of this repository and file is ${String(minute)}.`,
|
|
1899
|
+
fix: `cron: "${expected}"`
|
|
1900
|
+
});
|
|
1901
|
+
});
|
|
1902
|
+
return breaks;
|
|
1903
|
+
}
|
|
1904
|
+
const runnerBudget = {
|
|
1905
|
+
id: "runner-budget",
|
|
1906
|
+
title: "Each matrix has a max-parallel of 3 or less, each workflow has a concurrency group, and each schedule starts at the minute that the repository and the file give.",
|
|
1907
|
+
reason: "All repositories of the account share 40 runners, and heavy work keeps at most 28 of them. On 2026-10-30, a matrix with no max-parallel and the sync pull requests of about 20 repositories filled 39 of the 40 runners, with 88 jobs in the queue. Each repository copied the weekly scan at `23 5 * * 1`, so all scans started at the same minute. A workflow with no concurrency group starts a new run on each push, and the old runs keep their runners.",
|
|
1908
|
+
fix: "Add `max-parallel: 3` (or less) under `strategy`. Add a concurrency group at the top of the workflow (`concurrency: { group: <name>-${{ github.ref }}, cancel-in-progress: true }`), or in each job. Change the minute of each `cron` to the minute that the message gives; the hour and the days stay.",
|
|
1909
|
+
sources: [{
|
|
1910
|
+
repo: "fleet",
|
|
1911
|
+
rule: "runner-slots",
|
|
1912
|
+
doc: "docs/STRATEGY.md (2026-10-30, the runner slots: a cap of 40, heavy work at most 28)"
|
|
1913
|
+
}],
|
|
1914
|
+
options: {
|
|
1915
|
+
maxParallel: {
|
|
1916
|
+
type: "number",
|
|
1917
|
+
default: 3,
|
|
1918
|
+
description: "The largest max-parallel of a matrix."
|
|
1919
|
+
},
|
|
1920
|
+
minute: {
|
|
1921
|
+
type: "boolean",
|
|
1922
|
+
default: true,
|
|
1923
|
+
description: "When false, the rule does not examine the minute of the schedules."
|
|
1924
|
+
},
|
|
1925
|
+
grouped: {
|
|
1926
|
+
type: "strings",
|
|
1927
|
+
default: ["reusable-ai-review.yml", "reusable-codex-review.yml"],
|
|
1928
|
+
description: "The shared workflows that give a concurrency group in each of their jobs. A job that calls one needs no group of its own."
|
|
1929
|
+
}
|
|
1930
|
+
},
|
|
1931
|
+
check(context, options) {
|
|
1932
|
+
const files = context.gitFiles();
|
|
1933
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
1934
|
+
const workflows = files.filter((path) => WORKFLOW.test(path)).sort(byCode);
|
|
1935
|
+
if (workflows.length === 0) return { skipped: "the repository has no workflow" };
|
|
1936
|
+
const remote = context.git([
|
|
1937
|
+
"remote",
|
|
1938
|
+
"get-url",
|
|
1939
|
+
"origin"
|
|
1940
|
+
]);
|
|
1941
|
+
const repository = context.env["GITHUB_REPOSITORY"] ?? (remote === void 0 ? void 0 : repositoryOfRemote(remote));
|
|
1942
|
+
const limit = Number(options["maxParallel"]);
|
|
1943
|
+
const grouped = Array.isArray(options["grouped"]) ? options["grouped"] : [];
|
|
1944
|
+
const breaks = [];
|
|
1945
|
+
for (const file of workflows) {
|
|
1946
|
+
let text;
|
|
1947
|
+
try {
|
|
1948
|
+
text = readFileSync(join(context.root, file), "utf8");
|
|
1949
|
+
} catch {
|
|
1950
|
+
continue;
|
|
1951
|
+
}
|
|
1952
|
+
const lines = text.split(/\r?\n/).map((line) => line.trimStart().startsWith("#") ? "" : line);
|
|
1953
|
+
breaks.push(...matrixBreaks(file, lines, limit), ...concurrencyBreaks(file, lines, grouped));
|
|
1954
|
+
if (options["minute"] !== false) {
|
|
1955
|
+
if (lines.some((line) => keyValue(line, "cron") !== void 0) && repository === void 0) breaks.push({
|
|
1956
|
+
file,
|
|
1957
|
+
message: `${file} has a schedule, and the rule cannot find the repository (GITHUB_REPOSITORY, or a GitHub URL of the remote origin).`
|
|
1958
|
+
});
|
|
1959
|
+
else if (repository !== void 0) breaks.push(...cronBreaks(file, lines, scheduleMinute(repository, file)));
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
return breaks;
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1738
1965
|
// src/rules/source-main.ts
|
|
1739
1966
|
/**
|
|
1740
1967
|
* The rule `source-main`: a workspace package is a source package, and a public package moves its
|
|
@@ -2397,7 +2624,8 @@ const RULES = [
|
|
|
2397
2624
|
typedScripts,
|
|
2398
2625
|
typedFiles,
|
|
2399
2626
|
testsRequired,
|
|
2400
|
-
roadmapParses
|
|
2627
|
+
roadmapParses,
|
|
2628
|
+
runnerBudget
|
|
2401
2629
|
];
|
|
2402
2630
|
// src/run.ts
|
|
2403
2631
|
/**
|
|
@@ -2687,6 +2915,6 @@ function runCli(args, io) {
|
|
|
2687
2915
|
if (summary) appendFileSync(summary, summaryMarkdown(result));
|
|
2688
2916
|
return result.failed ? 1 : 0;
|
|
2689
2917
|
}
|
|
2690
|
-
export {
|
|
2918
|
+
export { workspaceGlobs as $, isPinned as A, codePackages as B, runnerBudget as C, requiredScripts as D, roadmapParses as E, noBuildOutput as F, matchesAny as G, inFolder as H, STRICT_OPTIONS as I, runGit as J, parseJsonc as K, cuePreset as L, DEFAULT_ALLOWED as M, HOME_PATTERNS as N, releaseFiles as O, noLocalPaths as P, packageFolders as Q, DEPENDENCY_FIELDS as R, repositoryOfRemote as S, roadmapOfLine as T, keyLine as U, hasFile as V, lineOf as W, globFolders as X, specifiersOf as Y, globToRegExp as Z, tsconfigTest as _, listRules as a, pathsOf as b, runCli as c, workspaceProtocol as d, defaultOptions as et, typedScripts as f, hasTests as g, typedFiles as h, formatResult as i, pinnedGitDeps as j, isGitSpecifier as k, summaryMarkdown as l, scriptsOf as m, annotations as n, readConfig as o, configsOfScript as p, readJsonc as q, createContext as r, runChecks as s, USAGE as t, parseConfig as tt, RULES as u, testsRequired as v, scheduleMinute as w, sourceMain as x, isSourcePath as y, cleanPath as z };
|
|
2691
2919
|
|
|
2692
|
-
//# sourceMappingURL=run-
|
|
2920
|
+
//# sourceMappingURL=run-d-5ceKnT.js.map
|