@rmartz/pr-policy 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/bin/pr-policy.js +9 -3
- package/dist/{chunk-KWZP3U4O.js → chunk-UI7QG6XT.js} +52 -1
- package/dist/index.d.ts +19 -2
- package/dist/index.js +11 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ new required-status name.
|
|
|
19
19
|
| **Base branch** ([docs](docs/checks/base-branch.md)) | The PR targets a branch other than the default and it isn't a non-epic PR on an open epic's branch. A stacked PR waits for its base PR (shows as pending); a base no open PR heads blocks. |
|
|
20
20
|
| **Title-type rules** ([docs](docs/checks/title.md)) | The squash title isn't a valid Conventional Commit, puts `!` on a non-functional type, disagrees with the `breaking change` label, types a linter/formatter bump as a non-release, non-`ci` type, or changes paths its type rules out (`docs`, `test`, `refactor`, `ci`). |
|
|
21
21
|
| **UAT sign-off** ([docs](docs/checks/uat.md)) | pr-lifecycle's sign-off status says the head needs UAT (or, before a repo cuts over, the PR isn't docs, tests, CI, dependency-only, or repo metadata), or the status can't be trusted, and no trusted user has applied `no UAT needed`, or `UAT passed` (or `tested`) since the last push (shows as pending). |
|
|
22
|
+
| **UAT label presence** ([docs](docs/checks/uat-label.md)), opt-in | `require-uat-label` is on and the PR carries none of `no UAT needed`, `UAT pending`, `UAT ready`, `UAT passed` (shows as pending). |
|
|
22
23
|
| **Dependabot claim verification** ([docs](docs/checks/dependabot.md)) | A Dependabot PR touches a non-dependency path, changes a dependency its description doesn't claim, pins a version other than the claimed one, or edits anything Dependabot never edits (a `package.json` script, a workflow step). |
|
|
23
24
|
| Domain labels (backlog) | Never blocks. Additive path-glob → domain-label map. |
|
|
24
25
|
| Milestone inheritance (backlog) | Never blocks. Issue → PR milestone. |
|
package/dist/bin/pr-policy.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
postVerdict,
|
|
9
9
|
resolveRepoTarget,
|
|
10
10
|
selectChecks
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-UI7QG6XT.js";
|
|
12
12
|
|
|
13
13
|
// src/bin/pr-policy.ts
|
|
14
14
|
import { readFile } from "fs/promises";
|
|
@@ -31,7 +31,11 @@ var USAGE = `Usage:
|
|
|
31
31
|
--sign-off-status-creators <login,...>
|
|
32
32
|
GitHub App logins trusted to post the pr-lifecycle/sign-off status,
|
|
33
33
|
e.g. rmartz-merge-bot[bot]. Exact matches only; github-actions[bot]
|
|
34
|
-
is refused. A person who could merge is always trusted
|
|
34
|
+
is refused. A person who could merge is always trusted.
|
|
35
|
+
--require-uat-label
|
|
36
|
+
Hold any PR that carries no UAT label (no UAT needed, UAT pending,
|
|
37
|
+
UAT ready, UAT passed). Off by default; turn it on once pr-lifecycle,
|
|
38
|
+
which applies the labels, runs on the default branch.`;
|
|
35
39
|
async function readInput(path) {
|
|
36
40
|
if (path !== "-") return readFile(path, "utf8");
|
|
37
41
|
const chunks = [];
|
|
@@ -50,6 +54,7 @@ async function main(argv) {
|
|
|
50
54
|
json: { type: "boolean" },
|
|
51
55
|
"skip-uat": { type: "boolean" },
|
|
52
56
|
"sign-off-status-creators": { type: "string" },
|
|
57
|
+
"require-uat-label": { type: "boolean" },
|
|
53
58
|
help: { type: "boolean", short: "h" }
|
|
54
59
|
}
|
|
55
60
|
});
|
|
@@ -63,7 +68,8 @@ async function main(argv) {
|
|
|
63
68
|
}
|
|
64
69
|
const checks = selectChecks({
|
|
65
70
|
skipUat: values["skip-uat"],
|
|
66
|
-
signOffStatusCreators: (values["sign-off-status-creators"] ?? "").split(",")
|
|
71
|
+
signOffStatusCreators: (values["sign-off-status-creators"] ?? "").split(","),
|
|
72
|
+
requireUatLabel: values["require-uat-label"]
|
|
67
73
|
});
|
|
68
74
|
if (values.facts !== void 0) {
|
|
69
75
|
const evaluation = await evaluatePolicy(parseFacts(await readInput(values.facts)), checks);
|
|
@@ -6,6 +6,17 @@ var CI_CHANGE_APPROVED_LABEL = "CI change approved";
|
|
|
6
6
|
var UAT_PASSED_LABEL = "UAT passed";
|
|
7
7
|
var LEGACY_UAT_PASSED_LABEL = "tested";
|
|
8
8
|
var NO_UAT_NEEDED_LABEL = "no UAT needed";
|
|
9
|
+
var UAT_PENDING_LABEL = "UAT pending";
|
|
10
|
+
var UAT_READY_LABEL = "UAT ready";
|
|
11
|
+
var LEGACY_UAT_READY_LABEL = "ready for UAT";
|
|
12
|
+
var UAT_LABELS = [
|
|
13
|
+
NO_UAT_NEEDED_LABEL,
|
|
14
|
+
UAT_PENDING_LABEL,
|
|
15
|
+
UAT_READY_LABEL,
|
|
16
|
+
UAT_PASSED_LABEL,
|
|
17
|
+
LEGACY_UAT_PASSED_LABEL,
|
|
18
|
+
LEGACY_UAT_READY_LABEL
|
|
19
|
+
];
|
|
9
20
|
var CONTAINED_BREAK_LABEL = "contained break";
|
|
10
21
|
var SIGN_OFF_LABELS = [
|
|
11
22
|
CI_CHANGE_APPROVED_LABEL,
|
|
@@ -1550,6 +1561,38 @@ var titleCheck = {
|
|
|
1550
1561
|
evaluate: async (pr) => decideTitle(pr)
|
|
1551
1562
|
};
|
|
1552
1563
|
|
|
1564
|
+
// src/checks/uat-label.ts
|
|
1565
|
+
var UAT_LABEL_CHECK = "uat-label";
|
|
1566
|
+
var UAT = new Set(UAT_LABELS.map((label) => label.toLowerCase()));
|
|
1567
|
+
function decideUatLabel(pr) {
|
|
1568
|
+
const present = pr.labels.filter((label) => UAT.has(label.toLowerCase()));
|
|
1569
|
+
if (present.length > 0) {
|
|
1570
|
+
const names = present.map((label) => `\`${label}\``).join(", ");
|
|
1571
|
+
return {
|
|
1572
|
+
findings: [
|
|
1573
|
+
{
|
|
1574
|
+
check: UAT_LABEL_CHECK,
|
|
1575
|
+
message: `UAT determination recorded: ${names}.`,
|
|
1576
|
+
effect: "info"
|
|
1577
|
+
}
|
|
1578
|
+
]
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
return {
|
|
1582
|
+
findings: [
|
|
1583
|
+
{
|
|
1584
|
+
check: UAT_LABEL_CHECK,
|
|
1585
|
+
message: "Waiting for a UAT determination: no UAT label is on the PR. pr-lifecycle applies one of `no UAT needed`, `UAT pending`, `UAT ready`, or `UAT passed` when it runs; a person can apply one too.",
|
|
1586
|
+
effect: "hold"
|
|
1587
|
+
}
|
|
1588
|
+
]
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
var uatLabelCheck = {
|
|
1592
|
+
name: UAT_LABEL_CHECK,
|
|
1593
|
+
evaluate: async (pr) => decideUatLabel(pr)
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1553
1596
|
// src/checks/base-branch.ts
|
|
1554
1597
|
var BASE_BRANCH_CHECK = "base-branch";
|
|
1555
1598
|
var isEpic = (labels) => labels.some((label) => label.trim().toLowerCase() === EPIC_LABEL);
|
|
@@ -1727,7 +1770,11 @@ function selectChecks(options = {}) {
|
|
|
1727
1770
|
if (check === ciChangeCheck) return ciChangeCheckFor(trustedBots);
|
|
1728
1771
|
return check;
|
|
1729
1772
|
});
|
|
1730
|
-
|
|
1773
|
+
const selected = options.skipUat ? configured.filter((check) => check.name !== uatCheck.name) : configured;
|
|
1774
|
+
if (!options.requireUatLabel) return selected;
|
|
1775
|
+
return selected.flatMap(
|
|
1776
|
+
(check) => check === dependabotCheck ? [uatLabelCheck, check] : [check]
|
|
1777
|
+
);
|
|
1731
1778
|
}
|
|
1732
1779
|
|
|
1733
1780
|
// src/report.ts
|
|
@@ -2375,6 +2422,7 @@ export {
|
|
|
2375
2422
|
SIGN_OFF_STATUS_CONTEXT,
|
|
2376
2423
|
CI_APPROVAL_NEEDED_LABEL,
|
|
2377
2424
|
CI_CHANGE_APPROVED_LABEL,
|
|
2425
|
+
UAT_LABELS,
|
|
2378
2426
|
DO_NOT_MERGE_LABEL,
|
|
2379
2427
|
DNM_LABEL,
|
|
2380
2428
|
BLOCKED_LABEL,
|
|
@@ -2416,6 +2464,9 @@ export {
|
|
|
2416
2464
|
TITLE_CHECK,
|
|
2417
2465
|
decideTitle,
|
|
2418
2466
|
titleCheck,
|
|
2467
|
+
UAT_LABEL_CHECK,
|
|
2468
|
+
decideUatLabel,
|
|
2469
|
+
uatLabelCheck,
|
|
2419
2470
|
CHECKS,
|
|
2420
2471
|
selectChecks,
|
|
2421
2472
|
POLICY_OUTCOMES,
|
package/dist/index.d.ts
CHANGED
|
@@ -173,10 +173,18 @@ interface PolicyOptions {
|
|
|
173
173
|
* unaffected: they still need a trusted person.
|
|
174
174
|
*/
|
|
175
175
|
signOffStatusCreators?: readonly string[];
|
|
176
|
+
/**
|
|
177
|
+
* Hold every PR that carries no UAT label (`uat-label`, rmartz/pr-policy#103).
|
|
178
|
+
* Off by default: turn it on once the repo's pr-lifecycle caller, which
|
|
179
|
+
* applies the labels, is on the default branch. It runs even with `skipUat`.
|
|
180
|
+
*/
|
|
181
|
+
requireUatLabel?: boolean;
|
|
176
182
|
}
|
|
177
183
|
/**
|
|
178
184
|
* The checks to run for a repo configured with `options`, in report order.
|
|
179
|
-
*
|
|
185
|
+
* The opt-in `uat-label` check is not in `CHECKS`; it runs just before
|
|
186
|
+
* `dependabot` when `requireUatLabel` is set. Throws on an invalid
|
|
187
|
+
* `signOffStatusCreators` entry.
|
|
180
188
|
*/
|
|
181
189
|
declare function selectChecks(options?: PolicyOptions): readonly PolicyCheck[];
|
|
182
190
|
|
|
@@ -205,6 +213,11 @@ declare const CI_APPROVAL_NEEDED_LABEL = "CI approval needed";
|
|
|
205
213
|
* applies it.
|
|
206
214
|
*/
|
|
207
215
|
declare const CI_CHANGE_APPROVED_LABEL = "CI change approved";
|
|
216
|
+
/**
|
|
217
|
+
* Every label that records a UAT determination on a PR, current and legacy
|
|
218
|
+
* names alike. The `uat-label` check passes when any one is present.
|
|
219
|
+
*/
|
|
220
|
+
declare const UAT_LABELS: readonly ["no UAT needed", "UAT pending", "UAT ready", "UAT passed", "tested", "ready for UAT"];
|
|
208
221
|
/**
|
|
209
222
|
* Labels a person puts on a PR to stop it merging. The merge-block check holds
|
|
210
223
|
* `pr-policy` while any of them is present, and never applies or removes one.
|
|
@@ -441,6 +454,10 @@ declare const MERGE_BLOCK_CHECK = "merge-block";
|
|
|
441
454
|
declare function decideMergeBlock(pr: PullRequestFacts): CheckResult;
|
|
442
455
|
declare const mergeBlockCheck: PolicyCheck;
|
|
443
456
|
|
|
457
|
+
declare const UAT_LABEL_CHECK = "uat-label";
|
|
458
|
+
declare function decideUatLabel(pr: Pick<PullRequestFacts, 'labels'>): CheckResult;
|
|
459
|
+
declare const uatLabelCheck: PolicyCheck;
|
|
460
|
+
|
|
444
461
|
/**
|
|
445
462
|
* Which files this guard considers "a CI workflow".
|
|
446
463
|
*
|
|
@@ -578,4 +595,4 @@ declare function statusBody(evaluation: PolicyEvaluation, runUrl: string | undef
|
|
|
578
595
|
/** Post the verdict: the `pr-policy` check-run, then the matching commit status. */
|
|
579
596
|
declare function postVerdict(target: PullRequestTarget, headSha: string, evaluation: PolicyEvaluation): Promise<void>;
|
|
580
597
|
|
|
581
|
-
export { AMBIGUOUS_INDICATORS, type AmbiguousIndicator, BLOCKED_LABEL, BLOCKING_LABELS, BREAKING_CHANGE_LABEL, CHECKS, CI_APPROVAL_NEEDED_LABEL, CI_CHANGE_APPROVED_LABEL, CI_CHANGE_CHECK, CI_CHANGE_VERDICTS, CI_SENSITIVE_PACKAGES, COMMIT_TYPES, type CheckResult, type CheckRunReport, type CiChangeVerdict, type Claim, type Classification, type CommitStatus, type CommitType, DEPENDABOT_CHECK, DEPENDABOT_LOGIN, DNM_LABEL, DO_NOT_MERGE_LABEL, ESCALATION_NEEDED_LABEL, FUNCTIONAL_TYPES, type FileChange, type Finding, GITHUB_ACTIONS_BOT, HOTFIX_LABEL, type Indicator, type IndicatorClass, type IndicatorKind, LOOSENING_INDICATORS, type LooseningIndicator, MERGE_BLOCK_CHECK, POLICY_OUTCOMES, PR_POLICY_CHECK_NAME, type ParsedTitle, type PolicyCheck, type PolicyEvaluation, type PolicyOptions, type PolicyOutcome, type PullRequestAuthor, type PullRequestFacts, type PullRequestTarget, RELEASE_PLEASE_PENDING_LABEL, SIGN_OFF_REQUIREMENTS, SIGN_OFF_STATUS_CONTEXT, SIGN_OFF_STATUS_VERSIONS, type SignOffClassification, type SignOffRequirement, type SignOffStatusReading, TITLE_CHECK, WAIVER_STATES, type WaiverState, type WorkflowFileChange, applyLabelEdits, buildReport, checkRunBody, ciChangeCheck, classifyWorkflowChanges, classifyWorkflowFile, decideCiChange, decideDependabot, decideMergeBlock, decideTitle, dependabotCheck, evaluatePolicy, gatherFacts, isManifestPath, isWorkflowPath, mergeBlockCheck, openPullRequestsAtHead, parseClaims, parseFacts, parseSignOffDescription, parseSignOffStatusCreators, parseTitle, postCheckRun, postVerdict, readSignOffStatus, selectChecks, sensitiveBumps, statusBody, titleCheck };
|
|
598
|
+
export { AMBIGUOUS_INDICATORS, type AmbiguousIndicator, BLOCKED_LABEL, BLOCKING_LABELS, BREAKING_CHANGE_LABEL, CHECKS, CI_APPROVAL_NEEDED_LABEL, CI_CHANGE_APPROVED_LABEL, CI_CHANGE_CHECK, CI_CHANGE_VERDICTS, CI_SENSITIVE_PACKAGES, COMMIT_TYPES, type CheckResult, type CheckRunReport, type CiChangeVerdict, type Claim, type Classification, type CommitStatus, type CommitType, DEPENDABOT_CHECK, DEPENDABOT_LOGIN, DNM_LABEL, DO_NOT_MERGE_LABEL, ESCALATION_NEEDED_LABEL, FUNCTIONAL_TYPES, type FileChange, type Finding, GITHUB_ACTIONS_BOT, HOTFIX_LABEL, type Indicator, type IndicatorClass, type IndicatorKind, LOOSENING_INDICATORS, type LooseningIndicator, MERGE_BLOCK_CHECK, POLICY_OUTCOMES, PR_POLICY_CHECK_NAME, type ParsedTitle, type PolicyCheck, type PolicyEvaluation, type PolicyOptions, type PolicyOutcome, type PullRequestAuthor, type PullRequestFacts, type PullRequestTarget, RELEASE_PLEASE_PENDING_LABEL, SIGN_OFF_REQUIREMENTS, SIGN_OFF_STATUS_CONTEXT, SIGN_OFF_STATUS_VERSIONS, type SignOffClassification, type SignOffRequirement, type SignOffStatusReading, TITLE_CHECK, UAT_LABELS, UAT_LABEL_CHECK, WAIVER_STATES, type WaiverState, type WorkflowFileChange, applyLabelEdits, buildReport, checkRunBody, ciChangeCheck, classifyWorkflowChanges, classifyWorkflowFile, decideCiChange, decideDependabot, decideMergeBlock, decideTitle, decideUatLabel, dependabotCheck, evaluatePolicy, gatherFacts, isManifestPath, isWorkflowPath, mergeBlockCheck, openPullRequestsAtHead, parseClaims, parseFacts, parseSignOffDescription, parseSignOffStatusCreators, parseTitle, postCheckRun, postVerdict, readSignOffStatus, selectChecks, sensitiveBumps, statusBody, titleCheck, uatLabelCheck };
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
SIGN_OFF_STATUS_CONTEXT,
|
|
28
28
|
SIGN_OFF_STATUS_VERSIONS,
|
|
29
29
|
TITLE_CHECK,
|
|
30
|
+
UAT_LABELS,
|
|
31
|
+
UAT_LABEL_CHECK,
|
|
30
32
|
WAIVER_STATES,
|
|
31
33
|
applyLabelEdits,
|
|
32
34
|
buildReport,
|
|
@@ -38,6 +40,7 @@ import {
|
|
|
38
40
|
decideDependabot,
|
|
39
41
|
decideMergeBlock,
|
|
40
42
|
decideTitle,
|
|
43
|
+
decideUatLabel,
|
|
41
44
|
dependabotCheck,
|
|
42
45
|
evaluatePolicy,
|
|
43
46
|
gatherFacts,
|
|
@@ -56,8 +59,9 @@ import {
|
|
|
56
59
|
selectChecks,
|
|
57
60
|
sensitiveBumps,
|
|
58
61
|
statusBody,
|
|
59
|
-
titleCheck
|
|
60
|
-
|
|
62
|
+
titleCheck,
|
|
63
|
+
uatLabelCheck
|
|
64
|
+
} from "./chunk-UI7QG6XT.js";
|
|
61
65
|
export {
|
|
62
66
|
AMBIGUOUS_INDICATORS,
|
|
63
67
|
BLOCKED_LABEL,
|
|
@@ -87,6 +91,8 @@ export {
|
|
|
87
91
|
SIGN_OFF_STATUS_CONTEXT,
|
|
88
92
|
SIGN_OFF_STATUS_VERSIONS,
|
|
89
93
|
TITLE_CHECK,
|
|
94
|
+
UAT_LABELS,
|
|
95
|
+
UAT_LABEL_CHECK,
|
|
90
96
|
WAIVER_STATES,
|
|
91
97
|
applyLabelEdits,
|
|
92
98
|
buildReport,
|
|
@@ -98,6 +104,7 @@ export {
|
|
|
98
104
|
decideDependabot,
|
|
99
105
|
decideMergeBlock,
|
|
100
106
|
decideTitle,
|
|
107
|
+
decideUatLabel,
|
|
101
108
|
dependabotCheck,
|
|
102
109
|
evaluatePolicy,
|
|
103
110
|
gatherFacts,
|
|
@@ -116,5 +123,6 @@ export {
|
|
|
116
123
|
selectChecks,
|
|
117
124
|
sensitiveBumps,
|
|
118
125
|
statusBody,
|
|
119
|
-
titleCheck
|
|
126
|
+
titleCheck,
|
|
127
|
+
uatLabelCheck
|
|
120
128
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmartz/pr-policy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Read-only PR content classifiers — CI-change classification, title-type rules, and more — reported as one blocking pr-policy check-run. Distributed as a pinned Action kept current by Dependabot.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pr-policy",
|