@mark1russell7/conventions 0.64.2 → 0.64.4
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 +15 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/{run-CG6GDnhx.js → run-CeEPIgVg.js} +688 -33
- package/build/run-CeEPIgVg.js.map +1 -0
- package/package.json +2 -2
- package/build/run-CG6GDnhx.js.map +0 -1
|
@@ -5,7 +5,7 @@ import { createRequire } from "node:module";
|
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
6
6
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
8
|
-
import { LineCounter, isMap, isScalar, parseAllDocuments } from "yaml";
|
|
8
|
+
import { LineCounter, isMap, isScalar, isSeq, parseAllDocuments } from "yaml";
|
|
9
9
|
import { errorMessage } from "@mark1russell7/text";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { containsShape, functionsOf } from "@mark1russell7/code-shape";
|
|
@@ -1371,6 +1371,95 @@ function shellCode(line) {
|
|
|
1371
1371
|
const comment = out.search(/(?:^|\s)#/);
|
|
1372
1372
|
return comment >= 0 ? out.slice(0, comment) : out;
|
|
1373
1373
|
}
|
|
1374
|
+
/** The characters that end a word and start an operator of the shell. */
|
|
1375
|
+
const SHELL_OPERATORS = ";&|()`";
|
|
1376
|
+
/**
|
|
1377
|
+
* This function gives the words and the operators of a line of a shell script, from the place `from` to the end of the
|
|
1378
|
+
* text. A quote that does not close goes to the end of the text. A `#` at the start of a word starts a comment. The
|
|
1379
|
+
* value `continues` tells that the line ends with a `\`, so the command continues on the next line.
|
|
1380
|
+
*/
|
|
1381
|
+
function shellTokens(text, line, from = 0) {
|
|
1382
|
+
const tokens = [];
|
|
1383
|
+
let at = from;
|
|
1384
|
+
while (at < text.length) {
|
|
1385
|
+
const char = text.charAt(at);
|
|
1386
|
+
if (char === " " || char === " ") {
|
|
1387
|
+
at += 1;
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
if (char === "#") break;
|
|
1391
|
+
if (char === "\\" && at === text.length - 1) return {
|
|
1392
|
+
tokens,
|
|
1393
|
+
continues: true
|
|
1394
|
+
};
|
|
1395
|
+
const two = text.slice(at, at + 2);
|
|
1396
|
+
if (two === "&&" || two === "||" || two === "$(") {
|
|
1397
|
+
tokens.push({
|
|
1398
|
+
text: two,
|
|
1399
|
+
operator: true,
|
|
1400
|
+
line,
|
|
1401
|
+
start: at,
|
|
1402
|
+
end: at + 2
|
|
1403
|
+
});
|
|
1404
|
+
at += 2;
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
if (SHELL_OPERATORS.includes(char) && two !== "&>") {
|
|
1408
|
+
tokens.push({
|
|
1409
|
+
text: char,
|
|
1410
|
+
operator: true,
|
|
1411
|
+
line,
|
|
1412
|
+
start: at,
|
|
1413
|
+
end: at + 1
|
|
1414
|
+
});
|
|
1415
|
+
at += 1;
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
const start = at;
|
|
1419
|
+
let word = "";
|
|
1420
|
+
while (at < text.length) {
|
|
1421
|
+
const next = text.charAt(at);
|
|
1422
|
+
if (next === " " || next === " " || next === "$" && text.charAt(at + 1) === "(") break;
|
|
1423
|
+
if (SHELL_OPERATORS.includes(next) && !(next === "&" && (at === start || /[<>]/.test(text.charAt(at - 1))))) break;
|
|
1424
|
+
if (next === "\\") {
|
|
1425
|
+
if (at === text.length - 1) return {
|
|
1426
|
+
tokens: [...tokens, {
|
|
1427
|
+
text: word,
|
|
1428
|
+
operator: false,
|
|
1429
|
+
line,
|
|
1430
|
+
start,
|
|
1431
|
+
end: at
|
|
1432
|
+
}],
|
|
1433
|
+
continues: true
|
|
1434
|
+
};
|
|
1435
|
+
word += text.charAt(at + 1);
|
|
1436
|
+
at += 2;
|
|
1437
|
+
} else if (next === "'" || next === "\"") {
|
|
1438
|
+
let close = at + 1;
|
|
1439
|
+
while (close < text.length && text.charAt(close) !== next) {
|
|
1440
|
+
if (next === "\"" && text.charAt(close) === "\\" && close + 1 < text.length) close += 1;
|
|
1441
|
+
word += text.charAt(close);
|
|
1442
|
+
close += 1;
|
|
1443
|
+
}
|
|
1444
|
+
at = Math.min(close + 1, text.length);
|
|
1445
|
+
} else {
|
|
1446
|
+
word += next;
|
|
1447
|
+
at += 1;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
tokens.push({
|
|
1451
|
+
text: word,
|
|
1452
|
+
operator: false,
|
|
1453
|
+
line,
|
|
1454
|
+
start,
|
|
1455
|
+
end: at
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
return {
|
|
1459
|
+
tokens,
|
|
1460
|
+
continues: false
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1374
1463
|
/** This function removes a comment at the end of a value, and the quotes around it. */
|
|
1375
1464
|
function valueOf$1(raw) {
|
|
1376
1465
|
const comment = raw.search(/\s#/);
|
|
@@ -1732,7 +1821,7 @@ function inputsOf(owner) {
|
|
|
1732
1821
|
return Object.fromEntries(Object.entries(inputs).map(([key, value]) => [key, optionalText(value)]));
|
|
1733
1822
|
}
|
|
1734
1823
|
/** This function reads a step: the same label as the line reader gives, its condition, its action and its secrets. */
|
|
1735
|
-
function parsedStep(value) {
|
|
1824
|
+
function parsedStep(value, line) {
|
|
1736
1825
|
const step = isObject$1(value) ? value : {};
|
|
1737
1826
|
const uses = actionOf(optionalText(step["uses"]));
|
|
1738
1827
|
return {
|
|
@@ -1741,7 +1830,8 @@ function parsedStep(value) {
|
|
|
1741
1830
|
uses,
|
|
1742
1831
|
secrets: [...secretsOf(step)],
|
|
1743
1832
|
with: inputsOf(step),
|
|
1744
|
-
run: optionalText(step["run"])
|
|
1833
|
+
run: optionalText(step["run"]),
|
|
1834
|
+
line
|
|
1745
1835
|
};
|
|
1746
1836
|
}
|
|
1747
1837
|
/** This function gives the `concurrency` of a workflow or of a job: a group as one text, or a map with `group`. */
|
|
@@ -1804,8 +1894,14 @@ function matrixJobsOf(strategy) {
|
|
|
1804
1894
|
const added = included.filter((entry) => !combinations.some((combination) => agrees(entry, combination, keys))).length;
|
|
1805
1895
|
return combinations.length + added;
|
|
1806
1896
|
}
|
|
1807
|
-
/** This function
|
|
1808
|
-
function
|
|
1897
|
+
/** This function gives the folder of `defaults.run.working-directory` of a workflow or of a job, or an empty text. */
|
|
1898
|
+
function defaultDirectoryOf(owner) {
|
|
1899
|
+
const defaults = owner["defaults"];
|
|
1900
|
+
const run = isObject$1(defaults) ? defaults["run"] : void 0;
|
|
1901
|
+
return isObject$1(run) ? optionalText(run["working-directory"]) : "";
|
|
1902
|
+
}
|
|
1903
|
+
/** This function reads a job. The folder `workflowDirectory` is the default folder of the workflow. */
|
|
1904
|
+
function parsedJob(id, value, at, workflowDirectory) {
|
|
1809
1905
|
const job = isObject$1(value) ? value : {};
|
|
1810
1906
|
const secrets = secretsOf(job);
|
|
1811
1907
|
if (job["secrets"] === "inherit") secrets.add("inherit");
|
|
@@ -1813,8 +1909,8 @@ function parsedJob(id, value, line, lines) {
|
|
|
1813
1909
|
const limit = strategy["max-parallel"];
|
|
1814
1910
|
return {
|
|
1815
1911
|
id,
|
|
1816
|
-
line,
|
|
1817
|
-
lines,
|
|
1912
|
+
line: at.line,
|
|
1913
|
+
lines: at.lines,
|
|
1818
1914
|
name: optionalText(job["name"]) || id,
|
|
1819
1915
|
maxParallel: typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? limit : null,
|
|
1820
1916
|
matrixJobs: isExpression(job["strategy"]) || isExpression(strategy["matrix"]) ? null : matrixJobsOf(strategy),
|
|
@@ -1825,7 +1921,8 @@ function parsedJob(id, value, line, lines) {
|
|
|
1825
1921
|
with: inputsOf(job),
|
|
1826
1922
|
permissions: permissionsOf(job),
|
|
1827
1923
|
secrets: [...secrets],
|
|
1828
|
-
steps: Array.isArray(job["steps"]) ? job["steps"].map(parsedStep) : []
|
|
1924
|
+
steps: Array.isArray(job["steps"]) ? job["steps"].map((step, index) => parsedStep(step, at.steps[index] ?? at.line)) : [],
|
|
1925
|
+
defaultDirectory: defaultDirectoryOf(job) || workflowDirectory
|
|
1829
1926
|
};
|
|
1830
1927
|
}
|
|
1831
1928
|
/** This function gives the line of each key of a map node of the parser, two keys deep. A key that is not a scalar has no line. */
|
|
@@ -1885,12 +1982,20 @@ function parseWorkflow(file, text) {
|
|
|
1885
1982
|
const jobsNode = first.get("jobs");
|
|
1886
1983
|
if (isMap(jobsNode)) for (const pair of jobsNode.items) {
|
|
1887
1984
|
const at = isScalar(pair.key) ? pair.key.range?.[0] : void 0;
|
|
1888
|
-
if (at
|
|
1985
|
+
if (at === void 0) continue;
|
|
1986
|
+
const stepsNode = isMap(pair.value) ? pair.value.get("steps", true) : void 0;
|
|
1987
|
+
const steps = isSeq(stepsNode) ? stepsNode.items.map((item) => item !== null && typeof item === "object" && "range" in item && Array.isArray(item.range) ? lineOf(item.range[0]) : lineOf(at)) : [];
|
|
1988
|
+
jobNodes.set(String(pair.key.value), {
|
|
1889
1989
|
line: lineOf(at),
|
|
1890
|
-
lines: keyLinesOf(pair.value, lineOf)
|
|
1990
|
+
lines: keyLinesOf(pair.value, lineOf),
|
|
1991
|
+
steps
|
|
1891
1992
|
});
|
|
1892
1993
|
}
|
|
1893
|
-
const jobs = isObject$1(top["jobs"]) ? Object.entries(top["jobs"]).map(([id, job]) => parsedJob(id, job, jobNodes.get(id)
|
|
1994
|
+
const jobs = isObject$1(top["jobs"]) ? Object.entries(top["jobs"]).map(([id, job]) => parsedJob(id, job, jobNodes.get(id) ?? {
|
|
1995
|
+
line: 1,
|
|
1996
|
+
lines: {},
|
|
1997
|
+
steps: []
|
|
1998
|
+
}, defaultDirectoryOf(top))) : [];
|
|
1894
1999
|
const secrets = secretsOf(top);
|
|
1895
2000
|
if (jobs.some((job) => job.secrets.includes("inherit"))) secrets.add("inherit");
|
|
1896
2001
|
const lines = keyLinesOf(first.contents, lineOf);
|
|
@@ -2137,6 +2242,103 @@ const mainRunsFinish = {
|
|
|
2137
2242
|
return breaks;
|
|
2138
2243
|
}
|
|
2139
2244
|
};
|
|
2245
|
+
// src/rules/job-limit-floor.ts
|
|
2246
|
+
/**
|
|
2247
|
+
* The rule `job-limit-floor`: each job of a workflow has a time limit (`timeout-minutes`) of at least
|
|
2248
|
+
* {@link JOB_LIMIT_FLOOR_MINUTES} minutes. GitHub counts the limit from the start of the runner, not from the first step.
|
|
2249
|
+
* A runner that starts slowly uses up a short limit before a step runs, and GitHub then cancels the job with no step.
|
|
2250
|
+
*/
|
|
2251
|
+
/**
|
|
2252
|
+
* The smallest time limit of a job, in minutes. The summary job and the job `changes` that the rules write get this
|
|
2253
|
+
* limit, so the rule and the generated jobs share one number.
|
|
2254
|
+
*/
|
|
2255
|
+
const JOB_LIMIT_FLOOR_MINUTES = 10;
|
|
2256
|
+
/** The key `timeout-minutes` of a job with a whole number, and the text after the number (a comment). */
|
|
2257
|
+
const LIMIT_LINE = /^(\s*timeout-minutes:\s*)(\d+)(\s*(?:#.*)?)$/;
|
|
2258
|
+
/**
|
|
2259
|
+
* This function gives each job of a workflow with a time limit under `floor` minutes. The function does not read a limit
|
|
2260
|
+
* that an expression gives, and a step limit is not a job limit.
|
|
2261
|
+
*/
|
|
2262
|
+
function shortJobLimits(file, text, floor = 10) {
|
|
2263
|
+
const lines = text.split(/\r?\n/);
|
|
2264
|
+
const found = [];
|
|
2265
|
+
for (const job of parseWorkflow(file, text).jobs) {
|
|
2266
|
+
const line = job.lines["timeout-minutes"];
|
|
2267
|
+
if (line === void 0) continue;
|
|
2268
|
+
const match = LIMIT_LINE.exec(lines[line - 1] ?? "");
|
|
2269
|
+
if (match === null) continue;
|
|
2270
|
+
const minutes = Number(match[2]);
|
|
2271
|
+
if (minutes < floor) found.push({
|
|
2272
|
+
job: job.id,
|
|
2273
|
+
line,
|
|
2274
|
+
minutes
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
return found;
|
|
2278
|
+
}
|
|
2279
|
+
/** This function gives the text of a workflow with each job limit under `floor` raised to `floor`. */
|
|
2280
|
+
function raiseJobLimits(file, text, floor = 10) {
|
|
2281
|
+
let after = text;
|
|
2282
|
+
for (const short of shortJobLimits(file, text, floor)) {
|
|
2283
|
+
const old = after.split(/\r?\n/)[short.line - 1] ?? "";
|
|
2284
|
+
after = replaceLine(after, short.line, [old.replace(LIMIT_LINE, `$1${floor}$3`)]);
|
|
2285
|
+
}
|
|
2286
|
+
return after;
|
|
2287
|
+
}
|
|
2288
|
+
const jobLimitFloor = {
|
|
2289
|
+
id: "job-limit-floor",
|
|
2290
|
+
title: `Each job of a workflow has a time limit (timeout-minutes) of at least 10 minutes.`,
|
|
2291
|
+
reason: "GitHub counts the time limit of a job from the start of its runner. On 2026-12-04 runners took 2 to 3 minutes to start, and GitHub cancelled four jobs with a limit of 2 or 3 minutes before their first step. Each cancel stopped a release or a merge until a person started the job again.",
|
|
2292
|
+
fix: `Set timeout-minutes of the job to 10 or more. A short job still ends fast, because the limit is only an upper bound.`,
|
|
2293
|
+
sources: [
|
|
2294
|
+
{
|
|
2295
|
+
repo: "alerts",
|
|
2296
|
+
rule: "start-gate",
|
|
2297
|
+
doc: "runs 47228718413 and 47242618266 (2026-12-04): the jobs Start gate OK (2 minutes) and night-base (2 minutes) were cancelled with no step"
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
repo: "rigor",
|
|
2301
|
+
rule: "release",
|
|
2302
|
+
doc: "run 47240263263 (2026-12-04): the job CI OK (2 minutes) of the release was cancelled with no step, so rigor-bench 0.3.28 waited"
|
|
2303
|
+
},
|
|
2304
|
+
{
|
|
2305
|
+
repo: "template",
|
|
2306
|
+
rule: "reusable-ci",
|
|
2307
|
+
doc: "the job release-window of reusable-ci.yml had a limit of 3 minutes. GitHub cancelled it with no step in rigor run 47243279369 (2026-12-04)"
|
|
2308
|
+
}
|
|
2309
|
+
],
|
|
2310
|
+
options: {},
|
|
2311
|
+
failsFrom: "2026-12-18",
|
|
2312
|
+
check(context) {
|
|
2313
|
+
const files = context.gitFiles();
|
|
2314
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
2315
|
+
const workflows = files.filter((path) => WORKFLOW$1.test(path)).sort(byCode);
|
|
2316
|
+
if (workflows.length === 0) return { skipped: "the repository has no workflow" };
|
|
2317
|
+
const breaks = [];
|
|
2318
|
+
for (const file of workflows) {
|
|
2319
|
+
let text;
|
|
2320
|
+
try {
|
|
2321
|
+
text = readFileSync(join(context.root, file), "utf8");
|
|
2322
|
+
} catch {
|
|
2323
|
+
continue;
|
|
2324
|
+
}
|
|
2325
|
+
const shorts = shortJobLimits(file, text);
|
|
2326
|
+
if (shorts.length === 0) continue;
|
|
2327
|
+
const after = raiseJobLimits(file, text);
|
|
2328
|
+
for (const short of shorts) breaks.push({
|
|
2329
|
+
file,
|
|
2330
|
+
line: short.line,
|
|
2331
|
+
message: `${file}: the job ${short.job} has a time limit of ${short.minutes} minutes. A slow runner start uses it up before the first step, and GitHub cancels the job.`,
|
|
2332
|
+
edits: [{
|
|
2333
|
+
file,
|
|
2334
|
+
before: text,
|
|
2335
|
+
after
|
|
2336
|
+
}]
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
return breaks;
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2140
2342
|
// src/rules/gate-trigger.ts
|
|
2141
2343
|
/**
|
|
2142
2344
|
* The rule `gate-trigger`: a workflow that runs on pull requests starts on each pull request, with no path filter. The
|
|
@@ -2227,7 +2429,7 @@ function summaryJob(s) {
|
|
|
2227
2429
|
`${job}if: ${NOT_CANCELLED}`,
|
|
2228
2430
|
`${job}needs: [${s.needs.join(", ")}]`,
|
|
2229
2431
|
`${job}runs-on: ubuntu-latest`,
|
|
2230
|
-
`${job}timeout-minutes:
|
|
2432
|
+
`${job}timeout-minutes: 10`,
|
|
2231
2433
|
...s.grouped ? [] : [
|
|
2232
2434
|
`${job}concurrency:`,
|
|
2233
2435
|
`${job}${s.unit}group: \${{ github.workflow }}-${s.id}-${OWN_GROUP}`,
|
|
@@ -2364,7 +2566,7 @@ function convertGate(text, file, commit = ACTIONS_COMMIT) {
|
|
|
2364
2566
|
const changes = [
|
|
2365
2567
|
`${jobIndent}changes:`,
|
|
2366
2568
|
`${job}runs-on: ubuntu-latest`,
|
|
2367
|
-
`${job}timeout-minutes:
|
|
2569
|
+
`${job}timeout-minutes: 10`,
|
|
2368
2570
|
...group("changes"),
|
|
2369
2571
|
`${job}permissions:`,
|
|
2370
2572
|
`${job}${unit}contents: read`,
|
|
@@ -3941,9 +4143,9 @@ const callPermissions = callPermissionsRule();
|
|
|
3941
4143
|
* GitHub fails at times with a 504, and a bare `curl` then fails the job.
|
|
3942
4144
|
*/
|
|
3943
4145
|
/** The files of a composite action. */
|
|
3944
|
-
const ACTION$
|
|
4146
|
+
const ACTION$7 = /^\.github\/actions\/.+\/action\.ya?ml$/;
|
|
3945
4147
|
/** The action of the template itself. It is the one place with the download. */
|
|
3946
|
-
const SHARED_ACTION$
|
|
4148
|
+
const SHARED_ACTION$3 = ".github/actions/setup-cue/action.yml";
|
|
3947
4149
|
/** A hand-written install of the cue CLI: a download of a release asset, or a build with `go install`. */
|
|
3948
4150
|
const DOWNLOAD = /github\.com\/cue-lang\/cue\/releases\/download\/(v[0-9][^/\s"']*)\/|cuelang\.org\/go\/cmd\/cue@(v?[0-9][^\s"']*|latest)/;
|
|
3949
4151
|
/** This function gives each line of a file that installs the cue CLI with its own command. It does not read a comment line. */
|
|
@@ -3988,7 +4190,7 @@ const setupCue = {
|
|
|
3988
4190
|
const files = context.gitFiles();
|
|
3989
4191
|
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
3990
4192
|
const breaks = [];
|
|
3991
|
-
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$
|
|
4193
|
+
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$7.test(path)) && path !== SHARED_ACTION$3).sort(byCode)) {
|
|
3992
4194
|
let text;
|
|
3993
4195
|
try {
|
|
3994
4196
|
text = readFileSync(join(context.root, file), "utf8");
|
|
@@ -4014,9 +4216,9 @@ const setupCue = {
|
|
|
4014
4216
|
* `pnpm/action-setup` step fails the job when its fetch of pnpm stalls or when the pnpm that it installed does not start.
|
|
4015
4217
|
*/
|
|
4016
4218
|
/** The files of a composite action. */
|
|
4017
|
-
const ACTION$
|
|
4219
|
+
const ACTION$6 = /^\.github\/actions\/.+\/action\.ya?ml$/;
|
|
4018
4220
|
/** The action of the template itself. It is the one place with the step `pnpm/action-setup`. */
|
|
4019
|
-
const SHARED_ACTION$
|
|
4221
|
+
const SHARED_ACTION$2 = ".github/actions/setup-pnpm/action.yml";
|
|
4020
4222
|
/** A step that uses the action `pnpm/action-setup`, with its ref and the version in the comment after it. */
|
|
4021
4223
|
const ACTION_SETUP = /^\s*(?:-\s+)?uses:\s*["']?pnpm\/action-setup@([^\s"'#]+)["']?\s*(?:#\s*(\S+))?/;
|
|
4022
4224
|
/** The npm command of a global install, up to a comment or the end of the command. */
|
|
@@ -4058,7 +4260,7 @@ const setupPnpm = {
|
|
|
4058
4260
|
id: "setup-pnpm",
|
|
4059
4261
|
title: "pnpm comes from the shared action `setup-pnpm`, not from a step `pnpm/action-setup` or a global npm install in a workflow.",
|
|
4060
4262
|
reason: "A fetch of pnpm stalls at times, and the pnpm that an install gives does not always start. On 2026-12-02 a stalled fetch (EIDLETIMEOUT) failed the memory probe of layout-contract, and a pnpm that did not start failed the CI of wirelab. On 2026-12-03 one failed install made the weekly site run of packing red, and its 323 other jobs passed.",
|
|
4061
|
-
fix: "Use the step `uses: mark1russell7/template/.github/actions/setup-pnpm@<commit>` in place of `pnpm/action-setup`. The action reads the version from the field `packageManager` of `package.json`: move a `with: version` to that field. The input `package_json_file` becomes `package-json-file`. In place of `run_install`, add the step `
|
|
4263
|
+
fix: "Use the step `uses: mark1russell7/template/.github/actions/setup-pnpm@<commit>` in place of `pnpm/action-setup`. The action reads the version from the field `packageManager` of `package.json`: move a `with: version` to that field. The input `package_json_file` becomes `package-json-file`. In place of `run_install`, add the step `uses: mark1russell7/template/.github/actions/pnpm-install@<commit>`.",
|
|
4062
4264
|
sources: [
|
|
4063
4265
|
{
|
|
4064
4266
|
repo: "layout-contract",
|
|
@@ -4087,7 +4289,7 @@ const setupPnpm = {
|
|
|
4087
4289
|
const files = context.gitFiles();
|
|
4088
4290
|
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
4089
4291
|
const breaks = [];
|
|
4090
|
-
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$
|
|
4292
|
+
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$6.test(path)) && path !== SHARED_ACTION$2).sort(byCode)) {
|
|
4091
4293
|
let text;
|
|
4092
4294
|
try {
|
|
4093
4295
|
text = readFileSync(join(context.root, file), "utf8");
|
|
@@ -4106,6 +4308,352 @@ const setupPnpm = {
|
|
|
4106
4308
|
return breaks;
|
|
4107
4309
|
}
|
|
4108
4310
|
};
|
|
4311
|
+
// src/rules/filtered-install.ts
|
|
4312
|
+
/**
|
|
4313
|
+
* The rule `filtered-install`: a filtered `pnpm install` of a workspace package also selects the workspace packages that
|
|
4314
|
+
* it uses. The filter `--filter <name>` installs only the dependencies of the package. The install links each workspace
|
|
4315
|
+
* package that the package uses, but it does not install the dependencies of the linked package. Then an import in the linked
|
|
4316
|
+
* package fails with `ERR_MODULE_NOT_FOUND`. The selector `<name>...` also installs each workspace package that the
|
|
4317
|
+
* package uses, with its dependencies.
|
|
4318
|
+
*/
|
|
4319
|
+
/** A key at the start of a line of YAML, also after the `- ` of a list item. Group 1 is the name of the key. */
|
|
4320
|
+
const KEY$1 = /^\s*(?:-\s+)?["']?([A-Za-z_][\w.-]*)["']?:(?:\s+|$)/;
|
|
4321
|
+
/** The keys whose value is a text for a person or for GitHub, not a command of the shell. */
|
|
4322
|
+
const TEXT_KEYS = /* @__PURE__ */ new Set([
|
|
4323
|
+
"name",
|
|
4324
|
+
"description",
|
|
4325
|
+
"id",
|
|
4326
|
+
"if",
|
|
4327
|
+
"uses",
|
|
4328
|
+
"shell",
|
|
4329
|
+
"working-directory",
|
|
4330
|
+
"runs-on",
|
|
4331
|
+
"needs"
|
|
4332
|
+
]);
|
|
4333
|
+
/** The words before a command that start the command or wait for it: `timeout 10m pnpm install`. */
|
|
4334
|
+
const LAUNCHERS = /* @__PURE__ */ new Set([
|
|
4335
|
+
"!",
|
|
4336
|
+
"{",
|
|
4337
|
+
"if",
|
|
4338
|
+
"then",
|
|
4339
|
+
"elif",
|
|
4340
|
+
"else",
|
|
4341
|
+
"while",
|
|
4342
|
+
"until",
|
|
4343
|
+
"do",
|
|
4344
|
+
"time",
|
|
4345
|
+
"command",
|
|
4346
|
+
"exec",
|
|
4347
|
+
"env",
|
|
4348
|
+
"sudo",
|
|
4349
|
+
"nice",
|
|
4350
|
+
"nohup",
|
|
4351
|
+
"timeout",
|
|
4352
|
+
"xvfb-run",
|
|
4353
|
+
"corepack",
|
|
4354
|
+
"npx"
|
|
4355
|
+
]);
|
|
4356
|
+
/** A word after a launcher: an option, a time or a count, or a variable of the environment (`CI=1`). */
|
|
4357
|
+
const LAUNCHER_ARGUMENT = /^(?:-\S*|\d+(?:\.\d+)?[smhd]?|[A-Za-z_]\w*=.*)$/;
|
|
4358
|
+
/** The command `pnpm`, also with a folder or a version: `./node_modules/.bin/pnpm`, `pnpm@11`. */
|
|
4359
|
+
const PNPM = /^(?:\S*\/)?pnpm(?:@\S+)?$/;
|
|
4360
|
+
/** The options of pnpm that take the next word as their value. A word after them is not the command of pnpm. */
|
|
4361
|
+
const VALUE_OPTIONS = /* @__PURE__ */ new Set([
|
|
4362
|
+
"--filter",
|
|
4363
|
+
"-F",
|
|
4364
|
+
"--filter-prod",
|
|
4365
|
+
"--dir",
|
|
4366
|
+
"-C",
|
|
4367
|
+
"--reporter",
|
|
4368
|
+
"--loglevel",
|
|
4369
|
+
"--workspace-concurrency",
|
|
4370
|
+
"--test-pattern",
|
|
4371
|
+
"--changed-files-ignore-pattern",
|
|
4372
|
+
"--store-dir",
|
|
4373
|
+
"--virtual-store-dir",
|
|
4374
|
+
"--modules-dir",
|
|
4375
|
+
"--lockfile-dir"
|
|
4376
|
+
]);
|
|
4377
|
+
/** The commands of pnpm that install the dependencies of a workspace. */
|
|
4378
|
+
const INSTALL_COMMANDS = /* @__PURE__ */ new Set(["install", "i"]);
|
|
4379
|
+
/** The option `--filter=` before the selector in one word. */
|
|
4380
|
+
const FILTER_EQUALS = "--filter=";
|
|
4381
|
+
/** This function gives the install of the command `words`, or undefined when the command is not a `pnpm install`. */
|
|
4382
|
+
function installOf(words, editable, action) {
|
|
4383
|
+
let at = 0;
|
|
4384
|
+
while (at < words.length && !PNPM.test(words[at]?.text ?? "")) {
|
|
4385
|
+
const text = words[at]?.text ?? "";
|
|
4386
|
+
if (!LAUNCHERS.has(text) && !(at > 0 && LAUNCHER_ARGUMENT.test(text)) && !/^[A-Za-z_]\w*=/.test(text)) return void 0;
|
|
4387
|
+
at += 1;
|
|
4388
|
+
}
|
|
4389
|
+
const pnpm = words[at];
|
|
4390
|
+
if (pnpm === void 0) return void 0;
|
|
4391
|
+
const args = words.slice(at + 1);
|
|
4392
|
+
let command;
|
|
4393
|
+
const found = [];
|
|
4394
|
+
for (let index = 0; index < args.length; index++) {
|
|
4395
|
+
const word = args[index];
|
|
4396
|
+
if (word === void 0 || word.text === "--") break;
|
|
4397
|
+
if (word.text === "--filter" || word.text === "-F") {
|
|
4398
|
+
const value = args[index + 1];
|
|
4399
|
+
if (value !== void 0) found.push({
|
|
4400
|
+
line: value.line + 1,
|
|
4401
|
+
selector: value.text,
|
|
4402
|
+
start: value.start,
|
|
4403
|
+
end: value.end,
|
|
4404
|
+
editable
|
|
4405
|
+
});
|
|
4406
|
+
index += 1;
|
|
4407
|
+
} else if (word.text.startsWith(FILTER_EQUALS)) found.push({
|
|
4408
|
+
line: word.line + 1,
|
|
4409
|
+
selector: word.text.slice(9),
|
|
4410
|
+
start: word.start + 9,
|
|
4411
|
+
end: word.end,
|
|
4412
|
+
editable
|
|
4413
|
+
});
|
|
4414
|
+
else if (word.text.startsWith("-")) {
|
|
4415
|
+
if (command === void 0 && VALUE_OPTIONS.has(word.text)) index += 1;
|
|
4416
|
+
} else command ??= word.text;
|
|
4417
|
+
}
|
|
4418
|
+
if (command === void 0 || !INSTALL_COMMANDS.has(command)) return void 0;
|
|
4419
|
+
return {
|
|
4420
|
+
line: pnpm.line + 1,
|
|
4421
|
+
words: words.slice(at).map((word) => word.text),
|
|
4422
|
+
action,
|
|
4423
|
+
selectors: found
|
|
4424
|
+
};
|
|
4425
|
+
}
|
|
4426
|
+
/** This function gives each `pnpm install` in the tokens of one command line. */
|
|
4427
|
+
function installsOf(tokens, editable) {
|
|
4428
|
+
const found = [];
|
|
4429
|
+
let words = [];
|
|
4430
|
+
for (const token of [...tokens, void 0]) {
|
|
4431
|
+
if (token !== void 0 && !token.operator) {
|
|
4432
|
+
words.push(token);
|
|
4433
|
+
continue;
|
|
4434
|
+
}
|
|
4435
|
+
const install = installOf(words, editable, false);
|
|
4436
|
+
if (install !== void 0) found.push(install);
|
|
4437
|
+
words = [];
|
|
4438
|
+
}
|
|
4439
|
+
return found;
|
|
4440
|
+
}
|
|
4441
|
+
/** The value of `uses` of a step with the action `pnpm-install` of the template, pinned or in a local folder. */
|
|
4442
|
+
const PNPM_INSTALL_ACTION = /(?:^|\/)\.github\/actions\/pnpm-install(?:@|\/?\s*$|\/?\s+#)/;
|
|
4443
|
+
/** The place of the key of a line: its indent, also after the `- ` of a list item. */
|
|
4444
|
+
const keyPlace = (line) => line.length - line.trimStart().replace(/^-\s+/, "").length;
|
|
4445
|
+
/**
|
|
4446
|
+
* This function gives true when the key under `with` at the line `index` is an input of the action `pnpm-install`.
|
|
4447
|
+
* It reads the keys of the step before and after `with`.
|
|
4448
|
+
*/
|
|
4449
|
+
function inPnpmInstallStep(lines, index) {
|
|
4450
|
+
const own = indentOf$1(lines[index] ?? "");
|
|
4451
|
+
let at = index - 1;
|
|
4452
|
+
while (at >= 0 && ((lines[at] ?? "").trim() === "" || indentOf$1(lines[at] ?? "") >= own)) at -= 1;
|
|
4453
|
+
const withLine = lines[at] ?? "";
|
|
4454
|
+
if (at < 0 || KEY$1.exec(withLine)?.[1] !== "with") return false;
|
|
4455
|
+
const step = keyPlace(withLine);
|
|
4456
|
+
const usesAction = (line) => {
|
|
4457
|
+
const key = KEY$1.exec(line);
|
|
4458
|
+
return key?.[1] === "uses" && PNPM_INSTALL_ACTION.test(line.slice(key[0].length).replace(/^["']|["']\s*$/g, ""));
|
|
4459
|
+
};
|
|
4460
|
+
for (let back = at; back >= 0; back -= 1) {
|
|
4461
|
+
const line = lines[back] ?? "";
|
|
4462
|
+
if (line.trim() === "" || indentOf$1(line) > step) continue;
|
|
4463
|
+
if (keyPlace(line) !== step) break;
|
|
4464
|
+
if (usesAction(line)) return true;
|
|
4465
|
+
if (/^\s*-\s/.test(line)) break;
|
|
4466
|
+
}
|
|
4467
|
+
for (let next = at + 1; next < lines.length; next += 1) {
|
|
4468
|
+
const line = lines[next] ?? "";
|
|
4469
|
+
if (line.trim() === "" || indentOf$1(line) > step) continue;
|
|
4470
|
+
if (indentOf$1(line) !== step || /^\s*-\s/.test(line)) break;
|
|
4471
|
+
if (usesAction(line)) return true;
|
|
4472
|
+
}
|
|
4473
|
+
return false;
|
|
4474
|
+
}
|
|
4475
|
+
/**
|
|
4476
|
+
* This function gives the install of the input `args` at the line `index`, or undefined for another key or step. The
|
|
4477
|
+
* action `pnpm-install` starts `pnpm install` with the words of the input.
|
|
4478
|
+
*/
|
|
4479
|
+
function actionInstall(lines, index, key) {
|
|
4480
|
+
if (key[1] !== "args" || !inPnpmInstallStep(lines, index)) return void 0;
|
|
4481
|
+
const line = lines[index] ?? "";
|
|
4482
|
+
let from = key[0].length;
|
|
4483
|
+
let to = line.length;
|
|
4484
|
+
const value = line.slice(from).trimEnd();
|
|
4485
|
+
const quote = value.charAt(0);
|
|
4486
|
+
const quoted = (quote === "\"" || quote === "'") && value.length > 1 && value.endsWith(quote);
|
|
4487
|
+
if (quoted) {
|
|
4488
|
+
from += 1;
|
|
4489
|
+
to = from + value.length - 2;
|
|
4490
|
+
}
|
|
4491
|
+
const at = {
|
|
4492
|
+
line: index,
|
|
4493
|
+
start: key[0].length,
|
|
4494
|
+
end: key[0].length,
|
|
4495
|
+
operator: false
|
|
4496
|
+
};
|
|
4497
|
+
return installOf([
|
|
4498
|
+
{
|
|
4499
|
+
...at,
|
|
4500
|
+
text: "pnpm"
|
|
4501
|
+
},
|
|
4502
|
+
{
|
|
4503
|
+
...at,
|
|
4504
|
+
text: "install"
|
|
4505
|
+
},
|
|
4506
|
+
...shellTokens(line.slice(0, to), index, from).tokens.filter((token) => !token.operator)
|
|
4507
|
+
], !quoted, true);
|
|
4508
|
+
}
|
|
4509
|
+
/** This function gives the end of the block of text under the key at the line `index`. The indent of a key after `- ` is the place of the key. */
|
|
4510
|
+
function textEnd(lines, index) {
|
|
4511
|
+
const line = lines[index] ?? "";
|
|
4512
|
+
const indent = line.length - line.trimStart().replace(/^-\s+/, "").length;
|
|
4513
|
+
let end = index + 1;
|
|
4514
|
+
while (end < lines.length && ((lines[end] ?? "").trim() === "" || indentOf$1(lines[end] ?? "") > indent)) end += 1;
|
|
4515
|
+
return end;
|
|
4516
|
+
}
|
|
4517
|
+
/**
|
|
4518
|
+
* This function gives each `pnpm install` of a workflow or a composite action, also `pnpm i` and
|
|
4519
|
+
* `pnpm --filter <selector> install`. It also gives the input `args` of each step with the action `pnpm-install`. It
|
|
4520
|
+
* reads the value of each key, the lines of a block of text, and the commands after `&&`, `;`, `|` and in `( )`. It reads a command
|
|
4521
|
+
* that continues after a `\`. It does not read comments, or the value of a key for a person or for GitHub (`name`, `if`).
|
|
4522
|
+
*/
|
|
4523
|
+
function pnpmInstallCommands(text) {
|
|
4524
|
+
const lines = workflowLines(text);
|
|
4525
|
+
const found = [];
|
|
4526
|
+
let pending = [];
|
|
4527
|
+
let editable = true;
|
|
4528
|
+
for (let index = 0; index < lines.length; index++) {
|
|
4529
|
+
const line = lines[index] ?? "";
|
|
4530
|
+
let from = 0;
|
|
4531
|
+
let to = line.length;
|
|
4532
|
+
let quoted = false;
|
|
4533
|
+
if (pending.length === 0) {
|
|
4534
|
+
const key = KEY$1.exec(line);
|
|
4535
|
+
const value = key === null ? "" : line.slice(key[0].length).trimEnd();
|
|
4536
|
+
if (key !== null && TEXT_KEYS.has(key[1] ?? "")) {
|
|
4537
|
+
if (/^[|>]/.test(value)) index = textEnd(lines, index) - 1;
|
|
4538
|
+
continue;
|
|
4539
|
+
}
|
|
4540
|
+
const action = key === null ? void 0 : actionInstall(lines, index, key);
|
|
4541
|
+
if (action !== void 0) {
|
|
4542
|
+
found.push(action);
|
|
4543
|
+
continue;
|
|
4544
|
+
}
|
|
4545
|
+
if (key !== null) {
|
|
4546
|
+
from = key[0].length;
|
|
4547
|
+
const quote = value.charAt(0);
|
|
4548
|
+
if ((quote === "\"" || quote === "'") && value.length > 1 && value.endsWith(quote)) {
|
|
4549
|
+
from += 1;
|
|
4550
|
+
to = from + value.length - 2;
|
|
4551
|
+
quoted = true;
|
|
4552
|
+
}
|
|
4553
|
+
} else from = /^\s*-\s+/.exec(line)?.[0].length ?? 0;
|
|
4554
|
+
}
|
|
4555
|
+
const { tokens, continues } = shellTokens(line.slice(0, to), index, from);
|
|
4556
|
+
pending.push(...tokens);
|
|
4557
|
+
editable &&= !quoted;
|
|
4558
|
+
if (continues) continue;
|
|
4559
|
+
found.push(...installsOf(pending, editable));
|
|
4560
|
+
pending = [];
|
|
4561
|
+
editable = true;
|
|
4562
|
+
}
|
|
4563
|
+
found.push(...installsOf(pending, editable));
|
|
4564
|
+
return found;
|
|
4565
|
+
}
|
|
4566
|
+
/** This function gives the selector of each filtered `pnpm install` of a workflow, from {@link pnpmInstallCommands}. */
|
|
4567
|
+
function filteredInstalls(text) {
|
|
4568
|
+
return pnpmInstallCommands(text).flatMap((install) => install.selectors);
|
|
4569
|
+
}
|
|
4570
|
+
/** This function gives the selector `<name>...` in the quotes of the old selector, or in double quotes. It gives undefined for a selector in another form. */
|
|
4571
|
+
function dependencySelector(raw, name) {
|
|
4572
|
+
if (raw === name) return `"${name}..."`;
|
|
4573
|
+
for (const quote of ["\"", "'"]) if (raw === `${quote}${name}${quote}`) return `${quote}${name}...${quote}`;
|
|
4574
|
+
}
|
|
4575
|
+
/** This function gives `text` with the selector `<name>...` in place of each selector of `installs` that a script can change. */
|
|
4576
|
+
function withDependencySelectors(text, installs) {
|
|
4577
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
4578
|
+
const lines = text.split(/\r?\n/);
|
|
4579
|
+
for (const install of [...installs].sort((a, b) => b.line - a.line || b.start - a.start)) {
|
|
4580
|
+
const line = lines[install.line - 1] ?? "";
|
|
4581
|
+
const next = install.editable ? dependencySelector(line.slice(install.start, install.end), install.selector) : void 0;
|
|
4582
|
+
if (next !== void 0) lines[install.line - 1] = line.slice(0, install.start) + next + line.slice(install.end);
|
|
4583
|
+
}
|
|
4584
|
+
return lines.join(eol);
|
|
4585
|
+
}
|
|
4586
|
+
/** This function gives the workspace packages that each package of the workspace uses (a `workspace:` specifier), by the name of the package. */
|
|
4587
|
+
function workspaceUses(packages) {
|
|
4588
|
+
const uses = /* @__PURE__ */ new Map();
|
|
4589
|
+
for (const pkg of packages) {
|
|
4590
|
+
const name = pkg.manifest["name"];
|
|
4591
|
+
if (typeof name !== "string" || uses.has(name)) continue;
|
|
4592
|
+
const used = DEPENDENCY_FIELDS.flatMap((field) => specifiersOf(pkg.manifest, field).filter(([, spec]) => spec.startsWith("workspace:")).map(([dependency]) => dependency));
|
|
4593
|
+
uses.set(name, [...new Set(used)].sort(byCode));
|
|
4594
|
+
}
|
|
4595
|
+
return uses;
|
|
4596
|
+
}
|
|
4597
|
+
const filteredInstall = {
|
|
4598
|
+
id: "filtered-install",
|
|
4599
|
+
title: "A filtered `pnpm install` of a package that uses workspace packages selects them too: `--filter \"<name>...\"`, not `--filter <name>`.",
|
|
4600
|
+
reason: "The filter `--filter <name>` installs only the dependencies of the package. The install links each workspace package that the package uses, but does not install their dependencies. On 2026-12-03 a CI job of metrograph-labs/canon failed with `ERR_MODULE_NOT_FOUND` for this reason.",
|
|
4601
|
+
fix: "Write the selector `\"<name>...\"`. It also installs each workspace package that the package uses, with its dependencies. `conventions fix` writes it.",
|
|
4602
|
+
sources: [
|
|
4603
|
+
{
|
|
4604
|
+
repo: "metrograph-labs/canon",
|
|
4605
|
+
rule: "ci",
|
|
4606
|
+
doc: "commit 14370f5 (2026-12-03): a job with a filter of one package failed with ERR_MODULE_NOT_FOUND in a linked workspace package. Two more workflows had the same filter."
|
|
4607
|
+
},
|
|
4608
|
+
{
|
|
4609
|
+
repo: "client",
|
|
4610
|
+
rule: "event-fan-out",
|
|
4611
|
+
doc: "commit 06088f9 (2026-11-04): each filtered install of the job selects \"@procedures/client...\", with the workspace packages that it uses"
|
|
4612
|
+
},
|
|
4613
|
+
{
|
|
4614
|
+
repo: "template",
|
|
4615
|
+
rule: "ci",
|
|
4616
|
+
doc: "commit b73368d (2026-11-16): the install of the rules selects \"@mark1russell7/conventions...\", and the release build selects \"<name>...\" for each package"
|
|
4617
|
+
}
|
|
4618
|
+
],
|
|
4619
|
+
options: {},
|
|
4620
|
+
failsFrom: "2026-12-21",
|
|
4621
|
+
check(context) {
|
|
4622
|
+
const files = context.gitFiles();
|
|
4623
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
4624
|
+
const uses = workspaceUses([context.rootPackage, ...context.packages]);
|
|
4625
|
+
const breaks = [];
|
|
4626
|
+
for (const file of files.filter((path) => WORKFLOW$1.test(path)).sort(byCode)) {
|
|
4627
|
+
let text;
|
|
4628
|
+
try {
|
|
4629
|
+
text = readFileSync(join(context.root, file), "utf8");
|
|
4630
|
+
} catch {
|
|
4631
|
+
continue;
|
|
4632
|
+
}
|
|
4633
|
+
const found = filteredInstalls(text).filter((install) => (uses.get(install.selector) ?? []).length > 0);
|
|
4634
|
+
if (found.length === 0) continue;
|
|
4635
|
+
const after = withDependencySelectors(text, found);
|
|
4636
|
+
const lines = text.split(/\r?\n/);
|
|
4637
|
+
for (const install of found) {
|
|
4638
|
+
const name = install.selector;
|
|
4639
|
+
const used = (uses.get(name) ?? []).join(", ");
|
|
4640
|
+
const raw = (lines[install.line - 1] ?? "").slice(install.start, install.end);
|
|
4641
|
+
const fixable = install.editable && dependencySelector(raw, name) !== void 0;
|
|
4642
|
+
breaks.push({
|
|
4643
|
+
file,
|
|
4644
|
+
line: install.line,
|
|
4645
|
+
message: `A pnpm install of ${file} has the filter ${name}, and ${name} uses the workspace packages ${used}. The install links them, but does not install their dependencies. Write "${name}...".`,
|
|
4646
|
+
...fixable ? { edits: [{
|
|
4647
|
+
file,
|
|
4648
|
+
before: text,
|
|
4649
|
+
after
|
|
4650
|
+
}] } : {}
|
|
4651
|
+
});
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
return breaks;
|
|
4655
|
+
}
|
|
4656
|
+
};
|
|
4109
4657
|
// src/rules/shared-ci.ts
|
|
4110
4658
|
/**
|
|
4111
4659
|
* The rule `shared-ci`: a repository uses the shared workflows and actions of the template, and keeps no copy of them.
|
|
@@ -4146,11 +4694,13 @@ const SHARED_ACTIONS = [
|
|
|
4146
4694
|
"npm-publish",
|
|
4147
4695
|
"pages-build",
|
|
4148
4696
|
"pass-stamp",
|
|
4697
|
+
"pnpm-install",
|
|
4149
4698
|
"pull-of-run",
|
|
4150
4699
|
"release-check",
|
|
4151
4700
|
"security-scan",
|
|
4152
4701
|
"select",
|
|
4153
4702
|
"setup-cue",
|
|
4703
|
+
"setup-electron",
|
|
4154
4704
|
"setup-playwright",
|
|
4155
4705
|
"setup-pnpm",
|
|
4156
4706
|
"site-check",
|
|
@@ -4161,7 +4711,7 @@ const SHARED_ACTIONS = [
|
|
|
4161
4711
|
/** The `uses` value of a job that calls the shared CI, with no pin. */
|
|
4162
4712
|
const SHARED_CI = "mark1russell7/template/.github/workflows/reusable-ci.yml";
|
|
4163
4713
|
/** The action folder of a path: `.github/actions/<name>/action.yml` gives `<name>`. */
|
|
4164
|
-
const ACTION$
|
|
4714
|
+
const ACTION$5 = /^\.github\/actions\/([^/]+)\//;
|
|
4165
4715
|
/** The file name of a path. */
|
|
4166
4716
|
const baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
|
|
4167
4717
|
/** This function tells if a job of a workflow text uses the shared CI of the template. */
|
|
@@ -4225,7 +4775,7 @@ const sharedCi = {
|
|
|
4225
4775
|
});
|
|
4226
4776
|
const actions = /* @__PURE__ */ new Set();
|
|
4227
4777
|
for (const file of files) {
|
|
4228
|
-
const folder = ACTION$
|
|
4778
|
+
const folder = ACTION$5.exec(file)?.[1];
|
|
4229
4779
|
if (folder !== void 0 && SHARED_ACTIONS.includes(folder) && !actions.has(folder)) {
|
|
4230
4780
|
actions.add(folder);
|
|
4231
4781
|
breaks.push({
|
|
@@ -6103,7 +6653,7 @@ const HOMES = [
|
|
|
6103
6653
|
{
|
|
6104
6654
|
area: "repo-structure",
|
|
6105
6655
|
title: "Repository structure, CI and conventions",
|
|
6106
|
-
covers: "new repositories and packages, the CUE presets, shared CI workflows, the API report, import boundaries, the conventions check, the release and status pages, the browser check of a built site (site-pages check), the offline shell of a built site (entry /offline of site-pages: manifest, service worker, the offline check)",
|
|
6656
|
+
covers: "new repositories and packages, the CUE presets, shared CI workflows, the API report, import boundaries, the conventions check, the release and status pages, the browser check of a built site (site-pages check), the offline shell of a built site (entry /offline of site-pages: manifest, service worker, the offline check), the React kit of a docs site (entry /react of site-pages: the theme, the content registry, the sidebar, callouts, tabs, the page footer, react.css)",
|
|
6107
6657
|
packages: [
|
|
6108
6658
|
"@mark1russell7/conventions",
|
|
6109
6659
|
"@mark1russell7/template-cli",
|
|
@@ -6129,7 +6679,15 @@ const HOMES = [
|
|
|
6129
6679
|
"offline",
|
|
6130
6680
|
"manifest",
|
|
6131
6681
|
"pwa",
|
|
6132
|
-
"service worker"
|
|
6682
|
+
"service worker",
|
|
6683
|
+
"docs site",
|
|
6684
|
+
"react kit",
|
|
6685
|
+
"content registry",
|
|
6686
|
+
"mdx",
|
|
6687
|
+
"sidebar",
|
|
6688
|
+
"callout",
|
|
6689
|
+
"table of contents",
|
|
6690
|
+
"theme toggle"
|
|
6133
6691
|
]
|
|
6134
6692
|
},
|
|
6135
6693
|
{
|
|
@@ -76085,7 +76643,7 @@ function movedTo(repo, moves) {
|
|
|
76085
76643
|
* Each run of the workflow then fails before it starts ("workflow file issue"), and no job shows why.
|
|
76086
76644
|
*/
|
|
76087
76645
|
/** The files of a composite action. */
|
|
76088
|
-
const ACTION$
|
|
76646
|
+
const ACTION$4 = /^\.github\/actions\/.+\/action\.ya?ml$/;
|
|
76089
76647
|
/** The value of `uses:` that names another repository: `owner/name`, then a path or nothing, then `@` and the ref. */
|
|
76090
76648
|
const REMOTE = /^([\w.-]+)\/([\w.-]+)(\/[^@\s]*)?@\S+$/;
|
|
76091
76649
|
/** This function gives each `uses:` of a workflow or an action that names another repository. A local path (`./`) and a Docker image (`docker://`) are not calls of a repository. */
|
|
@@ -76141,7 +76699,7 @@ const movedRepoCalls = {
|
|
|
76141
76699
|
if (bad !== void 0) return { skipped: `the option moves has "${bad.text}", which is not in the form owner/name=owner/name` };
|
|
76142
76700
|
const moves = [...MOVES, ...extra.map((each) => each.move)];
|
|
76143
76701
|
const breaks = [];
|
|
76144
|
-
for (const file of files.filter((path) => WORKFLOW$1.test(path) || ACTION$
|
|
76702
|
+
for (const file of files.filter((path) => WORKFLOW$1.test(path) || ACTION$4.test(path)).sort(byCode)) {
|
|
76145
76703
|
let text;
|
|
76146
76704
|
try {
|
|
76147
76705
|
text = readFileSync(join(context.root, file), "utf8");
|
|
@@ -76244,7 +76802,7 @@ const MANIFEST = /(^|\/)package\.json$/;
|
|
|
76244
76802
|
const MARKDOWN = /\.mdx?$/i;
|
|
76245
76803
|
const CHANGELOG = /(^|\/)CHANGELOG\.md$/i;
|
|
76246
76804
|
/** A file of a composite action. */
|
|
76247
|
-
const ACTION$
|
|
76805
|
+
const ACTION$3 = /^\.github\/actions\/.+\/action\.ya?ml$/;
|
|
76248
76806
|
/** The kinds of place of the core, in the order of a report. */
|
|
76249
76807
|
const PLACE_KINDS = [
|
|
76250
76808
|
{
|
|
@@ -76262,7 +76820,7 @@ const PLACE_KINDS = [
|
|
|
76262
76820
|
{
|
|
76263
76821
|
id: "workflow-names",
|
|
76264
76822
|
title: "The addresses and each key repository of a workflow or a composite action, except uses: (the rule moved-repo-calls).",
|
|
76265
|
-
reads: (file) => WORKFLOW$1.test(file) || ACTION$
|
|
76823
|
+
reads: (file) => WORKFLOW$1.test(file) || ACTION$3.test(file),
|
|
76266
76824
|
find: (text) => {
|
|
76267
76825
|
const skip = (line) => line.trimStart().startsWith("#") || keyValue(line, "uses") !== void 0;
|
|
76268
76826
|
const keys = [];
|
|
@@ -78793,6 +79351,10 @@ const SITE_CONFIG_KEYS = {
|
|
|
78793
79351
|
kind: "string",
|
|
78794
79352
|
default: ""
|
|
78795
79353
|
},
|
|
79354
|
+
"site-check-wide-font": {
|
|
79355
|
+
kind: "string",
|
|
79356
|
+
default: ""
|
|
79357
|
+
},
|
|
78796
79358
|
"site-check-playwright": {
|
|
78797
79359
|
kind: "string",
|
|
78798
79360
|
default: "1.64.1"
|
|
@@ -79666,9 +80228,9 @@ const jobFails = {
|
|
|
79666
80228
|
* more try. A bare `playwright install --with-deps` waits for the package mirror with no limit.
|
|
79667
80229
|
*/
|
|
79668
80230
|
/** The files of a composite action. */
|
|
79669
|
-
const ACTION$
|
|
80231
|
+
const ACTION$2 = /^\.github\/actions\/.+\/action\.ya?ml$/;
|
|
79670
80232
|
/** The folder of the action of the template itself. It is the one place with the install. */
|
|
79671
|
-
const SHARED_ACTION = ".github/actions/setup-playwright/";
|
|
80233
|
+
const SHARED_ACTION$1 = ".github/actions/setup-playwright/";
|
|
79672
80234
|
/**
|
|
79673
80235
|
* A command of the Playwright CLI that installs: `install` or `install-deps`. The CLI comes first on the line, or after a
|
|
79674
80236
|
* space or a shell operator. It can have a folder and a version, as in `node_modules/.bin/playwright` or
|
|
@@ -79743,7 +80305,7 @@ const playwrightInstall = {
|
|
|
79743
80305
|
return;
|
|
79744
80306
|
}
|
|
79745
80307
|
};
|
|
79746
|
-
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$
|
|
80308
|
+
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$2.test(path)) && !path.startsWith(SHARED_ACTION$1)).sort(byCode)) {
|
|
79747
80309
|
const text = read(file);
|
|
79748
80310
|
if (text === void 0) continue;
|
|
79749
80311
|
for (const install of playwrightInstalls(text)) breaks.push({
|
|
@@ -79764,6 +80326,96 @@ const playwrightInstall = {
|
|
|
79764
80326
|
return breaks;
|
|
79765
80327
|
}
|
|
79766
80328
|
};
|
|
80329
|
+
// src/rules/pnpm-install.ts
|
|
80330
|
+
/**
|
|
80331
|
+
* The rule `pnpm-install`: no workflow or action starts `pnpm install` in its own step. The shared action
|
|
80332
|
+
* `pnpm-install` of the template gives each try a time limit. After a failure or a stop, the next try starts. A bare
|
|
80333
|
+
* install waits until the limit of the job when a fetch from the npm registry stalls. In a job with a default folder
|
|
80334
|
+
* (`defaults.run.working-directory`), a step of the action gives that folder to its input `working-directory`. A step
|
|
80335
|
+
* `uses` does not take the default folder.
|
|
80336
|
+
*/
|
|
80337
|
+
/** The files of a composite action. */
|
|
80338
|
+
const ACTION$1 = /^\.github\/actions\/.+\/action\.ya?ml$/;
|
|
80339
|
+
/** The action of the template itself. Its step for an old Node.js starts one install with no time limit. */
|
|
80340
|
+
const SHARED_ACTION = ".github/actions/pnpm-install/action.yml";
|
|
80341
|
+
/** The action of a step, with no pin: the action `pnpm-install` of the template, or a copy of the template at a path. */
|
|
80342
|
+
const ACTION_USES = /(?:^|\/)\.github\/actions\/pnpm-install$/;
|
|
80343
|
+
/**
|
|
80344
|
+
* This function gives each step of the action `pnpm-install` with no input `working-directory` in a job with a default
|
|
80345
|
+
* folder other than the root. A file that does not parse gives none: the rule `workflow-parses` reports it.
|
|
80346
|
+
*/
|
|
80347
|
+
function lostFolders(file, text) {
|
|
80348
|
+
const found = [];
|
|
80349
|
+
for (const job of parseWorkflow(file, text).jobs) {
|
|
80350
|
+
const folder = job.defaultDirectory;
|
|
80351
|
+
if (folder === "" || folder === ".") continue;
|
|
80352
|
+
for (const step of job.steps) if (ACTION_USES.test(step.uses) && step.with["working-directory"] === void 0) found.push({
|
|
80353
|
+
line: step.line,
|
|
80354
|
+
job: job.id,
|
|
80355
|
+
folder
|
|
80356
|
+
});
|
|
80357
|
+
}
|
|
80358
|
+
return found;
|
|
80359
|
+
}
|
|
80360
|
+
/**
|
|
80361
|
+
* This function gives each `pnpm install` of a workflow or an action outside the action `pnpm-install`. The reader of
|
|
80362
|
+
* the rule `filtered-install` finds them. It does not read a comment, a quote or a name.
|
|
80363
|
+
*/
|
|
80364
|
+
function bareInstalls(text) {
|
|
80365
|
+
return pnpmInstallCommands(text).filter((install) => !install.action).map((install) => ({
|
|
80366
|
+
line: install.line,
|
|
80367
|
+
command: install.words.join(" ")
|
|
80368
|
+
}));
|
|
80369
|
+
}
|
|
80370
|
+
const pnpmInstall = {
|
|
80371
|
+
id: "pnpm-install",
|
|
80372
|
+
title: "pnpm install runs in the shared action `pnpm-install`, which gives each try a time limit, not in a step `run: pnpm install`.",
|
|
80373
|
+
reason: "A fetch from the npm registry stalls at times. A bare pnpm install then waits until the limit of the job. On 2026-12-02 the downloads of two packages stayed at 0 B in two jobs of client and in one job of TinyImages. Each job waited 15 or 25 minutes and failed. An install from the cache takes seconds: in 25 runs of each of five repositories, the slowest took 18 seconds.",
|
|
80374
|
+
fix: "Use the step `uses: mark1russell7/template/.github/actions/pnpm-install@<commit>` in place of `run: pnpm install`. Its input `args` gives the words after `pnpm install` (the default is `--frozen-lockfile`), and its input `working-directory` gives the folder. The other commands of the step stay in a step `run`. In a job with `defaults.run.working-directory`, give the same folder to the input `working-directory`: a step `uses` does not take the default folder.",
|
|
80375
|
+
sources: [
|
|
80376
|
+
{
|
|
80377
|
+
repo: "client",
|
|
80378
|
+
rule: "ci",
|
|
80379
|
+
doc: "run 46854685048 (2026-12-02): pnpm install --frozen-lockfile stalled in two jobs, and each job waited until its limit"
|
|
80380
|
+
},
|
|
80381
|
+
{
|
|
80382
|
+
repo: "TinyImages",
|
|
80383
|
+
rule: "ci",
|
|
80384
|
+
doc: "run 46853586975 (2026-12-02): the same stall, at the same hour"
|
|
80385
|
+
},
|
|
80386
|
+
{
|
|
80387
|
+
repo: "template",
|
|
80388
|
+
rule: "pnpm-install",
|
|
80389
|
+
doc: "the shared action pnpm-install: a time limit of 3 minutes on each try, and 3 tries"
|
|
80390
|
+
}
|
|
80391
|
+
],
|
|
80392
|
+
options: {},
|
|
80393
|
+
failsFrom: "2026-12-28",
|
|
80394
|
+
check(context) {
|
|
80395
|
+
const files = context.gitFiles();
|
|
80396
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
80397
|
+
const breaks = [];
|
|
80398
|
+
for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$1.test(path)) && path !== SHARED_ACTION).sort(byCode)) {
|
|
80399
|
+
let text;
|
|
80400
|
+
try {
|
|
80401
|
+
text = readFileSync(join(context.root, file), "utf8");
|
|
80402
|
+
} catch {
|
|
80403
|
+
continue;
|
|
80404
|
+
}
|
|
80405
|
+
if (WORKFLOW$1.test(file)) for (const lost of lostFolders(file, text)) breaks.push({
|
|
80406
|
+
file,
|
|
80407
|
+
line: lost.line,
|
|
80408
|
+
message: `${file} starts the action pnpm-install in the job ${lost.job} with no input working-directory. A step "uses" does not take the default folder ${lost.folder} of the job, so the install runs at the root of the checkout. Give the folder to the input working-directory.`
|
|
80409
|
+
});
|
|
80410
|
+
for (const install of bareInstalls(text)) breaks.push({
|
|
80411
|
+
file,
|
|
80412
|
+
line: install.line,
|
|
80413
|
+
message: `${file} starts "${install.command}" in a step of its own. A stalled fetch then holds the job, with no next try. Use the action pnpm-install of the template.`
|
|
80414
|
+
});
|
|
80415
|
+
}
|
|
80416
|
+
return breaks;
|
|
80417
|
+
}
|
|
80418
|
+
};
|
|
79767
80419
|
// src/rules/unreleased-change.ts
|
|
79768
80420
|
/**
|
|
79769
80421
|
* The rule `unreleased-change`: a change does not set a version that npm has. With the option `versionEachChange`, a
|
|
@@ -83043,6 +83695,7 @@ const RULES = [
|
|
|
83043
83695
|
pushMainOnly,
|
|
83044
83696
|
pipeFails,
|
|
83045
83697
|
jobFails,
|
|
83698
|
+
jobLimitFloor,
|
|
83046
83699
|
gateAfterCancel,
|
|
83047
83700
|
gateTrigger,
|
|
83048
83701
|
securityOneJob,
|
|
@@ -83053,6 +83706,8 @@ const RULES = [
|
|
|
83053
83706
|
sharedCi,
|
|
83054
83707
|
setupCue,
|
|
83055
83708
|
setupPnpm,
|
|
83709
|
+
filteredInstall,
|
|
83710
|
+
pnpmInstall,
|
|
83056
83711
|
playwrightInstall,
|
|
83057
83712
|
movedRepoCalls,
|
|
83058
83713
|
movedRepoNames,
|
|
@@ -84274,6 +84929,6 @@ function runHook(args, io) {
|
|
|
84274
84929
|
git: (gitArgs) => runGit(io.cwd, gitArgs)
|
|
84275
84930
|
}, io);
|
|
84276
84931
|
}
|
|
84277
|
-
export { retiredFile as $,
|
|
84932
|
+
export { retiredFile as $, SHARED_CI as $n, readWorkflow as $r, lineNameHit as $t, scriptsOf as A, declaredName as An, withOneJob as Ar, pushMainOnly as At, giveWaySlots as B, mapMarkdown as Bn, convertGate as Br, PRIVATE_NAMES_FILE_VARIABLE as Bt, setVersions as C, parseRuleConfig as Ci, shapesOfSource as Cn, startsOnPullRequest as Cr, gitPinOnNpm as Ct, trustPolicy as D, moduleMessage as Dn, SECURITY_TIMEOUT_MINUTES as Dr, pinnedGitDeps as Dt, TRAIN_SCOPES as E, homeModule as En, SECURITY_SCAN_INPUTS as Er, isPinned as Et, sourceMain as F, signaturesOf as Fn, licenseFile as Fr, publishTextSafe as Ft, workflowPeaks as G, npmPackagesOf as Gn, summaryName as Gr, privateNamesFiles as Gt, repositoryPeak as H, mergeHomes as Hn, prPathFilters as Hr, invalidPatternBreaks as Ht, TEMPLATE_CALLED as I, HOME_EXPORTS as In, licenseFileOf as Ir, packNoBuildinfo as It, mayRun as J, runCalls as Jn, gateAfterCancel as Jr, PRIVATE_NAME_LIST as Jt, evaluateExpression as K, readOverlay as Kn, JOB_LIMIT_FLOOR_MINUTES as Kr, privatePatterns as Kt, UNKNOWN_MATRIX_JOBS as L, HOMES as Ln, mitText as Lr, DEFAULT_ALLOWED as Lt, testsRequired as M, messageOf$1 as Mn, scheduleMinute as Mr, pagesCalls as Mt, isSourcePath as N, repoOf as Nn, LICENSE_TEXTS as Nr, pagesSite as Nt, typedScripts as O, moduleUses as On, securityCallers as Or, siteCheckInCi as Ot, pathsOf as P, reposOf as Pn, authorOf as Pr, exportsRequire as Pt, RETIRED_FILES as Q, SHARED_ACTIONS as Qn, readAction as Qr, isCommonUse as Qt, calledJobs as R, MAP_RULE as Rn, repositoryIsPublic as Rr, HOME_PATTERNS as Rt, namedVersions as S, parseConfig as Si, shapeMessage as Sn, hasSummaryJob as Sr, pnpmYamlParses as St, IGNORE_AFTER as T, HOME_SHAPES as Tn, SECURITY_SCAN_COMMIT as Tr, isGitSpecifier as Tt, runnerPeak as U, npmDrift as Un, skippableJobs as Ur, noLocalPaths as Ut, matrixPeak as V, mapText as Vn, gateTrigger as Vr, PRIVATE_PATTERNS_VARIABLE as Vt, runsAtOnce as W, npmNames as Wn, summaryJob as Wr, privateNamesFile as Wt, roadmapParses as X, hasTests as Xn, MATRIX_EXPAND_MAX as Xr, firstNameMatch as Xt, roadmapOfLine as Y, serviceRunMain as Yn, FILTER_KEYS as Yr, PrivateNameListError as Yt, retiredFiles as Z, tsconfigTest as Zn, parseWorkflow as Zr, isAllowedHit as Zt, runPrePushArgs as _, runGit as _i, coverageProvider as _n, isSecurityGate as _r, parseAdvisory as _t, listRules as a, cleanPath as ai, CONSOLE_LAST_DAY as an, setupCue as ar, publishedMinorRule as at, GITHUB_YAML as b, specifiersOf as bi, homeShape as bn, SUMMARY_GATES as br, pipeFails as bt, runCli as c, inFolder as ci, consoleGate as cn, HOME_TIMEOUT_MS as cr, SHIPPED_FIELDS as ct, HOOK_MARKER as d, matchesAny as di, isConsoleSource as dn, sharedDocsRule as dr, unreleasedChange as dt, yamlFaults as ei, lineNameHits as en, SHARED_WORKFLOWS as er, requiredScripts as et, NO_READ_LINE as f, parseCatFileBatch as fi, noConsole as fn, addReleaseMode as fr, unreleasedChangeRule as ft, prePush as g, repositoryOfRemote as gi, mainCheck as gn, SECURITY_FILE as gr, jobFails as gt, parsePrePushArgs as h, replaceLine as hi, hasImportMetaMain as hn, releaseModeRule as hr, hiddenFailures as ht, formatResult as i, RULE_WARN_DAYS as ii, pathNameHit as in, setupPnpm as ir, publishedMinor as it, typedFiles as j, homePackage as jn, runnerBudget as jr, PAGES_WORKFLOWS as jt, configsOfScript as k, modulesOf as kn, securityOneJob as kr, pagesAfterRelease as kt, runFix as l, keyLine as li, consoleKind as ln, blockHash as lr, UNSHIPPED_FILES as lt, installHook as m, readJsonc as mi, REAL_COMPARE as mn, hasReleaseMode as mr, playwrightInstall as mt, annotations as n, cuePreset as ni, nameMatches as nn, sharedCi as nr, lockedVersions as nt, readConfig as o, codePackages as oi, NOT_SOURCE as on, callPermissions as or, reachOf as ot, PRE_PUSH_HOOK as p, parseJsonc as pi, noBuildOutput as pn, callsReleaseBuild as pr, pnpmInstall as pt, groupParts as q, SERVICE_PACKAGE as qn, jobLimitFloor as qr, privateTextBreaks as qt, createContext as r, DEPENDENCY_FIELDS as ri, parsePrivateNames as rn, filteredInstall as rr, minorOf as rt, runChecks as s, hasFile as si, consoleBreaks as sn, callPermissionsRule as sr, NPM_REGISTRY as st, USAGE as t, STRICT_OPTIONS as ti, mergePrivateNames as tn, callsSharedCi as tr, releaseFiles as tt, summaryMarkdown as u, lineOf as ui, isCliFile as un, githubFetch as ur, npmLookup as ut, RULES as v, runGitShow as vi, apiReportScript as vn, securityGate as vr, startsTests as vt, versionTitle as w, spansOf as wn, summaryJobRule as wr, dependencySpecifiers as wt, workflowParses as x, defaultOptions as xi, homeShapesOf as xn, addSummaryJob as xr, PNPM_YAML as xt, workspaceProtocol as y, showFiles as yi, containedHome as yn, securityWorkflow as yr, swallowsTests as yt, eventClass as z, findHomes as zn, ACTIONS_COMMIT as zr, PRIVATE_NAMES_FILE_CONFIG as zt };
|
|
84278
84933
|
|
|
84279
|
-
//# sourceMappingURL=run-
|
|
84934
|
+
//# sourceMappingURL=run-CeEPIgVg.js.map
|