@mark1russell7/conventions 0.10.0 → 0.11.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 +3 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +25 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/{run-DvvaHCjC.js → run-BRZBN04H.js} +368 -50
- package/build/run-BRZBN04H.js.map +1 -0
- package/package.json +1 -1
- package/build/run-DvvaHCjC.js.map +0 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ Each break shows the file, the line, the rule and the fix. In GitHub Actions, th
|
|
|
27
27
|
- `typed-files`: a config file at the root of a package (`vitest.config.ts`). The fix adds `*.config.ts` and `rootDir: "."` to the `tsconfig.test.json` of the package, when that file has no comments.
|
|
28
28
|
- `trust-policy`: the settings `trustPolicy`, `trustPolicyIgnoreAfter` and `trustPolicyExclude` of `pnpm-workspace.yaml`. The fix makes the file when the repository has none.
|
|
29
29
|
- `main-check`: a compare of `process.argv[1]` with the path of the script. The fix writes `import.meta.main` when each Node version of `engines.node` has it (`^22.18`, `>=24.2`). Else it writes a compare of the two real paths, and it adds the imports. It removes the imports that only the old compare used.
|
|
30
|
+
- `gate-trigger`: a path filter on the pull request trigger of a gate. The fix removes the filter and adds a job `changes` with the same patterns. Each other job needs it and has an `if` on its match. A summary job `<Name> OK` with the action `gate-summary` needs each job. A job with its own `if`, and each job that needs such a job, can be skipped (`allow-skip`). Some workflows need a person, because the fix cannot convert them with certainty. Examples are a trigger in the flow form, an `if` of more than one line, and a job `changes` that already exists.
|
|
30
31
|
|
|
31
32
|
The text output marks each break that has a fix. In the JSON output, such a break has `fixable: true`. The release train starts `conventions fix` in its update pull requests. Thus a break that a script can fix does not block a repository.
|
|
32
33
|
|
|
@@ -52,6 +53,7 @@ The rules come from the invariants audit of 2026-10-26 (strategy item s38). The
|
|
|
52
53
|
| `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). |
|
|
53
54
|
| `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). |
|
|
54
55
|
| `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). |
|
|
56
|
+
| `gate-trigger` | No workflow has `paths` or `paths-ignore` on `on.pull_request` or `on.pull_request_target`. The ruleset needs the summary check `<Name> OK` of each gate, and a workflow with a path filter does not start on each pull request. Then its check is not there, the ruleset cannot ask for it, and a pull request can merge before the gate ends. A gate uses the actions `changes` and `gate-summary` of the template (`CI.md`, "A gate with paths"). | fleet `gate-trigger` (STRATEGY.md, 2026-11-02). |
|
|
55
57
|
|
|
56
58
|
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`.
|
|
57
59
|
|
|
@@ -107,6 +109,7 @@ An unknown rule, an unknown option, or an exception or a changed option without
|
|
|
107
109
|
| `runner-budget.maxParallel` | `3` | The largest `max-parallel` of a matrix. |
|
|
108
110
|
| `runner-budget.minute` | `true` | When `false`, the rule does not examine the minute of the schedules. |
|
|
109
111
|
| `runner-budget.grouped` | `["reusable-ai-review.yml", "reusable-codex-review.yml"]` | The shared workflows that give a concurrency group in each of their jobs. |
|
|
112
|
+
| `gate-trigger.allow` | `[]` | The file names of the workflows that can filter pull requests by path, because they are not a gate (for example a preview). |
|
|
110
113
|
|
|
111
114
|
## Commands
|
|
112
115
|
|
package/build/cli.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -152,6 +152,30 @@ export declare function parseConfig(value: unknown, rules: readonly Rule[]): Con
|
|
|
152
152
|
/** The compiler options that make the type check strict. A package does not turn them off. */
|
|
153
153
|
export declare const STRICT_OPTIONS: readonly ["strict", "noImplicitAny", "strictNullChecks", "strictFunctionTypes", "strictBindCallApply", "strictPropertyInitialization", "strictBuiltinIteratorReturn", "noImplicitThis", "useUnknownInCatchVariables", "alwaysStrict", "noUncheckedIndexedAccess", "exactOptionalPropertyTypes", "noImplicitOverride", "noImplicitReturns", "noFallthroughCasesInSwitch", "noPropertyAccessFromIndexSignature"];
|
|
154
154
|
export declare const cuePreset: Rule;
|
|
155
|
+
/** A path filter of a pull request trigger: the line (from 1), the trigger and the key. */
|
|
156
|
+
interface PathFilter {
|
|
157
|
+
readonly line: number;
|
|
158
|
+
readonly trigger: string;
|
|
159
|
+
readonly key: string;
|
|
160
|
+
}
|
|
161
|
+
/** This function gives the path filters of the pull request triggers of a workflow. */
|
|
162
|
+
export declare function prPathFilters(text: string): PathFilter[];
|
|
163
|
+
/** The commit of the template with the actions `changes` and `gate-summary`. Renovate updates the pins after the fix. */
|
|
164
|
+
export declare const ACTIONS_COMMIT: string;
|
|
165
|
+
/** This function gives the name of the summary check of a workflow: its name with "OK", in the form that ruleset-ci-ok.ts reads. */
|
|
166
|
+
export declare function summaryName(workflowName: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* This function converts a gate workflow with a path filter on its pull request trigger. The trigger loses the filter,
|
|
169
|
+
* and a job `changes` gets the same patterns. Each other job needs it and runs only on a match. A summary job
|
|
170
|
+
* `<Name> OK` with the action gate-summary needs each job. The function gives the new text, or the reason why a
|
|
171
|
+
* person must convert the workflow.
|
|
172
|
+
*/
|
|
173
|
+
export declare function convertGate(text: string, file: string, commit?: string): {
|
|
174
|
+
text: string;
|
|
175
|
+
} | {
|
|
176
|
+
reason: string;
|
|
177
|
+
};
|
|
178
|
+
export declare const gateTrigger: Rule;
|
|
155
179
|
/** The compare of two real paths. It is true through a link too, and it works on each Node version. */
|
|
156
180
|
export declare const REAL_COMPARE = "process.argv[1] !== undefined && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))";
|
|
157
181
|
/** This function tells if each Node version of the range has `import.meta.main`: 22.18 and later in 22, and 24.2 and later. Node 23 does not have it. */
|
|
@@ -306,5 +330,5 @@ export declare function workspaceGlobs(root: string): string[] | undefined;
|
|
|
306
330
|
* The result has absolute paths, in the order of the code units.
|
|
307
331
|
*/
|
|
308
332
|
export declare function packageFolders(root: string, globs?: readonly string[] | undefined): string[];
|
|
309
|
-
export type { AuditSource, Break, CheckOptions, CheckResult, CliIo, ConventionsConfig, Edit, FixResult, Manifest, OptionSpec, OptionValue, Options, PackageInfo, Rule, RuleConfig, RuleContext, RuleOutcome, RuleResult };
|
|
333
|
+
export type { AuditSource, Break, CheckOptions, CheckResult, CliIo, ConventionsConfig, Edit, FixResult, Manifest, OptionSpec, OptionValue, Options, PackageInfo, PathFilter, Rule, RuleConfig, RuleContext, RuleOutcome, RuleResult };
|
|
310
334
|
//# sourceMappingURL=index.d.ts.map
|
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/main-check.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/trust-policy.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;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;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;;UCrM9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/rules/main-check.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/trust-policy.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;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;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;;UCrM9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;;UCtFP;WACN;WACA;WACA;;;wBAIK,cAAc,eAAe;;qBAoBhC;;wBAgCG,YAAY;;;;;;;wBAkBZ,YAAY,cAAc,cAAc;EAAoC;;EAAmB;;qBA8IlG,aAAa;;qBC1Nb;;wBA6BG,kBAAkB;qBAiFrB,WAAW;qBCxHX,eAAe;;qBCYf;;qBAGA,wBAAwB;qBAOxB,cAAc;;wBCnBX,eAAe;;;;;wBAaf,SAAS,cAAc;qBAqB1B,eAAe;qBCEf,cAAc;qBCrBd,iBAAiB;;wBCqCd,cAAc;qBAajB,eAAe;;;;;;wBC3DZ,eAAe,oBAAoB;;wBAUnC,mBAAmB;qBAsJtB,cAAc;;wBCrKX,QAAQ;;wBAQR,aAAa;qBAKhB,YAAY;qBCkBZ,eAAe;;wBCpBZ,SAAS,0BAA0B;qBAKtC,cAAc;;wBCiCX,gBAAgB;;;;;wBA4BhB,UAAU,SAAS,SAAS,0BAA0B,cAAc,OAAM;qBAgG7E,YAAY;qBCjJZ,cAAc;;qBC3Bd;;qBAGA;qBA6DA,aAAa;qBCnEb,mBAAmB;;qBCenB,gBAAgB;;UCXZ;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;;UAoCjC;;WAEN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA0BG,OAAO,yBAAyB,IAAI;;;;;;wBC9QpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { I as DEFAULT_ALLOWED,
|
|
1
|
+
export { U as ACTIONS_COMMIT, I as DEFAULT_ALLOWED, X as DEPENDENCY_FIELDS, L as HOME_PATTERNS, p as IGNORE_AFTER, B as REAL_COMPARE, d as RULES, J as STRICT_OPTIONS, m as TRAIN_SCOPES, t as USAGE, n as annotations, Z as cleanPath, Q as codePackages, _ as configsOfScript, W as convertGate, r as createContext, Y as cuePreset, pt as defaultOptions, i as formatResult, G as gateTrigger, lt as globFolders, ut as globToRegExp, $ as hasFile, V as hasImportMetaMain, x as hasTests, et as inFolder, N as isGitSpecifier, P as isPinned, C as isSourcePath, tt as keyLine, nt as lineOf, a as listRules, H as mainCheck, rt as matchesAny, z as noBuildOutput, R as noLocalPaths, dt as packageFolders, mt as parseConfig, it as parseJsonc, w as pathsOf, F as pinnedGitDeps, K as prPathFilters, o as readConfig, at as readJsonc, M as releaseFiles, ot as replaceLine, E as repositoryOfRemote, j as requiredScripts, k as roadmapOfLine, A as roadmapParses, s as runChecks, c as runCli, l as runFix, st as runGit, D as runnerBudget, O as scheduleMinute, v as scriptsOf, T as sourceMain, ct as specifiersOf, u as summaryMarkdown, q as summaryName, b as testsRequired, h as trustPolicy, S as tsconfigTest, y as typedFiles, g as typedScripts, ft as workspaceGlobs, f as workspaceProtocol } from "./run-BRZBN04H.js";
|
|
@@ -503,6 +503,356 @@ const cuePreset = {
|
|
|
503
503
|
return breaks;
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
|
+
// src/workflow.ts
|
|
507
|
+
/**
|
|
508
|
+
* A small reader of GitHub workflow files, by the indent of the lines. The rules that read workflows share it. It
|
|
509
|
+
* knows the block form and the inline values of keys, which is what the workflows of the template use.
|
|
510
|
+
*/
|
|
511
|
+
/** A workflow file. */
|
|
512
|
+
const WORKFLOW$1 = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
513
|
+
const indentOf$1 = (line) => line.length - line.trimStart().length;
|
|
514
|
+
/** This function gives the lines of a workflow, with each line of a comment made empty. */
|
|
515
|
+
const workflowLines = (text) => text.split(/\r?\n/).map((line) => line.trimStart().startsWith("#") ? "" : line);
|
|
516
|
+
/** This function removes a comment at the end of a value, and the quotes around it. */
|
|
517
|
+
function valueOf$1(raw) {
|
|
518
|
+
const comment = raw.indexOf(" #");
|
|
519
|
+
let value = (comment >= 0 ? raw.slice(0, comment) : raw).trim();
|
|
520
|
+
const quote = value.charAt(0);
|
|
521
|
+
if (value.length >= 2 && (quote === "\"" || quote === "'") && value.endsWith(quote)) value = value.slice(1, -1).trim();
|
|
522
|
+
return value;
|
|
523
|
+
}
|
|
524
|
+
/** This function gives the value of the key `key` on a line, or undefined when the line has another key. A quoted key ("on") counts too. */
|
|
525
|
+
function keyValue(line, key) {
|
|
526
|
+
let text = line.trimStart();
|
|
527
|
+
if (text.startsWith("- ")) text = text.slice(2).trimStart();
|
|
528
|
+
for (const form of [
|
|
529
|
+
key,
|
|
530
|
+
`"${key}"`,
|
|
531
|
+
`'${key}'`
|
|
532
|
+
]) if (text.startsWith(`${form}:`)) return valueOf$1(text.slice(form.length + 1));
|
|
533
|
+
}
|
|
534
|
+
/** This function gives the end of the block under the line `index`. The end is the next line with the same indent or a smaller one. */
|
|
535
|
+
function blockEnd(lines, index) {
|
|
536
|
+
const indent = indentOf$1(lines[index] ?? "");
|
|
537
|
+
let end = index + 1;
|
|
538
|
+
while (end < lines.length) {
|
|
539
|
+
const line = lines[end] ?? "";
|
|
540
|
+
if (line.trim() !== "" && indentOf$1(line) <= indent) break;
|
|
541
|
+
end += 1;
|
|
542
|
+
}
|
|
543
|
+
return end;
|
|
544
|
+
}
|
|
545
|
+
/** This function gives the indent of the first key of the block under the line `index`, or undefined for an empty block. */
|
|
546
|
+
function childIndent(lines, index) {
|
|
547
|
+
const end = blockEnd(lines, index);
|
|
548
|
+
for (let i = index + 1; i < end; i++) if ((lines[i] ?? "").trim() !== "") return indentOf$1(lines[i] ?? "");
|
|
549
|
+
}
|
|
550
|
+
/** This function gives the indexes of the keys of the block under the line `index`: the lines at the indent of its first key. */
|
|
551
|
+
function childKeys(lines, index) {
|
|
552
|
+
const indent = childIndent(lines, index);
|
|
553
|
+
if (indent === void 0) return [];
|
|
554
|
+
const keys = [];
|
|
555
|
+
for (let i = index + 1; i < blockEnd(lines, index); i++) if ((lines[i] ?? "").trim() !== "" && indentOf$1(lines[i] ?? "") === indent) keys.push(i);
|
|
556
|
+
return keys;
|
|
557
|
+
}
|
|
558
|
+
// src/rules/gate-trigger.ts
|
|
559
|
+
/**
|
|
560
|
+
* The rule `gate-trigger`: a workflow that runs on pull requests starts on each pull request, with no path filter. The
|
|
561
|
+
* ruleset needs the summary check "<Name> OK" of each gate. A workflow with `on.pull_request.paths` does not start
|
|
562
|
+
* on each pull request, so its check is not always there, and the ruleset cannot ask for it.
|
|
563
|
+
*/
|
|
564
|
+
const TRIGGERS = ["pull_request", "pull_request_target"];
|
|
565
|
+
const FILTERS = ["paths", "paths-ignore"];
|
|
566
|
+
/** This function gives the path filters of the pull request triggers of a workflow. */
|
|
567
|
+
function prPathFilters(text) {
|
|
568
|
+
const lines = workflowLines(text);
|
|
569
|
+
const on = lines.findIndex((line) => indentOf$1(line) === 0 && keyValue(line, "on") !== void 0);
|
|
570
|
+
if (on < 0) return [];
|
|
571
|
+
if ((keyValue(lines[on] ?? "", "on") ?? "") !== "") return [];
|
|
572
|
+
const found = [];
|
|
573
|
+
for (const at of childKeys(lines, on)) for (const trigger of TRIGGERS) {
|
|
574
|
+
const value = keyValue(lines[at] ?? "", trigger);
|
|
575
|
+
if (value === void 0) continue;
|
|
576
|
+
for (const key of FILTERS) if (new RegExp(`(^|[{,\\s])${key}\\s*:`).test(value)) found.push({
|
|
577
|
+
line: at + 1,
|
|
578
|
+
trigger,
|
|
579
|
+
key
|
|
580
|
+
});
|
|
581
|
+
for (const child of childKeys(lines, at)) for (const key of FILTERS) if (keyValue(lines[child] ?? "", key) !== void 0) found.push({
|
|
582
|
+
line: child + 1,
|
|
583
|
+
trigger,
|
|
584
|
+
key
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return found;
|
|
588
|
+
}
|
|
589
|
+
/** The commit of the template with the actions `changes` and `gate-summary`. Renovate updates the pins after the fix. */
|
|
590
|
+
const ACTIONS_COMMIT = "f05c6eeb35e33a040bdfdcd7d07a1d2c00640f8d";
|
|
591
|
+
/** This function gives the items of a list value: the flow form `[a, "b"]`, or the block form under the line `index`. */
|
|
592
|
+
function listItems(lines, index, value) {
|
|
593
|
+
if (value.startsWith("[") && value.endsWith("]")) return {
|
|
594
|
+
items: value.slice(1, -1).split(",").map((item) => valueOf$1(item)).filter((item) => item !== ""),
|
|
595
|
+
end: index + 1
|
|
596
|
+
};
|
|
597
|
+
if (value !== "") return void 0;
|
|
598
|
+
const indent = indentOf$1(lines[index] ?? "");
|
|
599
|
+
const items = [];
|
|
600
|
+
let end = index + 1;
|
|
601
|
+
for (let i = index + 1; i < lines.length; i++) {
|
|
602
|
+
const line = lines[i] ?? "";
|
|
603
|
+
if (line.trim() === "") continue;
|
|
604
|
+
if (!(indentOf$1(line) > indent || indentOf$1(line) === indent && line.trimStart().startsWith("- "))) break;
|
|
605
|
+
if (!line.trimStart().startsWith("- ")) return void 0;
|
|
606
|
+
items.push(valueOf$1(line.trimStart().slice(2)));
|
|
607
|
+
end = i + 1;
|
|
608
|
+
}
|
|
609
|
+
return {
|
|
610
|
+
items,
|
|
611
|
+
end
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
/** This function gives the name of the summary check of a workflow: its name with "OK", in the form that ruleset-ci-ok.ts reads. */
|
|
615
|
+
function summaryName(workflowName) {
|
|
616
|
+
const words = workflowName.replace(/[^A-Za-z0-9]+/g, " ").trim();
|
|
617
|
+
return `${words === "" ? "Gate" : words.charAt(0).toUpperCase() + words.slice(1)} OK`;
|
|
618
|
+
}
|
|
619
|
+
/** This function puts an expression into the value of an `if`, as YAML that keeps it. */
|
|
620
|
+
const ifValue = (expression) => {
|
|
621
|
+
const value = `\${{ ${expression} }}`;
|
|
622
|
+
return value.includes(": ") || value.includes(" #") ? `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"` : value;
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* This function converts a gate workflow with a path filter on its pull request trigger. The trigger loses the filter,
|
|
626
|
+
* and a job `changes` gets the same patterns. Each other job needs it and runs only on a match. A summary job
|
|
627
|
+
* `<Name> OK` with the action gate-summary needs each job. The function gives the new text, or the reason why a
|
|
628
|
+
* person must convert the workflow.
|
|
629
|
+
*/
|
|
630
|
+
function convertGate(text, file, commit = ACTIONS_COMMIT) {
|
|
631
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
632
|
+
const original = text.split(/\r?\n/);
|
|
633
|
+
const lines = workflowLines(text);
|
|
634
|
+
const top = (key) => lines.findIndex((line) => indentOf$1(line) === 0 && keyValue(line, key) !== void 0);
|
|
635
|
+
const on = top("on");
|
|
636
|
+
const jobsAt = top("jobs");
|
|
637
|
+
if (on < 0 || jobsAt < 0) return { reason: "the workflow has no on block or no jobs block" };
|
|
638
|
+
const splices = [];
|
|
639
|
+
const filters = {};
|
|
640
|
+
for (const at of childKeys(lines, on)) {
|
|
641
|
+
const trigger = TRIGGERS.find((name) => keyValue(lines[at] ?? "", name) !== void 0);
|
|
642
|
+
if (trigger === void 0) continue;
|
|
643
|
+
if ((keyValue(lines[at] ?? "", trigger) ?? "") !== "") return { reason: `on.${trigger} has the flow form` };
|
|
644
|
+
let filtered = false;
|
|
645
|
+
for (const child of childKeys(lines, at)) {
|
|
646
|
+
const key = FILTERS.find((name) => keyValue(lines[child] ?? "", name) !== void 0);
|
|
647
|
+
if (key === void 0) continue;
|
|
648
|
+
const list = listItems(lines, child, keyValue(lines[child] ?? "", key) ?? "");
|
|
649
|
+
if (list === void 0) return { reason: `on.${trigger}.${key} is not a list` };
|
|
650
|
+
const before = filters[key];
|
|
651
|
+
if (before !== void 0 && before.join("\n") !== list.items.join("\n")) return { reason: `the triggers have different ${key}` };
|
|
652
|
+
filters[key] = list.items;
|
|
653
|
+
splices.push({
|
|
654
|
+
at: child,
|
|
655
|
+
remove: list.end - child,
|
|
656
|
+
insert: []
|
|
657
|
+
});
|
|
658
|
+
filtered = true;
|
|
659
|
+
}
|
|
660
|
+
if (filtered) {
|
|
661
|
+
const pad = " ".repeat(indentOf$1(lines[at] ?? ""));
|
|
662
|
+
splices.push({
|
|
663
|
+
at,
|
|
664
|
+
remove: 0,
|
|
665
|
+
insert: [`${pad}# Each pull request starts this workflow, so its summary check is always there. The job changes skips the`, `${pad}# work when the pull request changes no file of the gate (CI.md of the template, "A gate with paths").`]
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (Object.keys(filters).length === 0) return { reason: "the workflow has no path filter on a pull request trigger" };
|
|
670
|
+
const jobs = childKeys(lines, jobsAt);
|
|
671
|
+
const first = jobs[0];
|
|
672
|
+
if (first === void 0) return { reason: "the workflow has no job" };
|
|
673
|
+
const ids = jobs.map((at) => (lines[at] ?? "").trim().replace(/:$/, ""));
|
|
674
|
+
const jobIndent = " ".repeat(indentOf$1(lines[first] ?? ""));
|
|
675
|
+
const unit = " ".repeat((childIndent(lines, first) ?? indentOf$1(lines[first] ?? "") + 2) - jobIndent.length);
|
|
676
|
+
const nameAt = top("name");
|
|
677
|
+
const name = summaryName(nameAt >= 0 ? keyValue(lines[nameAt] ?? "", "name") ?? "" : (file.split("/").pop() ?? "").replace(/\.ya?ml$/, ""));
|
|
678
|
+
const summaryId = name.toLowerCase().replaceAll(" ", "-");
|
|
679
|
+
for (const id of ["changes", summaryId]) if (ids.includes(id)) return { reason: `the workflow already has a job ${id}` };
|
|
680
|
+
const needsOf = /* @__PURE__ */ new Map();
|
|
681
|
+
const own = /* @__PURE__ */ new Set();
|
|
682
|
+
for (const [index, at] of jobs.entries()) {
|
|
683
|
+
const id = ids[index] ?? "";
|
|
684
|
+
const keys = childKeys(lines, at);
|
|
685
|
+
const pad = " ".repeat(childIndent(lines, at) ?? indentOf$1(lines[at] ?? "") + unit.length);
|
|
686
|
+
const needsAt = keys.find((key) => keyValue(lines[key] ?? "", "needs") !== void 0);
|
|
687
|
+
const ifAt = keys.find((key) => keyValue(lines[key] ?? "", "if") !== void 0);
|
|
688
|
+
if (needsAt === void 0) {
|
|
689
|
+
needsOf.set(id, []);
|
|
690
|
+
splices.push({
|
|
691
|
+
at: at + 1,
|
|
692
|
+
remove: 0,
|
|
693
|
+
insert: [`${pad}needs: changes`]
|
|
694
|
+
});
|
|
695
|
+
} else {
|
|
696
|
+
const value = keyValue(lines[needsAt] ?? "", "needs") ?? "";
|
|
697
|
+
const list = value === "" || value.startsWith("[") ? listItems(lines, needsAt, value) : {
|
|
698
|
+
items: [value],
|
|
699
|
+
end: needsAt + 1
|
|
700
|
+
};
|
|
701
|
+
if (list === void 0) return { reason: `the needs of the job ${id} is not a list` };
|
|
702
|
+
needsOf.set(id, list.items);
|
|
703
|
+
if (value === "") {
|
|
704
|
+
const item = lines.findIndex((line, i) => i > needsAt && line.trim() !== "");
|
|
705
|
+
splices.push({
|
|
706
|
+
at: item,
|
|
707
|
+
remove: 0,
|
|
708
|
+
insert: [`${" ".repeat(indentOf$1(lines[item] ?? ""))}- changes`]
|
|
709
|
+
});
|
|
710
|
+
} else splices.push({
|
|
711
|
+
at: needsAt,
|
|
712
|
+
remove: 1,
|
|
713
|
+
insert: [`${pad}needs: [${["changes", ...list.items].join(", ")}]`]
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
if (ifAt === void 0) splices.push({
|
|
717
|
+
at: at + 1,
|
|
718
|
+
remove: 0,
|
|
719
|
+
insert: [`${pad}if: needs.changes.outputs.match == 'true'`]
|
|
720
|
+
});
|
|
721
|
+
else {
|
|
722
|
+
let old = keyValue(lines[ifAt] ?? "", "if") ?? "";
|
|
723
|
+
if (/^[>|]/.test(old)) return { reason: `the if of the job ${id} has more than one line` };
|
|
724
|
+
const whole = /^\$\{\{(.*)\}\}$/.exec(old);
|
|
725
|
+
if (whole !== null) old = (whole[1] ?? "").trim();
|
|
726
|
+
if (old.includes("${{")) return { reason: `the if of the job ${id} has a part in \${{ }}` };
|
|
727
|
+
own.add(id);
|
|
728
|
+
splices.push({
|
|
729
|
+
at: ifAt,
|
|
730
|
+
remove: 1,
|
|
731
|
+
insert: [`${pad}if: ${ifValue(`needs.changes.outputs.match == 'true' && (${old})`)}`]
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
const skippable = new Set(own);
|
|
736
|
+
for (let grew = true; grew;) {
|
|
737
|
+
grew = false;
|
|
738
|
+
for (const [id, needs] of needsOf) {
|
|
739
|
+
if (skippable.has(id) || !needs.some((need) => skippable.has(need))) continue;
|
|
740
|
+
skippable.add(id);
|
|
741
|
+
grew = true;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
const action = (step) => `mark1russell7/template/.github/actions/${step}@${commit} # main`;
|
|
745
|
+
const block = (indent, key, items) => [`${indent}${key}: |`, ...items.map((item) => `${indent}${unit}${item}`)];
|
|
746
|
+
const job = jobIndent + unit;
|
|
747
|
+
const step = job + unit;
|
|
748
|
+
const grouped = top("concurrency") >= 0;
|
|
749
|
+
const group = (id) => grouped ? [] : [
|
|
750
|
+
`${job}concurrency:`,
|
|
751
|
+
`${job}${unit}group: \${{ github.workflow }}-${id}-\${{ github.ref }}`,
|
|
752
|
+
`${job}${unit}cancel-in-progress: true`
|
|
753
|
+
];
|
|
754
|
+
const changes = [
|
|
755
|
+
`${jobIndent}changes:`,
|
|
756
|
+
`${job}runs-on: ubuntu-latest`,
|
|
757
|
+
`${job}timeout-minutes: 5`,
|
|
758
|
+
...group("changes"),
|
|
759
|
+
`${job}permissions:`,
|
|
760
|
+
`${job}${unit}contents: read`,
|
|
761
|
+
`${job}${unit}pull-requests: read`,
|
|
762
|
+
`${job}outputs:`,
|
|
763
|
+
`${job}${unit}match: \${{ steps.changes.outputs.match }}`,
|
|
764
|
+
`${job}steps:`,
|
|
765
|
+
`${step}- id: changes`,
|
|
766
|
+
`${step} uses: ${action("changes")}`,
|
|
767
|
+
`${step} with:`,
|
|
768
|
+
...block(`${step} ${unit}`, "paths", filters["paths"] ?? ["**"]),
|
|
769
|
+
...filters["paths-ignore"] === void 0 ? [] : block(`${step} ${unit}`, "paths-ignore", filters["paths-ignore"]),
|
|
770
|
+
""
|
|
771
|
+
];
|
|
772
|
+
const allow = ids.filter((id) => skippable.has(id));
|
|
773
|
+
const summary = [
|
|
774
|
+
"",
|
|
775
|
+
`${jobIndent}${summaryId}:`,
|
|
776
|
+
`${job}name: ${name}`,
|
|
777
|
+
`${job}if: always()`,
|
|
778
|
+
`${job}needs: [${["changes", ...ids].join(", ")}]`,
|
|
779
|
+
`${job}runs-on: ubuntu-latest`,
|
|
780
|
+
`${job}timeout-minutes: 2`,
|
|
781
|
+
...group(summaryId),
|
|
782
|
+
`${job}permissions: {}`,
|
|
783
|
+
`${job}steps:`,
|
|
784
|
+
`${step}- uses: ${action("gate-summary")}`,
|
|
785
|
+
`${step} with:`,
|
|
786
|
+
`${step} ${unit}needs: \${{ toJSON(needs) }}`,
|
|
787
|
+
...allow.length === 0 ? [] : [`${step} ${unit}allow-skip: ${allow.join(" ")}`]
|
|
788
|
+
];
|
|
789
|
+
let last = blockEnd(lines, jobsAt);
|
|
790
|
+
while (last > jobsAt + 1 && (lines[last - 1] ?? "").trim() === "") last -= 1;
|
|
791
|
+
splices.push({
|
|
792
|
+
at: first,
|
|
793
|
+
remove: 0,
|
|
794
|
+
insert: changes
|
|
795
|
+
}, {
|
|
796
|
+
at: last,
|
|
797
|
+
remove: 0,
|
|
798
|
+
insert: summary
|
|
799
|
+
});
|
|
800
|
+
const out = [...original];
|
|
801
|
+
for (const item of splices.map((value, order) => ({
|
|
802
|
+
...value,
|
|
803
|
+
order
|
|
804
|
+
})).sort((a, b) => b.at - a.at || b.remove - a.remove || b.order - a.order)) out.splice(item.at, item.remove, ...item.insert);
|
|
805
|
+
return { text: out.join(eol) };
|
|
806
|
+
}
|
|
807
|
+
const gateTrigger = {
|
|
808
|
+
id: "gate-trigger",
|
|
809
|
+
title: "A workflow that runs on pull requests starts on each pull request: it has no on.pull_request.paths or paths-ignore.",
|
|
810
|
+
reason: "The ruleset requires the summary check \"<Name> OK\" of each gate. A workflow with a path filter does not start on a pull request that changes no file of the filter, so its check is not there, and the ruleset cannot require it. Then a pull request can merge before such a gate ends. On 2026-11-02, 19 such workflows in 11 repositories fed no required check.",
|
|
811
|
+
fix: "Remove the paths from on.pull_request. Add a job \"changes\" with the action mark1russell7/template/.github/actions/changes and the same paths, and \"if: needs.changes.outputs.match == 'true'\" on each gate job. Add a job \"<Name> OK\" with \"if: always()\", \"needs\" with each job, and the action gate-summary (CI.md, \"A gate with paths\"). Then start ruleset-ci-ok.ts again. A workflow that is not a gate can go in the option allow.",
|
|
812
|
+
sources: [{
|
|
813
|
+
repo: "fleet",
|
|
814
|
+
rule: "gate-trigger",
|
|
815
|
+
doc: "docs/STRATEGY.md (2026-11-02, a gate with paths feeds a required summary)"
|
|
816
|
+
}],
|
|
817
|
+
options: { allow: {
|
|
818
|
+
type: "strings",
|
|
819
|
+
default: [],
|
|
820
|
+
description: "The file names of the workflows that can filter pull requests by path, because they are not a gate (for example a preview)."
|
|
821
|
+
} },
|
|
822
|
+
check(context, options) {
|
|
823
|
+
const files = context.gitFiles();
|
|
824
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
825
|
+
const workflows = files.filter((path) => WORKFLOW$1.test(path)).sort(byCode);
|
|
826
|
+
if (workflows.length === 0) return { skipped: "the repository has no workflow" };
|
|
827
|
+
const allow = Array.isArray(options["allow"]) ? options["allow"] : [];
|
|
828
|
+
const breaks = [];
|
|
829
|
+
for (const file of workflows) {
|
|
830
|
+
if (allow.includes(file.slice(file.lastIndexOf("/") + 1))) continue;
|
|
831
|
+
let text;
|
|
832
|
+
try {
|
|
833
|
+
text = readFileSync(join(context.root, file), "utf8");
|
|
834
|
+
} catch {
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
const filters = prPathFilters(text);
|
|
838
|
+
const first = filters[0];
|
|
839
|
+
if (first === void 0) continue;
|
|
840
|
+
const keys = filters.map((filter) => `on.${filter.trigger}.${filter.key}`).join(" and ");
|
|
841
|
+
const converted = convertGate(text, file);
|
|
842
|
+
breaks.push({
|
|
843
|
+
file,
|
|
844
|
+
line: first.line,
|
|
845
|
+
message: `${file}: ${keys}, so the workflow does not start on each pull request, and the ruleset cannot ask for its summary check.`,
|
|
846
|
+
..."text" in converted ? { edits: [{
|
|
847
|
+
file,
|
|
848
|
+
before: text,
|
|
849
|
+
after: converted.text
|
|
850
|
+
}] } : { fix: `A person must convert it, because ${converted.reason}. ${gateTrigger.fix}` }
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
return breaks;
|
|
854
|
+
}
|
|
855
|
+
};
|
|
506
856
|
// src/rules/main-check.ts
|
|
507
857
|
/**
|
|
508
858
|
* The rule `main-check`: a script does not find out that it is the main module by a compare of `process.argv[1]` with
|
|
@@ -533,6 +883,7 @@ const PATH_NAMES = [
|
|
|
533
883
|
/** This function tells if a text compares `process.argv[1]` with the path of the module, without a real path of each side. */
|
|
534
884
|
function isPathCompare(text) {
|
|
535
885
|
if (!text.includes("process.argv[1]") || !/import\.meta\.(url|filename|dirname)\b/.test(text)) return false;
|
|
886
|
+
if (!/[!=]=|\.(?:endsWith|startsWith|includes)\(/.test(text)) return false;
|
|
536
887
|
return (text.match(/realpathSync\s*\(/g) ?? []).length < 2;
|
|
537
888
|
}
|
|
538
889
|
/** The lowest version of a range of `engines.node` (for example `>=22.19` or `^24.2.0`). It is undefined when the range has no single lower bound. */
|
|
@@ -1804,7 +2155,7 @@ if (board) {
|
|
|
1804
2155
|
* The rule `roadmap-parses`: each roadmap that a workflow gives to the Status page parses, on the pull request.
|
|
1805
2156
|
*/
|
|
1806
2157
|
/** A workflow file. */
|
|
1807
|
-
const WORKFLOW
|
|
2158
|
+
const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1808
2159
|
/** This function tells if a line calls the Pages workflow of the template (`uses: ...reusable-pages.yml`). */
|
|
1809
2160
|
function callsPages(line) {
|
|
1810
2161
|
let text = line.trimStart();
|
|
@@ -1813,7 +2164,7 @@ function callsPages(line) {
|
|
|
1813
2164
|
const value = text.slice(5).trim();
|
|
1814
2165
|
return /(?:^|\/)reusable-pages\.ya?ml(?:@|$|\s)/.test(value);
|
|
1815
2166
|
}
|
|
1816
|
-
const indentOf
|
|
2167
|
+
const indentOf = (line) => line.length - line.trimStart().length;
|
|
1817
2168
|
/** This function tells if a line is `site-pages: false`: the site has no Status page. */
|
|
1818
2169
|
function noStatusPage(line) {
|
|
1819
2170
|
const text = line.trimStart();
|
|
@@ -1835,8 +2186,8 @@ function callsWithoutRoadmap(lines) {
|
|
|
1835
2186
|
const found = [];
|
|
1836
2187
|
lines.forEach((line, index) => {
|
|
1837
2188
|
if (!callsPages(line)) return;
|
|
1838
|
-
const indent = indentOf
|
|
1839
|
-
const inJob = (text) => text.trim() === "" || indentOf
|
|
2189
|
+
const indent = indentOf(line);
|
|
2190
|
+
const inJob = (text) => text.trim() === "" || indentOf(text) >= indent;
|
|
1840
2191
|
let first = index;
|
|
1841
2192
|
while (first > 0 && inJob(lines[first - 1] ?? "")) first -= 1;
|
|
1842
2193
|
let last = index;
|
|
@@ -1878,7 +2229,7 @@ const roadmapParses = {
|
|
|
1878
2229
|
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
1879
2230
|
const named = [];
|
|
1880
2231
|
const breaks = [];
|
|
1881
|
-
for (const file of files.filter((path) => WORKFLOW
|
|
2232
|
+
for (const file of files.filter((path) => WORKFLOW.test(path)).sort(byCode)) {
|
|
1882
2233
|
const lines = readFileSync(join(context.root, file), "utf8").split(/\r?\n/);
|
|
1883
2234
|
lines.forEach((line, index) => {
|
|
1884
2235
|
const roadmap = roadmapOfLine(line);
|
|
@@ -1933,40 +2284,6 @@ const roadmapParses = {
|
|
|
1933
2284
|
* The rule `runner-budget`: the workflows share the runners of the account. Each matrix has a `max-parallel`, each
|
|
1934
2285
|
* workflow has a concurrency group, and each schedule starts at the minute of its repository and file.
|
|
1935
2286
|
*/
|
|
1936
|
-
/** A workflow file. */
|
|
1937
|
-
const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1938
|
-
const indentOf = (line) => line.length - line.trimStart().length;
|
|
1939
|
-
/** This function removes a comment at the end of a value, and the quotes around it. */
|
|
1940
|
-
function valueOf$1(raw) {
|
|
1941
|
-
const comment = raw.indexOf(" #");
|
|
1942
|
-
let value = (comment >= 0 ? raw.slice(0, comment) : raw).trim();
|
|
1943
|
-
const quote = value.charAt(0);
|
|
1944
|
-
if (value.length >= 2 && (quote === "\"" || quote === "'") && value.endsWith(quote)) value = value.slice(1, -1).trim();
|
|
1945
|
-
return value;
|
|
1946
|
-
}
|
|
1947
|
-
/** This function gives the value of the key `key` on a line, or undefined when the line has another key. */
|
|
1948
|
-
function keyValue(line, key) {
|
|
1949
|
-
let text = line.trimStart();
|
|
1950
|
-
if (text.startsWith("- ")) text = text.slice(2).trimStart();
|
|
1951
|
-
if (!text.startsWith(`${key}:`)) return void 0;
|
|
1952
|
-
return valueOf$1(text.slice(key.length + 1));
|
|
1953
|
-
}
|
|
1954
|
-
/** This function gives the lines of the block under the line `index`: the next lines with a larger indent. */
|
|
1955
|
-
function blockEnd(lines, index) {
|
|
1956
|
-
const indent = indentOf(lines[index] ?? "");
|
|
1957
|
-
let end = index + 1;
|
|
1958
|
-
while (end < lines.length) {
|
|
1959
|
-
const line = lines[end] ?? "";
|
|
1960
|
-
if (line.trim() !== "" && indentOf(line) <= indent) break;
|
|
1961
|
-
end += 1;
|
|
1962
|
-
}
|
|
1963
|
-
return end;
|
|
1964
|
-
}
|
|
1965
|
-
/** This function gives the indent of the first key of the block under the line `index`, or undefined for an empty block. */
|
|
1966
|
-
function childIndent(lines, index) {
|
|
1967
|
-
const end = blockEnd(lines, index);
|
|
1968
|
-
for (let i = index + 1; i < end; i++) if ((lines[i] ?? "").trim() !== "") return indentOf(lines[i] ?? "");
|
|
1969
|
-
}
|
|
1970
2287
|
/**
|
|
1971
2288
|
* This function gives the minute (1 to 59) of the schedules of a workflow: the FNV-1a hash of the repository and the
|
|
1972
2289
|
* file. Two repositories with the same workflow thus start at different minutes, and no schedule starts at minute 0,
|
|
@@ -2007,16 +2324,16 @@ function isShared(lines) {
|
|
|
2007
2324
|
}
|
|
2008
2325
|
/** This function gives the jobs of a workflow. */
|
|
2009
2326
|
function jobsOf(lines) {
|
|
2010
|
-
const jobs = lines.findIndex((line) => indentOf(line) === 0 && line.startsWith("jobs:"));
|
|
2327
|
+
const jobs = lines.findIndex((line) => indentOf$1(line) === 0 && line.startsWith("jobs:"));
|
|
2011
2328
|
if (jobs < 0) return [];
|
|
2012
2329
|
const jobIndent = childIndent(lines, jobs);
|
|
2013
2330
|
const end = blockEnd(lines, jobs);
|
|
2014
2331
|
const found = [];
|
|
2015
2332
|
for (let i = jobs + 1; i < end; i++) {
|
|
2016
2333
|
const line = lines[i] ?? "";
|
|
2017
|
-
if (line.trim() === "" || indentOf(line) !== jobIndent) continue;
|
|
2334
|
+
if (line.trim() === "" || indentOf$1(line) !== jobIndent) continue;
|
|
2018
2335
|
const keyIndent = childIndent(lines, i);
|
|
2019
|
-
const keys = lines.slice(i + 1, blockEnd(lines, i)).filter((text) => indentOf(text) === keyIndent);
|
|
2336
|
+
const keys = lines.slice(i + 1, blockEnd(lines, i)).filter((text) => indentOf$1(text) === keyIndent);
|
|
2020
2337
|
const uses = keys.map((text) => keyValue(text, "uses")).find((value) => value !== void 0);
|
|
2021
2338
|
const at = uses === void 0 ? -1 : uses.indexOf(".github/workflows/");
|
|
2022
2339
|
const calls = uses === void 0 || at < 0 ? void 0 : uses.slice(at + 18).split("@")[0] ?? "";
|
|
@@ -2029,13 +2346,13 @@ function jobsOf(lines) {
|
|
|
2029
2346
|
}
|
|
2030
2347
|
return found;
|
|
2031
2348
|
}
|
|
2032
|
-
const hasTopGroup = (lines) => lines.some((line) => indentOf(line) === 0 && line.startsWith("concurrency:"));
|
|
2349
|
+
const hasTopGroup = (lines) => lines.some((line) => indentOf$1(line) === 0 && line.startsWith("concurrency:"));
|
|
2033
2350
|
/**
|
|
2034
2351
|
* This function gives the edit that adds a concurrency group at the top of a workflow, before `jobs:`. A new run of a pull
|
|
2035
2352
|
* request stops the old run. A run of another event waits for the old run, so that no release or scheduled run stops.
|
|
2036
2353
|
*/
|
|
2037
2354
|
function groupEdits(file, text, lines) {
|
|
2038
|
-
const jobs = lines.findIndex((line) => indentOf(line) === 0 && line.startsWith("jobs:"));
|
|
2355
|
+
const jobs = lines.findIndex((line) => indentOf$1(line) === 0 && line.startsWith("jobs:"));
|
|
2039
2356
|
if (jobs < 0) return [];
|
|
2040
2357
|
const pad = " ".repeat(childIndent(lines, jobs) ?? 2);
|
|
2041
2358
|
const original = text.split(/\r?\n/)[jobs] ?? "jobs:";
|
|
@@ -2087,7 +2404,7 @@ function matrixBreaks(file, text, lines, limit) {
|
|
|
2087
2404
|
const keyIndent = childIndent(lines, index);
|
|
2088
2405
|
if (keyIndent === void 0) return;
|
|
2089
2406
|
const keys = [];
|
|
2090
|
-
for (let i = index + 1; i < blockEnd(lines, index); i++) if ((lines[i] ?? "").trim() !== "" && indentOf(lines[i] ?? "") === keyIndent) keys.push(i);
|
|
2407
|
+
for (let i = index + 1; i < blockEnd(lines, index); i++) if ((lines[i] ?? "").trim() !== "" && indentOf$1(lines[i] ?? "") === keyIndent) keys.push(i);
|
|
2091
2408
|
if (!keys.some((i) => keyValue(lines[i] ?? "", "matrix") !== void 0)) return;
|
|
2092
2409
|
const at = keys.find((i) => keyValue(lines[i] ?? "", "max-parallel") !== void 0);
|
|
2093
2410
|
const raw = at === void 0 ? void 0 : keyValue(lines[at] ?? "", "max-parallel");
|
|
@@ -2195,7 +2512,7 @@ const runnerBudget = {
|
|
|
2195
2512
|
check(context, options) {
|
|
2196
2513
|
const files = context.gitFiles();
|
|
2197
2514
|
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
2198
|
-
const workflows = files.filter((path) => WORKFLOW.test(path)).sort(byCode);
|
|
2515
|
+
const workflows = files.filter((path) => WORKFLOW$1.test(path)).sort(byCode);
|
|
2199
2516
|
if (workflows.length === 0) return { skipped: "the repository has no workflow" };
|
|
2200
2517
|
const remote = context.git([
|
|
2201
2518
|
"remote",
|
|
@@ -2213,7 +2530,7 @@ const runnerBudget = {
|
|
|
2213
2530
|
} catch {
|
|
2214
2531
|
continue;
|
|
2215
2532
|
}
|
|
2216
|
-
const lines = text
|
|
2533
|
+
const lines = workflowLines(text);
|
|
2217
2534
|
breaks.push(...matrixBreaks(file, text, lines, limit), ...concurrencyBreaks(file, text, lines, grouped));
|
|
2218
2535
|
if (options["minute"] !== false) {
|
|
2219
2536
|
if (lines.some((line) => keyValue(line, "cron") !== void 0) && repository === void 0) breaks.push({
|
|
@@ -3151,7 +3468,8 @@ const RULES = [
|
|
|
3151
3468
|
mainCheck,
|
|
3152
3469
|
testsRequired,
|
|
3153
3470
|
roadmapParses,
|
|
3154
|
-
runnerBudget
|
|
3471
|
+
runnerBudget,
|
|
3472
|
+
gateTrigger
|
|
3155
3473
|
];
|
|
3156
3474
|
// src/run.ts
|
|
3157
3475
|
/**
|
|
@@ -3505,6 +3823,6 @@ function runCli(args, io) {
|
|
|
3505
3823
|
if (summary) appendFileSync(summary, summaryMarkdown(result));
|
|
3506
3824
|
return result.failed ? 1 : 0;
|
|
3507
3825
|
}
|
|
3508
|
-
export {
|
|
3826
|
+
export { hasFile as $, roadmapParses as A, REAL_COMPARE as B, isSourcePath as C, runnerBudget as D, repositoryOfRemote as E, pinnedGitDeps as F, gateTrigger as G, mainCheck as H, DEFAULT_ALLOWED as I, STRICT_OPTIONS as J, prPathFilters as K, HOME_PATTERNS as L, releaseFiles as M, isGitSpecifier as N, scheduleMinute as O, isPinned as P, codePackages as Q, noLocalPaths as R, tsconfigTest as S, sourceMain as T, ACTIONS_COMMIT as U, hasImportMetaMain as V, convertGate as W, DEPENDENCY_FIELDS as X, cuePreset as Y, cleanPath as Z, configsOfScript as _, listRules as a, readJsonc as at, testsRequired as b, runCli as c, specifiersOf as ct, RULES as d, packageFolders as dt, inFolder as et, workspaceProtocol as f, workspaceGlobs as ft, typedScripts as g, trustPolicy as h, formatResult as i, parseJsonc as it, requiredScripts as j, roadmapOfLine as k, runFix as l, globFolders as lt, TRAIN_SCOPES as m, parseConfig as mt, annotations as n, lineOf as nt, readConfig as o, replaceLine as ot, IGNORE_AFTER as p, defaultOptions as pt, summaryName as q, createContext as r, matchesAny as rt, runChecks as s, runGit as st, USAGE as t, keyLine as tt, summaryMarkdown as u, globToRegExp as ut, scriptsOf as v, pathsOf as w, hasTests as x, typedFiles as y, noBuildOutput as z };
|
|
3509
3827
|
|
|
3510
|
-
//# sourceMappingURL=run-
|
|
3828
|
+
//# sourceMappingURL=run-BRZBN04H.js.map
|