@mark1russell7/conventions 0.52.0 → 0.52.2
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 +5 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +162 -45
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/{run-BbSnF13L.js → run-z_zuxE9M.js} +579 -91
- package/build/run-z_zuxE9M.js.map +1 -0
- package/package.json +1 -1
- package/build/run-BbSnF13L.js.map +0 -1
|
@@ -4,7 +4,7 @@ import { createRequire } from "node:module";
|
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
7
|
-
import { parseAllDocuments } from "yaml";
|
|
7
|
+
import { LineCounter, isMap, isScalar, parseAllDocuments } from "yaml";
|
|
8
8
|
import { errorMessage } from "@mark1russell7/text";
|
|
9
9
|
import { SECRET_SHAPES, findSecretShapes, findSecretShapesInValue, redactSecretShapes } from "@mark1russell7/text/redact";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
@@ -1715,16 +1715,81 @@ function parsedStep(value) {
|
|
|
1715
1715
|
secrets: [...secretsOf(step)]
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
|
+
/** This function gives the `concurrency` of a workflow or of a job: a group as one text, or a map with `group`. */
|
|
1719
|
+
function concurrencyOf(owner) {
|
|
1720
|
+
const value = owner["concurrency"];
|
|
1721
|
+
if (value === void 0 || value === null) return null;
|
|
1722
|
+
if (!isObject$1(value)) return {
|
|
1723
|
+
group: textOf(value).trim(),
|
|
1724
|
+
cancelInProgress: false
|
|
1725
|
+
};
|
|
1726
|
+
const cancel = value["cancel-in-progress"];
|
|
1727
|
+
return {
|
|
1728
|
+
group: optionalText(value["group"]),
|
|
1729
|
+
cancelInProgress: typeof cancel === "boolean" ? cancel : cancel === void 0 || cancel === null ? false : textOf(cancel).trim()
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
/** The largest product of the lists of a matrix that the reader expands. GitHub refuses a matrix of more than 256 jobs. */
|
|
1733
|
+
const MATRIX_EXPAND_MAX = 65536;
|
|
1734
|
+
/** This function tells if a value of the parser is an expression or holds one at its top. GitHub then gives the value at run time. */
|
|
1735
|
+
const isExpression = (value) => typeof value === "string" && value.includes("${{");
|
|
1736
|
+
/** This function tells if two values of the parser are the same: the same scalar, or lists and maps with the same items. */
|
|
1737
|
+
function sameValue(a, b) {
|
|
1738
|
+
if (a === b) return true;
|
|
1739
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => sameValue(item, b[i]));
|
|
1740
|
+
if (!isObject$1(a) || !isObject$1(b)) return false;
|
|
1741
|
+
const keys = Object.keys(a);
|
|
1742
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && sameValue(a[key], b[key]));
|
|
1743
|
+
}
|
|
1744
|
+
/** This function tells if an entry of `exclude` or `include` agrees with a combination on each key of `keys` that the entry has. */
|
|
1745
|
+
const agrees = (entry, combination, keys) => Object.keys(entry).every((key) => !keys.has(key) || sameValue(entry[key], combination[key]));
|
|
1746
|
+
/**
|
|
1747
|
+
* This function gives the count of the jobs of a matrix, as GitHub expands it. First the product of the lists, then
|
|
1748
|
+
* `exclude` takes away each combination that agrees with an entry on each key of the entry. Then each entry of `include`
|
|
1749
|
+
* adds to each combination that it agrees with on the keys of the lists. It changes no value of a list. An entry that adds
|
|
1750
|
+
* to no combination is a new job. A job that `include` made is no target of a later entry, so a matrix of only `include`
|
|
1751
|
+
* gives one job for each entry.
|
|
1752
|
+
*/
|
|
1753
|
+
function matrixJobsOf(strategy) {
|
|
1754
|
+
const matrix = strategy["matrix"];
|
|
1755
|
+
if (matrix === void 0 || matrix === null) return 1;
|
|
1756
|
+
if (!isObject$1(matrix)) return null;
|
|
1757
|
+
const { include, exclude, ...lists } = matrix;
|
|
1758
|
+
const entries = (value) => value === void 0 || value === null ? [] : Array.isArray(value) && value.every(isObject$1) ? value : null;
|
|
1759
|
+
const included = entries(include);
|
|
1760
|
+
const excluded = entries(exclude);
|
|
1761
|
+
if (included === null || excluded === null) return null;
|
|
1762
|
+
const dimensions = Object.entries(lists);
|
|
1763
|
+
if (dimensions.some(([, values]) => !Array.isArray(values))) return null;
|
|
1764
|
+
const keys = new Set(dimensions.map(([key]) => key));
|
|
1765
|
+
let combinations = [];
|
|
1766
|
+
if (dimensions.length > 0) {
|
|
1767
|
+
if (dimensions.reduce((size, [, values]) => size * values.length, 1) > 65536) return null;
|
|
1768
|
+
combinations = [{}];
|
|
1769
|
+
for (const [key, values] of dimensions) combinations = combinations.flatMap((combination) => values.map((value) => ({
|
|
1770
|
+
...combination,
|
|
1771
|
+
[key]: value
|
|
1772
|
+
})));
|
|
1773
|
+
combinations = combinations.filter((combination) => !excluded.some((entry) => agrees(entry, combination, new Set(Object.keys(entry)))));
|
|
1774
|
+
}
|
|
1775
|
+
const added = included.filter((entry) => !combinations.some((combination) => agrees(entry, combination, keys))).length;
|
|
1776
|
+
return combinations.length + added;
|
|
1777
|
+
}
|
|
1718
1778
|
/** This function reads a job. */
|
|
1719
|
-
function parsedJob(id, value) {
|
|
1779
|
+
function parsedJob(id, value, line, lines) {
|
|
1720
1780
|
const job = isObject$1(value) ? value : {};
|
|
1721
1781
|
const secrets = secretsOf(job);
|
|
1722
1782
|
if (job["secrets"] === "inherit") secrets.add("inherit");
|
|
1723
|
-
const
|
|
1783
|
+
const strategy = isObject$1(job["strategy"]) ? job["strategy"] : {};
|
|
1784
|
+
const limit = strategy["max-parallel"];
|
|
1724
1785
|
return {
|
|
1725
1786
|
id,
|
|
1787
|
+
line,
|
|
1788
|
+
lines,
|
|
1726
1789
|
name: optionalText(job["name"]) || id,
|
|
1727
1790
|
maxParallel: typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? limit : null,
|
|
1791
|
+
matrixJobs: isExpression(job["strategy"]) || isExpression(strategy["matrix"]) ? null : matrixJobsOf(strategy),
|
|
1792
|
+
concurrency: concurrencyOf(job),
|
|
1728
1793
|
if: optionalText(job["if"]),
|
|
1729
1794
|
needs: listValues(job["needs"]),
|
|
1730
1795
|
uses: actionOf(optionalText(job["uses"])),
|
|
@@ -1733,6 +1798,17 @@ function parsedJob(id, value) {
|
|
|
1733
1798
|
steps: Array.isArray(job["steps"]) ? job["steps"].map(parsedStep) : []
|
|
1734
1799
|
};
|
|
1735
1800
|
}
|
|
1801
|
+
/** 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. */
|
|
1802
|
+
function keyLinesOf(node, lineOf, prefix = "", depth = 2, into = {}) {
|
|
1803
|
+
if (!isMap(node)) return into;
|
|
1804
|
+
for (const pair of node.items) {
|
|
1805
|
+
if (!isScalar(pair.key) || pair.key.range === void 0 || pair.key.range === null) continue;
|
|
1806
|
+
const path = prefix + String(pair.key.value);
|
|
1807
|
+
into[path] ??= lineOf(pair.key.range[0]);
|
|
1808
|
+
if (depth > 1) keyLinesOf(pair.value, lineOf, `${path}.`, depth - 1, into);
|
|
1809
|
+
}
|
|
1810
|
+
return into;
|
|
1811
|
+
}
|
|
1736
1812
|
/** This function gives the line (from 1) of the offset `at` of a text. */
|
|
1737
1813
|
const lineAt$1 = (text, at) => text.slice(0, at).split("\n").length;
|
|
1738
1814
|
/**
|
|
@@ -1740,7 +1816,11 @@ const lineAt$1 = (text, at) => text.slice(0, at).split("\n").length;
|
|
|
1740
1816
|
* problem is a fault of the result. A file with a fault gives no trigger and no job.
|
|
1741
1817
|
*/
|
|
1742
1818
|
function parseWorkflow(file, text) {
|
|
1743
|
-
const
|
|
1819
|
+
const lineCounter = new LineCounter();
|
|
1820
|
+
const documents = parseAllDocuments(text, {
|
|
1821
|
+
...PARSE,
|
|
1822
|
+
lineCounter
|
|
1823
|
+
});
|
|
1744
1824
|
const faults = faultsOf(documents);
|
|
1745
1825
|
const [first, second] = documents;
|
|
1746
1826
|
if (second !== void 0) faults.push({
|
|
@@ -1759,24 +1839,39 @@ function parseWorkflow(file, text) {
|
|
|
1759
1839
|
name: file,
|
|
1760
1840
|
triggers: [],
|
|
1761
1841
|
permissions: null,
|
|
1842
|
+
concurrency: null,
|
|
1762
1843
|
secrets: [],
|
|
1763
1844
|
jobs: [],
|
|
1845
|
+
lines: {},
|
|
1764
1846
|
faults
|
|
1765
1847
|
};
|
|
1766
1848
|
if (first === void 0 || faults.length > 0) return none;
|
|
1767
1849
|
try {
|
|
1768
1850
|
const top = first.toJS();
|
|
1769
1851
|
if (!isObject$1(top)) return none;
|
|
1770
|
-
const
|
|
1852
|
+
const lineOf = (offset) => lineCounter.linePos(offset).line;
|
|
1853
|
+
const jobNodes = /* @__PURE__ */ new Map();
|
|
1854
|
+
const jobsNode = first.get("jobs");
|
|
1855
|
+
if (isMap(jobsNode)) for (const pair of jobsNode.items) {
|
|
1856
|
+
const at = isScalar(pair.key) ? pair.key.range?.[0] : void 0;
|
|
1857
|
+
if (at !== void 0) jobNodes.set(String(pair.key.value), {
|
|
1858
|
+
line: lineOf(at),
|
|
1859
|
+
lines: keyLinesOf(pair.value, lineOf)
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
const jobs = isObject$1(top["jobs"]) ? Object.entries(top["jobs"]).map(([id, job]) => parsedJob(id, job, jobNodes.get(id)?.line ?? 1, jobNodes.get(id)?.lines ?? {})) : [];
|
|
1771
1863
|
const secrets = secretsOf(top);
|
|
1772
1864
|
if (jobs.some((job) => job.secrets.includes("inherit"))) secrets.add("inherit");
|
|
1865
|
+
const lines = keyLinesOf(first.contents, lineOf);
|
|
1773
1866
|
return {
|
|
1774
1867
|
file,
|
|
1775
1868
|
name: optionalText(top["name"]) || file,
|
|
1776
1869
|
triggers: triggersOf$1(top["on"]),
|
|
1777
1870
|
permissions: permissionsOf(top),
|
|
1871
|
+
concurrency: concurrencyOf(top),
|
|
1778
1872
|
secrets: [...secrets],
|
|
1779
1873
|
jobs,
|
|
1874
|
+
lines,
|
|
1780
1875
|
faults
|
|
1781
1876
|
};
|
|
1782
1877
|
} catch (error) {
|
|
@@ -2491,57 +2586,33 @@ function scheduleMinute(repository, file) {
|
|
|
2491
2586
|
return hash % 59 + 1;
|
|
2492
2587
|
}
|
|
2493
2588
|
/** This function tells if a workflow is a shared workflow (`on: workflow_call`). Its caller gives the concurrency group. */
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2589
|
+
const isShared = (workflow) => workflow.triggers.includes("workflow_call");
|
|
2590
|
+
/** This function gives the file name of the shared workflow that a job calls (`uses: .../.github/workflows/<name>`), if any. */
|
|
2591
|
+
function callOf$1(job) {
|
|
2592
|
+
const at = job.uses.indexOf(".github/workflows/");
|
|
2593
|
+
return at < 0 ? void 0 : job.uses.slice(at + 18);
|
|
2499
2594
|
}
|
|
2500
|
-
/** This function gives the jobs of a workflow. */
|
|
2501
|
-
function jobsOf(lines) {
|
|
2502
|
-
const jobs = lines.findIndex((line) => indentOf$1(line) === 0 && line.startsWith("jobs:"));
|
|
2503
|
-
if (jobs < 0) return [];
|
|
2504
|
-
const jobIndent = childIndent(lines, jobs);
|
|
2505
|
-
const end = blockEnd(lines, jobs);
|
|
2506
|
-
const found = [];
|
|
2507
|
-
for (let i = jobs + 1; i < end; i++) {
|
|
2508
|
-
const line = lines[i] ?? "";
|
|
2509
|
-
if (line.trim() === "" || indentOf$1(line) !== jobIndent) continue;
|
|
2510
|
-
const keyIndent = childIndent(lines, i);
|
|
2511
|
-
const keys = lines.slice(i + 1, blockEnd(lines, i)).filter((text) => indentOf$1(text) === keyIndent);
|
|
2512
|
-
const uses = keys.map((text) => keyValue(text, "uses")).find((value) => value !== void 0);
|
|
2513
|
-
const at = uses === void 0 ? -1 : uses.indexOf(".github/workflows/");
|
|
2514
|
-
const calls = uses === void 0 || at < 0 ? void 0 : uses.slice(at + 18).split("@")[0] ?? "";
|
|
2515
|
-
found.push({
|
|
2516
|
-
name: line.trim().replace(/:$/, ""),
|
|
2517
|
-
line: i + 1,
|
|
2518
|
-
grouped: keys.some((text) => keyValue(text, "concurrency") !== void 0),
|
|
2519
|
-
...calls === void 0 ? {} : { calls }
|
|
2520
|
-
});
|
|
2521
|
-
}
|
|
2522
|
-
return found;
|
|
2523
|
-
}
|
|
2524
|
-
const hasTopGroup = (lines) => lines.some((line) => indentOf$1(line) === 0 && line.startsWith("concurrency:"));
|
|
2525
2595
|
/**
|
|
2526
2596
|
* This function gives the edit that adds a concurrency group at the top of a workflow, before `jobs:`. A new run of a pull
|
|
2527
2597
|
* request stops the old run. A run of another event has the group of its commit, so that no release or scheduled run stops.
|
|
2528
2598
|
*/
|
|
2529
|
-
function groupEdits(file, text,
|
|
2530
|
-
const jobs = lines
|
|
2531
|
-
if (jobs
|
|
2532
|
-
const
|
|
2533
|
-
const
|
|
2534
|
-
const
|
|
2535
|
-
|
|
2536
|
-
pad + "group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}",
|
|
2537
|
-
pad + "cancel-in-progress: ${{ github.event_name == 'pull_request' }}",
|
|
2538
|
-
"",
|
|
2539
|
-
original
|
|
2540
|
-
];
|
|
2599
|
+
function groupEdits(file, text, workflow) {
|
|
2600
|
+
const jobs = workflow.lines["jobs"];
|
|
2601
|
+
if (jobs === void 0) return [];
|
|
2602
|
+
const originals = text.split(/\r?\n/);
|
|
2603
|
+
const first = workflow.jobs[0];
|
|
2604
|
+
const pad = " ".repeat(first === void 0 ? 2 : indentOf$1(originals[first.line - 1] ?? " ") || 2);
|
|
2605
|
+
const original = originals[jobs - 1] ?? "jobs:";
|
|
2541
2606
|
return [{
|
|
2542
2607
|
file,
|
|
2543
2608
|
before: text,
|
|
2544
|
-
after: replaceLine(text, jobs
|
|
2609
|
+
after: replaceLine(text, jobs, [
|
|
2610
|
+
"concurrency:",
|
|
2611
|
+
pad + "group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}",
|
|
2612
|
+
pad + "cancel-in-progress: ${{ github.event_name == 'pull_request' }}",
|
|
2613
|
+
"",
|
|
2614
|
+
original
|
|
2615
|
+
])
|
|
2545
2616
|
}];
|
|
2546
2617
|
}
|
|
2547
2618
|
/**
|
|
@@ -2549,68 +2620,67 @@ function groupEdits(file, text, lines) {
|
|
|
2549
2620
|
* A job that calls a shared workflow of `grouped` gets its group from the jobs of that workflow. A shared workflow gets
|
|
2550
2621
|
* its group from its caller, but a shared workflow of `grouped` has a group in each job.
|
|
2551
2622
|
*/
|
|
2552
|
-
function concurrencyBreaks(file, text,
|
|
2623
|
+
function concurrencyBreaks(file, text, workflow, grouped) {
|
|
2553
2624
|
const name = file.slice(file.lastIndexOf("/") + 1);
|
|
2554
|
-
|
|
2555
|
-
if (isShared(lines)) {
|
|
2625
|
+
if (isShared(workflow)) {
|
|
2556
2626
|
if (!grouped.includes(name)) return [];
|
|
2557
|
-
return jobs.filter((job) =>
|
|
2627
|
+
return workflow.jobs.filter((job) => job.concurrency === null).map((job) => ({
|
|
2558
2628
|
file,
|
|
2559
2629
|
line: job.line,
|
|
2560
|
-
message: `${file}: the job ${job.
|
|
2630
|
+
message: `${file}: the job ${job.id} has no concurrency group, and its callers rely on it (the option grouped).`
|
|
2561
2631
|
}));
|
|
2562
2632
|
}
|
|
2563
|
-
if (
|
|
2564
|
-
const missing = jobs.filter((job) =>
|
|
2565
|
-
|
|
2633
|
+
if (workflow.concurrency !== null) return [];
|
|
2634
|
+
const missing = workflow.jobs.filter((job) => {
|
|
2635
|
+
const calls = callOf$1(job);
|
|
2636
|
+
return job.concurrency === null && !(calls !== void 0 && grouped.includes(calls));
|
|
2637
|
+
});
|
|
2638
|
+
const edits = missing.length === 0 ? [] : groupEdits(file, text, workflow);
|
|
2566
2639
|
return missing.map((job) => ({
|
|
2567
2640
|
file,
|
|
2568
2641
|
line: job.line,
|
|
2569
|
-
message: `${file}: the job ${job.
|
|
2642
|
+
message: `${file}: the job ${job.id} has no concurrency group, and the workflow has none.`,
|
|
2570
2643
|
edits
|
|
2571
2644
|
}));
|
|
2572
2645
|
}
|
|
2573
2646
|
/** This function gives the breaks of the matrices: each `strategy` with a `matrix` has a `max-parallel` of `limit` or less. */
|
|
2574
|
-
function matrixBreaks(file, text,
|
|
2647
|
+
function matrixBreaks(file, text, workflow, limit) {
|
|
2575
2648
|
const breaks = [];
|
|
2576
2649
|
const originals = text.split(/\r?\n/);
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
const
|
|
2580
|
-
if (
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2650
|
+
for (const job of workflow.jobs) {
|
|
2651
|
+
const strategy = job.lines["strategy"];
|
|
2652
|
+
const matrix = job.lines["strategy.matrix"];
|
|
2653
|
+
if (strategy === void 0 || matrix === void 0) continue;
|
|
2654
|
+
const at = job.lines["strategy.max-parallel"];
|
|
2655
|
+
const block = (line, key) => (originals[line - 1] ?? "").trimStart().startsWith(`${key}:`);
|
|
2656
|
+
const wanted = (line) => `${" ".repeat(indentOf$1(originals[line - 1] ?? ""))}max-parallel: ${String(limit)}`;
|
|
2657
|
+
if (at === void 0) {
|
|
2658
|
+
const edits = block(matrix, "matrix") ? [{
|
|
2659
|
+
file,
|
|
2660
|
+
before: text,
|
|
2661
|
+
after: replaceLine(text, strategy, [originals[strategy - 1] ?? "", wanted(matrix)])
|
|
2662
|
+
}] : [];
|
|
2590
2663
|
breaks.push({
|
|
2591
2664
|
file,
|
|
2592
|
-
line:
|
|
2665
|
+
line: strategy,
|
|
2593
2666
|
message: `${file}: a matrix has no max-parallel.`,
|
|
2594
|
-
edits
|
|
2595
|
-
file,
|
|
2596
|
-
before: text,
|
|
2597
|
-
after
|
|
2598
|
-
}]
|
|
2667
|
+
edits
|
|
2599
2668
|
});
|
|
2600
|
-
} else if (
|
|
2601
|
-
const
|
|
2669
|
+
} else if (job.maxParallel === null || job.maxParallel > limit) {
|
|
2670
|
+
const edits = block(at, "max-parallel") ? [{
|
|
2671
|
+
file,
|
|
2672
|
+
before: text,
|
|
2673
|
+
after: replaceLine(text, at, [wanted(at)])
|
|
2674
|
+
}] : [];
|
|
2675
|
+
const value = job.maxParallel === null ? "a max-parallel that is not a whole number of 1 or more" : `max-parallel ${String(job.maxParallel)}`;
|
|
2602
2676
|
breaks.push({
|
|
2603
2677
|
file,
|
|
2604
|
-
line:
|
|
2605
|
-
message: `${file}: a matrix has
|
|
2606
|
-
edits
|
|
2607
|
-
file,
|
|
2608
|
-
before: text,
|
|
2609
|
-
after
|
|
2610
|
-
}]
|
|
2678
|
+
line: strategy,
|
|
2679
|
+
message: `${file}: a matrix has ${value}, and the most is ${String(limit)}.`,
|
|
2680
|
+
edits
|
|
2611
2681
|
});
|
|
2612
2682
|
}
|
|
2613
|
-
}
|
|
2683
|
+
}
|
|
2614
2684
|
return breaks;
|
|
2615
2685
|
}
|
|
2616
2686
|
/**
|
|
@@ -2703,8 +2773,8 @@ const runnerBudget = {
|
|
|
2703
2773
|
} catch {
|
|
2704
2774
|
continue;
|
|
2705
2775
|
}
|
|
2706
|
-
const
|
|
2707
|
-
breaks.push(...matrixBreaks(file, text,
|
|
2776
|
+
const workflow = parseWorkflow(file.slice(file.lastIndexOf("/") + 1), text);
|
|
2777
|
+
breaks.push(...matrixBreaks(file, text, workflow, limit), ...concurrencyBreaks(file, text, workflow, grouped));
|
|
2708
2778
|
if (options["minute"] !== false) {
|
|
2709
2779
|
if (cronLines(text).length > 0 && repository === void 0) breaks.push({
|
|
2710
2780
|
file,
|
|
@@ -21608,6 +21678,423 @@ const roadmapParses = {
|
|
|
21608
21678
|
return breaks;
|
|
21609
21679
|
}
|
|
21610
21680
|
};
|
|
21681
|
+
// src/workflow-expression.ts
|
|
21682
|
+
/** The events of a pull request: `github.head_ref` is not empty only on these. */
|
|
21683
|
+
const PULL_REQUEST_EVENTS = /* @__PURE__ */ new Set([
|
|
21684
|
+
"pull_request",
|
|
21685
|
+
"pull_request_target",
|
|
21686
|
+
"pull_request_review",
|
|
21687
|
+
"pull_request_review_comment"
|
|
21688
|
+
]);
|
|
21689
|
+
const literal = (text, truthy) => ({
|
|
21690
|
+
parts: /* @__PURE__ */ new Set(),
|
|
21691
|
+
truthy,
|
|
21692
|
+
text
|
|
21693
|
+
});
|
|
21694
|
+
const unknownBool = {
|
|
21695
|
+
parts: /* @__PURE__ */ new Set(),
|
|
21696
|
+
truthy: void 0
|
|
21697
|
+
};
|
|
21698
|
+
const union = (a, b) => ({
|
|
21699
|
+
parts: /* @__PURE__ */ new Set([...a.parts, ...b.parts]),
|
|
21700
|
+
truthy: a.truthy === b.truthy ? a.truthy : void 0
|
|
21701
|
+
});
|
|
21702
|
+
/** This function gives the part of a context path (lower case, with dots), or undefined for `github.event_name`. */
|
|
21703
|
+
function partOf(path) {
|
|
21704
|
+
if (/^github\.(ref|ref_name|head_ref|base_ref)$/.test(path) || /^github\.event\.(number|pull_request\.(number|head\.ref))$/.test(path)) return "ref";
|
|
21705
|
+
if (/^github\.(sha|event\.after|event\.pull_request\.head\.sha)$/.test(path)) return "commit";
|
|
21706
|
+
if (/^github\.run_(id|number|attempt)$/.test(path)) return "run";
|
|
21707
|
+
if (/^(inputs|github\.event\.inputs)(\.|$)/.test(path)) return "input";
|
|
21708
|
+
return "other";
|
|
21709
|
+
}
|
|
21710
|
+
/** This function gives the value of a context path on the event. */
|
|
21711
|
+
function contextValue(path, event) {
|
|
21712
|
+
const name = path.toLowerCase();
|
|
21713
|
+
if (name === "github.event_name") return literal(event, event !== "");
|
|
21714
|
+
if (/^github\.(workflow|repository|repository_owner|event\.repository\.\w+)$/.test(name)) return {
|
|
21715
|
+
parts: /* @__PURE__ */ new Set(),
|
|
21716
|
+
truthy: true
|
|
21717
|
+
};
|
|
21718
|
+
if (name === "github.head_ref") return {
|
|
21719
|
+
parts: /* @__PURE__ */ new Set(["ref"]),
|
|
21720
|
+
truthy: PULL_REQUEST_EVENTS.has(event)
|
|
21721
|
+
};
|
|
21722
|
+
const part = partOf(name);
|
|
21723
|
+
return {
|
|
21724
|
+
parts: /* @__PURE__ */ new Set([part]),
|
|
21725
|
+
truthy: part === "ref" || part === "commit" || part === "run" ? true : void 0
|
|
21726
|
+
};
|
|
21727
|
+
}
|
|
21728
|
+
/** This function gives the tokens of an expression, or undefined when it has a character that GitHub does not take. */
|
|
21729
|
+
function tokensOf(body) {
|
|
21730
|
+
const tokens = [];
|
|
21731
|
+
let at = 0;
|
|
21732
|
+
while (at < body.length) {
|
|
21733
|
+
const rest = body.slice(at);
|
|
21734
|
+
const space = /^\s+/.exec(rest);
|
|
21735
|
+
if (space) {
|
|
21736
|
+
at += space[0].length;
|
|
21737
|
+
continue;
|
|
21738
|
+
}
|
|
21739
|
+
const match = /^'((?:[^']|'')*)'/.exec(rest) ?? /^(-?\d+(?:\.\d+)?)/.exec(rest) ?? /^([A-Za-z_][\w-]*(?:\s*(?:\.\s*[A-Za-z_*][\w-]*|\[\s*'(?:[^']|'')*'\s*\]|\[\s*\*\s*\]))*)/.exec(rest) ?? /^(&&|\|\||==|!=|<=|>=|[!<>(),])/.exec(rest);
|
|
21740
|
+
if (!match) return void 0;
|
|
21741
|
+
const text = match[0];
|
|
21742
|
+
const kind = text.startsWith("'") ? "string" : /^-?\d/.test(text) ? "number" : /^[A-Za-z_]/.test(text) ? "name" : "op";
|
|
21743
|
+
tokens.push({
|
|
21744
|
+
kind,
|
|
21745
|
+
text: kind === "string" ? (match[1] ?? "").replaceAll("''", "'") : text
|
|
21746
|
+
});
|
|
21747
|
+
at += text.length;
|
|
21748
|
+
}
|
|
21749
|
+
return tokens;
|
|
21750
|
+
}
|
|
21751
|
+
/** This function gives the path of a context name: lower case, with dots, and `['x']` as `.x`. */
|
|
21752
|
+
const pathOf = (name) => name.replace(/\s+/g, "").replace(/\['((?:[^']|'')*)'\]/g, (_, key) => `.${key.replaceAll("''", "'")}`).toLowerCase();
|
|
21753
|
+
/** This function reads an expression on the event. It gives undefined when the expression does not parse. */
|
|
21754
|
+
function evaluateExpression(body, event) {
|
|
21755
|
+
const tokens = tokensOf(body);
|
|
21756
|
+
if (tokens === void 0 || tokens.length === 0) return void 0;
|
|
21757
|
+
let at = 0;
|
|
21758
|
+
const peek = () => tokens[at];
|
|
21759
|
+
const take = (text) => {
|
|
21760
|
+
if (peek()?.kind === "op" && peek()?.text === text) {
|
|
21761
|
+
at++;
|
|
21762
|
+
return true;
|
|
21763
|
+
}
|
|
21764
|
+
return false;
|
|
21765
|
+
};
|
|
21766
|
+
const primary = () => {
|
|
21767
|
+
const token = tokens[at++];
|
|
21768
|
+
if (token === void 0) return void 0;
|
|
21769
|
+
if (token.kind === "string") return literal(token.text, token.text !== "");
|
|
21770
|
+
if (token.kind === "number") return literal(String(Number(token.text)), Number(token.text) !== 0);
|
|
21771
|
+
if (token.kind === "op") {
|
|
21772
|
+
if (token.text !== "(") return void 0;
|
|
21773
|
+
const inner = or();
|
|
21774
|
+
return inner !== void 0 && take(")") ? inner : void 0;
|
|
21775
|
+
}
|
|
21776
|
+
const name = token.text.toLowerCase();
|
|
21777
|
+
if (name === "true" || name === "false") return literal(name, name === "true");
|
|
21778
|
+
if (name === "null") return literal("", false);
|
|
21779
|
+
if (!take("(")) return contextValue(pathOf(token.text), event);
|
|
21780
|
+
const args = [];
|
|
21781
|
+
if (!take(")")) {
|
|
21782
|
+
do {
|
|
21783
|
+
const arg = or();
|
|
21784
|
+
if (arg === void 0) return void 0;
|
|
21785
|
+
args.push(arg);
|
|
21786
|
+
} while (take(","));
|
|
21787
|
+
if (!take(")")) return void 0;
|
|
21788
|
+
}
|
|
21789
|
+
const parts = new Set(args.flatMap((arg) => [...arg.parts]));
|
|
21790
|
+
if (name === "format" || name === "join" || name === "tojson") return {
|
|
21791
|
+
parts,
|
|
21792
|
+
truthy: name === "format" ? void 0 : true
|
|
21793
|
+
};
|
|
21794
|
+
if (name === "contains" || name === "startswith" || name === "endswith" || name === "always" || name === "success" || name === "failure" || name === "cancelled") return unknownBool;
|
|
21795
|
+
return {
|
|
21796
|
+
parts,
|
|
21797
|
+
truthy: void 0
|
|
21798
|
+
};
|
|
21799
|
+
};
|
|
21800
|
+
const not = () => {
|
|
21801
|
+
if (!take("!")) return primary();
|
|
21802
|
+
const value = not();
|
|
21803
|
+
return value === void 0 ? void 0 : {
|
|
21804
|
+
parts: /* @__PURE__ */ new Set(),
|
|
21805
|
+
truthy: value.truthy === void 0 ? void 0 : !value.truthy
|
|
21806
|
+
};
|
|
21807
|
+
};
|
|
21808
|
+
const compare = () => {
|
|
21809
|
+
const left = not();
|
|
21810
|
+
if (left === void 0) return void 0;
|
|
21811
|
+
const op = peek();
|
|
21812
|
+
if (op?.kind !== "op" || ![
|
|
21813
|
+
"==",
|
|
21814
|
+
"!=",
|
|
21815
|
+
"<",
|
|
21816
|
+
"<=",
|
|
21817
|
+
">",
|
|
21818
|
+
">="
|
|
21819
|
+
].includes(op.text)) return left;
|
|
21820
|
+
at++;
|
|
21821
|
+
const right = not();
|
|
21822
|
+
if (right === void 0) return void 0;
|
|
21823
|
+
if ((op.text === "==" || op.text === "!=") && left.text !== void 0 && right.text !== void 0) {
|
|
21824
|
+
const same = left.text.toLowerCase() === right.text.toLowerCase();
|
|
21825
|
+
return literal(String(same === (op.text === "==")), same === (op.text === "=="));
|
|
21826
|
+
}
|
|
21827
|
+
return unknownBool;
|
|
21828
|
+
};
|
|
21829
|
+
const and = () => {
|
|
21830
|
+
let left = compare();
|
|
21831
|
+
while (left !== void 0 && take("&&")) {
|
|
21832
|
+
const right = compare();
|
|
21833
|
+
if (right === void 0) return void 0;
|
|
21834
|
+
left = left.truthy === false ? left : left.truthy === true ? right : union(left, right);
|
|
21835
|
+
}
|
|
21836
|
+
return left;
|
|
21837
|
+
};
|
|
21838
|
+
const or = () => {
|
|
21839
|
+
let left = and();
|
|
21840
|
+
while (left !== void 0 && take("||")) {
|
|
21841
|
+
const right = and();
|
|
21842
|
+
if (right === void 0) return void 0;
|
|
21843
|
+
left = left.truthy === true ? left : left.truthy === false ? right : union(left, right);
|
|
21844
|
+
}
|
|
21845
|
+
return left;
|
|
21846
|
+
};
|
|
21847
|
+
const value = or();
|
|
21848
|
+
return value !== void 0 && at === tokens.length ? value : void 0;
|
|
21849
|
+
}
|
|
21850
|
+
/** This function gives the bodies of the expressions of a text (the parts between `${{` and `}}`). */
|
|
21851
|
+
function bodiesOf(text) {
|
|
21852
|
+
const bodies = [];
|
|
21853
|
+
let at = text.indexOf("${{");
|
|
21854
|
+
while (at >= 0) {
|
|
21855
|
+
const end = text.indexOf("}}", at + 3);
|
|
21856
|
+
if (end < 0) break;
|
|
21857
|
+
bodies.push(text.slice(at + 3, end));
|
|
21858
|
+
at = text.indexOf("${{", end + 2);
|
|
21859
|
+
}
|
|
21860
|
+
return bodies;
|
|
21861
|
+
}
|
|
21862
|
+
/**
|
|
21863
|
+
* This function gives the parts of a run that a concurrency group depends on, on the event. A group with no expression
|
|
21864
|
+
* depends on no part: all runs share it. An expression that does not parse depends on the run, so each run has its own group.
|
|
21865
|
+
*/
|
|
21866
|
+
function groupParts(group, event) {
|
|
21867
|
+
const parts = /* @__PURE__ */ new Set();
|
|
21868
|
+
for (const body of bodiesOf(group)) {
|
|
21869
|
+
const value = evaluateExpression(body, event);
|
|
21870
|
+
if (value === void 0) parts.add("run");
|
|
21871
|
+
else for (const part of value.parts) parts.add(part);
|
|
21872
|
+
}
|
|
21873
|
+
return parts;
|
|
21874
|
+
}
|
|
21875
|
+
/**
|
|
21876
|
+
* This function tells if a job with the condition `condition` (an `if`, with or with no `${{ }}`) can run on the event.
|
|
21877
|
+
* It is false only when the condition is false on each run of the event.
|
|
21878
|
+
*/
|
|
21879
|
+
function mayRun(condition, event) {
|
|
21880
|
+
const text = condition.trim();
|
|
21881
|
+
if (text === "") return true;
|
|
21882
|
+
const whole = /^\$\{\{([\s\S]*)\}\}$/.exec(text);
|
|
21883
|
+
return evaluateExpression(whole ? whole[1] ?? "" : text, event)?.truthy !== false;
|
|
21884
|
+
}
|
|
21885
|
+
// src/rules/runner-peak.ts
|
|
21886
|
+
/**
|
|
21887
|
+
* The rule `runner-peak`: the workflows of a repository hold at most its share of the runners in a busy minute. The peak
|
|
21888
|
+
* of a job is the jobs of one run (a matrix, capped by its `max-parallel`) times the runs that its concurrency group lets
|
|
21889
|
+
* run at one time. A burst of merges on `push` and a burst of pull requests give these runs. The peak of a workflow is
|
|
21890
|
+
* the sum over its jobs.
|
|
21891
|
+
*/
|
|
21892
|
+
/** The jobs of a matrix that the reader cannot count and that has no `max-parallel`: the most that the rule runner-budget lets run. */
|
|
21893
|
+
const UNKNOWN_MATRIX_JOBS = 3;
|
|
21894
|
+
const PUSH_EVENTS = /* @__PURE__ */ new Set([
|
|
21895
|
+
"push",
|
|
21896
|
+
"merge_group",
|
|
21897
|
+
"workflow_run"
|
|
21898
|
+
]);
|
|
21899
|
+
const PULL_EVENTS = /* @__PURE__ */ new Set(["pull_request", "pull_request_target"]);
|
|
21900
|
+
/** This function gives the class of an event, or undefined for `workflow_call`: the caller counts the jobs of a called workflow. */
|
|
21901
|
+
function eventClass(event) {
|
|
21902
|
+
if (event === "workflow_call") return void 0;
|
|
21903
|
+
return PUSH_EVENTS.has(event) ? "push" : PULL_EVENTS.has(event) ? "pull" : "other";
|
|
21904
|
+
}
|
|
21905
|
+
/**
|
|
21906
|
+
* This function gives the runs of a concurrency group that run at one time on the event. A group that depends on the commit
|
|
21907
|
+
* or the run, or no group, gives a burst on `push` and on pull requests. A group of the branch gives one run on `push` (the
|
|
21908
|
+
* default branch) and a burst of pull requests. Each other event gives one run.
|
|
21909
|
+
*/
|
|
21910
|
+
function runsAtOnce(concurrency, event, burst) {
|
|
21911
|
+
const kind = eventClass(event);
|
|
21912
|
+
if (kind === void 0 || kind === "other") return 1;
|
|
21913
|
+
if (concurrency === null) return burst;
|
|
21914
|
+
const parts = groupParts(concurrency.group, event);
|
|
21915
|
+
if (parts.has("commit") || parts.has("run")) return burst;
|
|
21916
|
+
return parts.has("ref") && kind === "pull" ? burst : 1;
|
|
21917
|
+
}
|
|
21918
|
+
/** The file name of the workflow that a job calls, and if it is a file of the same repository (`./.github/workflows/`). */
|
|
21919
|
+
function callOf(job) {
|
|
21920
|
+
const at = job.uses.indexOf(".github/workflows/");
|
|
21921
|
+
if (at < 0) return void 0;
|
|
21922
|
+
return {
|
|
21923
|
+
name: job.uses.slice(at + 18),
|
|
21924
|
+
local: job.uses.startsWith("./")
|
|
21925
|
+
};
|
|
21926
|
+
}
|
|
21927
|
+
/** This function gives the jobs of one run of a job that calls no workflow: 1, or the jobs of its matrix that run together. */
|
|
21928
|
+
function matrixPeak(job) {
|
|
21929
|
+
if (job.lines["strategy.matrix"] === void 0) return 1;
|
|
21930
|
+
const limit = job.maxParallel;
|
|
21931
|
+
if (job.matrixJobs === null) return limit ?? 3;
|
|
21932
|
+
return Math.max(1, Math.min(job.matrixJobs, limit ?? job.matrixJobs));
|
|
21933
|
+
}
|
|
21934
|
+
/** This function gives the jobs of one run of a workflow on the event: the sum over the jobs that can run on it. */
|
|
21935
|
+
function jobsOfRun(workflow, event, local, options, seen) {
|
|
21936
|
+
let jobs = 0;
|
|
21937
|
+
let known = true;
|
|
21938
|
+
for (const job of workflow.jobs) {
|
|
21939
|
+
if (!mayRun(job.if, event)) continue;
|
|
21940
|
+
const one = jobOfRun(job, event, local, options, seen);
|
|
21941
|
+
jobs += one.jobs;
|
|
21942
|
+
known &&= one.known;
|
|
21943
|
+
}
|
|
21944
|
+
return {
|
|
21945
|
+
jobs,
|
|
21946
|
+
known
|
|
21947
|
+
};
|
|
21948
|
+
}
|
|
21949
|
+
/** This function gives the jobs of one run of a job: its matrix, or the jobs of the workflow that it calls. */
|
|
21950
|
+
function jobOfRun(job, event, local, options, seen) {
|
|
21951
|
+
const call = callOf(job);
|
|
21952
|
+
if (call === void 0) return {
|
|
21953
|
+
jobs: matrixPeak(job),
|
|
21954
|
+
known: true
|
|
21955
|
+
};
|
|
21956
|
+
const file = call.local ? local.get(call.name) : void 0;
|
|
21957
|
+
if (file !== void 0) return seen.has(call.name) ? {
|
|
21958
|
+
jobs: 0,
|
|
21959
|
+
known: true
|
|
21960
|
+
} : jobsOfRun(file, event, local, options, /* @__PURE__ */ new Set([...seen, call.name]));
|
|
21961
|
+
const count = options.called[call.name];
|
|
21962
|
+
return count === void 0 ? {
|
|
21963
|
+
jobs: 1,
|
|
21964
|
+
known: false
|
|
21965
|
+
} : {
|
|
21966
|
+
jobs: count,
|
|
21967
|
+
known: true
|
|
21968
|
+
};
|
|
21969
|
+
}
|
|
21970
|
+
/**
|
|
21971
|
+
* This function gives the peak of each workflow of a repository in a busy minute. In each class of events, it takes the
|
|
21972
|
+
* event with the most jobs. The peak of a job is its jobs of one run times the runs of its group (the group at the top of
|
|
21973
|
+
* the file, else the group of the job). The sum over the jobs is an upper bound: a job that `needs` another job does not
|
|
21974
|
+
* run at the same time as it.
|
|
21975
|
+
*/
|
|
21976
|
+
function workflowPeaks(workflows, options) {
|
|
21977
|
+
const local = new Map(workflows.map((workflow) => [workflow.file, workflow]));
|
|
21978
|
+
return workflows.flatMap((workflow) => {
|
|
21979
|
+
const classes = {};
|
|
21980
|
+
for (const event of workflow.triggers) {
|
|
21981
|
+
const kind = eventClass(event);
|
|
21982
|
+
if (kind === void 0) continue;
|
|
21983
|
+
const jobs = workflow.jobs.filter((job) => mayRun(job.if, event)).map((job) => {
|
|
21984
|
+
const one = jobOfRun(job, event, local, options, /* @__PURE__ */ new Set([workflow.file]));
|
|
21985
|
+
return {
|
|
21986
|
+
id: job.id,
|
|
21987
|
+
line: job.line,
|
|
21988
|
+
jobs: one.jobs,
|
|
21989
|
+
runs: runsAtOnce(workflow.concurrency ?? job.concurrency, event, options.burst),
|
|
21990
|
+
known: one.known
|
|
21991
|
+
};
|
|
21992
|
+
});
|
|
21993
|
+
const peak = jobs.reduce((sum, job) => sum + job.jobs * job.runs, 0);
|
|
21994
|
+
if (peak > (classes[kind]?.peak ?? -1)) classes[kind] = {
|
|
21995
|
+
event,
|
|
21996
|
+
peak,
|
|
21997
|
+
jobs
|
|
21998
|
+
};
|
|
21999
|
+
}
|
|
22000
|
+
const peak = Object.values(classes).reduce((sum, item) => sum + item.peak, 0);
|
|
22001
|
+
return Object.keys(classes).length === 0 ? [] : [{
|
|
22002
|
+
file: workflow.file,
|
|
22003
|
+
peak,
|
|
22004
|
+
classes
|
|
22005
|
+
}];
|
|
22006
|
+
});
|
|
22007
|
+
}
|
|
22008
|
+
/** This function reads the option `called`: a list of `<file>=<jobs>`. A pair that does not parse is left out. */
|
|
22009
|
+
function calledJobs(values) {
|
|
22010
|
+
const out = {};
|
|
22011
|
+
for (const value of values) {
|
|
22012
|
+
const match = /^\s*([^=\s]+)\s*=\s*(\d+)\s*$/.exec(value);
|
|
22013
|
+
if (match) out[match[1] ?? ""] = Number(match[2]);
|
|
22014
|
+
}
|
|
22015
|
+
return out;
|
|
22016
|
+
}
|
|
22017
|
+
/** This function gives the text of the peak of a workflow: `ci.yml 15 (push: 5 runs of 3 jobs)`. */
|
|
22018
|
+
function peakText(item) {
|
|
22019
|
+
const parts = Object.entries(item.classes).map(([kind, value]) => {
|
|
22020
|
+
const runs = Math.max(...value.jobs.map((job) => job.runs), 0);
|
|
22021
|
+
const unknown = value.jobs.some((job) => !job.known) ? ", a call of an unknown workflow counts 1" : "";
|
|
22022
|
+
return `${kind} ${String(value.peak)} on ${value.event} (up to ${String(runs)} runs at one time${unknown})`;
|
|
22023
|
+
});
|
|
22024
|
+
return `${item.file.slice(item.file.lastIndexOf("/") + 1)} ${String(item.peak)}: ${parts.join("; ")}`;
|
|
22025
|
+
}
|
|
22026
|
+
/**
|
|
22027
|
+
* The jobs of each run of the shared workflows of the template, on the event with the most jobs. A test of the template
|
|
22028
|
+
* computes them from its files, so a change of a shared workflow changes this list.
|
|
22029
|
+
*/
|
|
22030
|
+
const TEMPLATE_CALLED = [
|
|
22031
|
+
"reusable-ai-review.yml=1",
|
|
22032
|
+
"reusable-ci.yml=7",
|
|
22033
|
+
"reusable-codex-review.yml=2",
|
|
22034
|
+
"reusable-lockfile.yml=1",
|
|
22035
|
+
"reusable-mutation.yml=5",
|
|
22036
|
+
"reusable-pages-check.yml=1",
|
|
22037
|
+
"reusable-pages.yml=4",
|
|
22038
|
+
"reusable-queue.yml=1",
|
|
22039
|
+
"reusable-release-build.yml=1",
|
|
22040
|
+
"reusable-release-tag.yml=1",
|
|
22041
|
+
"reusable-release-tree.yml=1",
|
|
22042
|
+
"reusable-security.yml=3"
|
|
22043
|
+
];
|
|
22044
|
+
const runnerPeak = {
|
|
22045
|
+
id: "runner-peak",
|
|
22046
|
+
title: "The workflows of a repository hold at most its share of the runners in a busy minute.",
|
|
22047
|
+
reason: "The repositories of an account or an organization share its runners. The rule runner-budget caps each matrix and each workflow, but not the sum: a run of main has the group of its commit (the rule main-runs-finish), so a burst of merges starts a full run for each merge. On 2026-11-24, five push runs of one repository waited with 58 of the 60 jobs of its organization, and a bench of that repository waited 15.9 minutes for a runner.",
|
|
22048
|
+
fix: "Lower the `max-parallel` of the largest matrices, run heavy jobs only on `workflow_dispatch` or a schedule, or give a job that a run of `push` does not need an `if` that is false on `push`. Else the organization gives the repository a larger share (the option share).",
|
|
22049
|
+
sources: [{
|
|
22050
|
+
repo: "private",
|
|
22051
|
+
rule: "runner-slots",
|
|
22052
|
+
doc: "a decision of 2026-10-30: the runner slots: a cap of 40, heavy work at most 28"
|
|
22053
|
+
}],
|
|
22054
|
+
failsFrom: "2026-12-09",
|
|
22055
|
+
options: {
|
|
22056
|
+
share: {
|
|
22057
|
+
type: "number",
|
|
22058
|
+
default: 0,
|
|
22059
|
+
description: "The most jobs that the workflows of the repository hold at one time in a busy minute. The organization gives each repository its share of the pool. 0 turns the rule off: the CI of the template alone can hold 145 jobs in a busy minute, so no one share fits each repository."
|
|
22060
|
+
},
|
|
22061
|
+
burst: {
|
|
22062
|
+
type: "number",
|
|
22063
|
+
default: 5,
|
|
22064
|
+
description: "The runs of push, or of pull requests, that start in a busy minute when each run has its own group."
|
|
22065
|
+
},
|
|
22066
|
+
called: {
|
|
22067
|
+
type: "strings",
|
|
22068
|
+
default: TEMPLATE_CALLED,
|
|
22069
|
+
description: "The jobs of each run of a called workflow of another repository, as `<file>=<jobs>`. A call of a workflow that is not in the list counts 1."
|
|
22070
|
+
}
|
|
22071
|
+
},
|
|
22072
|
+
check(context, options) {
|
|
22073
|
+
const share = Number(options["share"]);
|
|
22074
|
+
if (!(share > 0)) return { skipped: "the option share is 0" };
|
|
22075
|
+
const files = context.gitFiles();
|
|
22076
|
+
if (files === void 0) return { skipped: "the root is not in a git repository" };
|
|
22077
|
+
const paths = files.filter((path) => WORKFLOW$1.test(path)).sort(byCode);
|
|
22078
|
+
if (paths.length === 0) return { skipped: "the repository has no workflow" };
|
|
22079
|
+
const workflows = [];
|
|
22080
|
+
for (const path of paths) try {
|
|
22081
|
+
workflows.push(parseWorkflow(path.slice(path.lastIndexOf("/") + 1), readFileSync(join(context.root, path), "utf8")));
|
|
22082
|
+
} catch {
|
|
22083
|
+
continue;
|
|
22084
|
+
}
|
|
22085
|
+
const called = calledJobs(Array.isArray(options["called"]) ? options["called"] : []);
|
|
22086
|
+
const peaks = workflowPeaks(workflows, {
|
|
22087
|
+
burst: Math.max(1, Number(options["burst"])),
|
|
22088
|
+
called
|
|
22089
|
+
}).sort((a, b) => b.peak - a.peak);
|
|
22090
|
+
const total = peaks.reduce((sum, item) => sum + item.peak, 0);
|
|
22091
|
+
if (total <= share) return [];
|
|
22092
|
+
return [{
|
|
22093
|
+
file: `.github/workflows/${peaks[0]?.file ?? ""}`,
|
|
22094
|
+
message: `The workflows can hold ${String(total)} jobs at one time in a busy minute, and the share of the repository is ${String(share)}. ${peaks.map(peakText).join(". ")}.`
|
|
22095
|
+
}];
|
|
22096
|
+
}
|
|
22097
|
+
};
|
|
21611
22098
|
// src/rules/schedule-literals.ts
|
|
21612
22099
|
/**
|
|
21613
22100
|
* The rule `schedule-literals`: a workflow can compare `github.event.schedule` with a cron in quotes. Each such cron
|
|
@@ -23331,6 +23818,7 @@ const RULES = [
|
|
|
23331
23818
|
roadmapParses,
|
|
23332
23819
|
workflowParses,
|
|
23333
23820
|
runnerBudget,
|
|
23821
|
+
runnerPeak,
|
|
23334
23822
|
mainRunsFinish,
|
|
23335
23823
|
pushMainOnly,
|
|
23336
23824
|
pipeFails,
|
|
@@ -24364,6 +24852,6 @@ function runHook(args, io) {
|
|
|
24364
24852
|
git: (gitArgs) => runGit(io.cwd, gitArgs)
|
|
24365
24853
|
}, io);
|
|
24366
24854
|
}
|
|
24367
|
-
export {
|
|
24855
|
+
export { requiredScripts as $, LICENSE_TEXTS as $n, noBuildOutput as $t, scriptsOf as A, SHARED_ACTIONS as An, parseJsonc as Ar, packNoBuildinfo as At, TEMPLATE_CALLED as B, SUMMARY_GATES as Bn, parseRuleConfig as Br, privatePatterns as Bt, setVersions as C, npmNames as Cn, codePackages as Cr, pagesAfterRelease as Ct, trustPolicy as D, serviceRunMain as Dn, lineOf as Dr, pagesSite as Dt, TRAIN_SCOPES as E, runCalls as En, keyLine as Er, pagesCalls as Et, sourceMain as F, setupCue as Fn, runGitShow as Fr, PRIVATE_PATTERNS_VARIABLE as Ft, runnerPeak as G, SECURITY_SCAN_COMMIT as Gn, isAllowedHit as Gt, calledJobs as H, hasSummaryJob as Hn, PRIVATE_NAME_LIST as Ht, HOME_TIMEOUT_MS as I, SECURITY_FILE as In, showFiles as Ir, invalidPatternBreaks as It, evaluateExpression as J, securityCallers as Jn, lineNameHits as Jt, runsAtOnce as K, SECURITY_SCAN_INPUTS as Kn, isCommonUse as Kt, blockHash as L, isSecurityGate as Ln, specifiersOf as Lr, noLocalPaths as Lt, testsRequired as M, SHARED_WORKFLOWS as Mn, replaceLine as Mr, HOME_PATTERNS as Mt, isSourcePath as N, callsSharedCi as Nn, repositoryOfRemote as Nr, PRIVATE_NAMES_FILE_CONFIG as Nt, typedScripts as O, hasTests as On, matchesAny as Or, exportsRequire as Ot, pathsOf as P, sharedCi as Pn, runGit as Pr, PRIVATE_NAMES_FILE_VARIABLE as Pt, roadmapParses as Q, scheduleMinute as Qn, pathNameHit as Qt, githubFetch as R, securityGate as Rn, defaultOptions as Rr, privateNamesFile as Rt, namedVersions as S, npmDrift as Sn, cleanPath as Sr, siteCheckInCi as St, IGNORE_AFTER as T, SERVICE_PACKAGE as Tn, inFolder as Tr, PAGES_WORKFLOWS as Tt, eventClass as U, startsOnPullRequest as Un, PrivateNameListError as Ut, UNKNOWN_MATRIX_JOBS as V, addSummaryJob as Vn, privateTextBreaks as Vt, matrixPeak as W, summaryJobRule as Wn, firstNameMatch as Wt, mayRun as X, withOneJob as Xn, nameMatches as Xt, groupParts as Y, securityOneJob as Yn, mergePrivateNames as Yt, roadmapOfLine as Z, runnerBudget as Zn, parsePrivateNames as Zt, runPrePushArgs as _, MAP_RULE as _n, yamlFaults as _r, swallowsTests as _t, listRules as a, homeModule as an, ACTIONS_COMMIT as ar, reachOf as at, GITHUB_YAML as b, mapText as bn, DEPENDENCY_FIELDS as br, isPinned as bt, runCli as c, modulesOf as cn, prPathFilters as cr, UNSHIPPED_FILES as ct, HOOK_MARKER as d, messageOf as dn, summaryName as dr, unreleasedChangeRule as dt, REAL_COMPARE as en, authorOf as er, releaseFiles as et, NO_READ_LINE as f, repoOf as fn, gateAfterCancel as fr, playwrightInstall as ft, prePush as g, HOMES as gn, readWorkflow as gr, startsTests as gt, parsePrePushArgs as h, HOME_EXPORTS as hn, readAction as hr, parseAdvisory as ht, formatResult as i, apiReportScript as in, repositoryIsPublic as ir, publishedMinorRule as it, typedFiles as j, SHARED_CI as jn, readJsonc as jr, DEFAULT_ALLOWED as jt, configsOfScript as k, tsconfigTest as kn, parseCatFileBatch as kr, publishTextSafe as kt, runFix as l, declaredName as ln, skippableJobs as lr, npmLookup as lt, installHook as m, signaturesOf as mn, parseWorkflow as mr, jobFails as mt, annotations as n, mainCheck as nn, licenseFileOf as nr, minorOf as nt, readConfig as o, moduleMessage as on, convertGate as or, NPM_REGISTRY as ot, PRE_PUSH_HOOK as p, reposOf as pn, MATRIX_EXPAND_MAX as pr, hiddenFailures as pt, workflowPeaks as q, SECURITY_TIMEOUT_MINUTES as qn, lineNameHit as qt, createContext as r, coverageProvider as rn, mitText as rr, publishedMinor as rt, runChecks as s, moduleUses as sn, gateTrigger as sr, SHIPPED_FIELDS as st, USAGE as t, hasImportMetaMain as tn, licenseFile as tr, lockedVersions as tt, summaryMarkdown as u, homePackage as un, summaryJob as ur, unreleasedChange as ut, RULES as v, findHomes as vn, STRICT_OPTIONS as vr, pipeFails as vt, versionTitle as w, readOverlay as wn, hasFile as wr, pushMainOnly as wt, workflowParses as x, mergeHomes as xn, RULE_WARN_DAYS as xr, pinnedGitDeps as xt, workspaceProtocol as y, mapMarkdown as yn, cuePreset as yr, isGitSpecifier as yt, sharedDocsRule as z, securityWorkflow as zn, parseConfig as zr, privateNamesFiles as zt };
|
|
24368
24856
|
|
|
24369
|
-
//# sourceMappingURL=run-
|
|
24857
|
+
//# sourceMappingURL=run-z_zuxE9M.js.map
|