@rmartz/pr-policy 0.10.1 → 0.12.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/dist/bin/pr-policy.js
CHANGED
|
@@ -5,11 +5,13 @@ var CI_CHANGE_APPROVED_LABEL = "CI change approved";
|
|
|
5
5
|
var UAT_PASSED_LABEL = "UAT passed";
|
|
6
6
|
var LEGACY_UAT_PASSED_LABEL = "tested";
|
|
7
7
|
var NO_UAT_NEEDED_LABEL = "no UAT needed";
|
|
8
|
+
var CONTAINED_BREAK_LABEL = "contained break";
|
|
8
9
|
var SIGN_OFF_LABELS = [
|
|
9
10
|
CI_CHANGE_APPROVED_LABEL,
|
|
10
11
|
UAT_PASSED_LABEL,
|
|
11
12
|
LEGACY_UAT_PASSED_LABEL,
|
|
12
|
-
NO_UAT_NEEDED_LABEL
|
|
13
|
+
NO_UAT_NEEDED_LABEL,
|
|
14
|
+
CONTAINED_BREAK_LABEL
|
|
13
15
|
];
|
|
14
16
|
var DO_NOT_MERGE_LABEL = "do not merge";
|
|
15
17
|
var DNM_LABEL = "dnm";
|
|
@@ -708,15 +710,15 @@ function pipVersions(text) {
|
|
|
708
710
|
}
|
|
709
711
|
return versions;
|
|
710
712
|
}
|
|
711
|
-
function
|
|
713
|
+
function manifestVersions(path, text) {
|
|
712
714
|
return basename(path) === "package.json" ? npmVersions(text) : pipVersions(text);
|
|
713
715
|
}
|
|
714
716
|
function sensitiveBumps(changes) {
|
|
715
717
|
const bumped = /* @__PURE__ */ new Set();
|
|
716
718
|
for (const change of changes) {
|
|
717
719
|
if (change.baseText === void 0 || change.headText === void 0) continue;
|
|
718
|
-
const before =
|
|
719
|
-
const after =
|
|
720
|
+
const before = manifestVersions(change.path, change.baseText);
|
|
721
|
+
const after = manifestVersions(change.path, change.headText);
|
|
720
722
|
if (before === null || after === null) continue;
|
|
721
723
|
for (const name of CI_SENSITIVE_PACKAGES) {
|
|
722
724
|
const was = before.get(name);
|
|
@@ -1156,6 +1158,34 @@ function isReleasePleaseTitle(title) {
|
|
|
1156
1158
|
return RELEASE_PLEASE_TITLE.test(title);
|
|
1157
1159
|
}
|
|
1158
1160
|
|
|
1161
|
+
// src/checks/title/major-bump.ts
|
|
1162
|
+
var LEADING_VERSION = /^[\^~=<>!v\s]*(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
1163
|
+
function parseVersion(spec) {
|
|
1164
|
+
const match = LEADING_VERSION.exec(spec);
|
|
1165
|
+
if (match === null) return void 0;
|
|
1166
|
+
const [, major = "0", minor = "0", patch = "0"] = match;
|
|
1167
|
+
return { major: Number(major), text: `${major}.${minor}.${patch}` };
|
|
1168
|
+
}
|
|
1169
|
+
function majorBumps(changes) {
|
|
1170
|
+
const bumps = /* @__PURE__ */ new Set();
|
|
1171
|
+
for (const change of changes) {
|
|
1172
|
+
if (change.baseText === void 0 || change.headText === void 0) continue;
|
|
1173
|
+
const before = manifestVersions(change.path, change.baseText);
|
|
1174
|
+
const after = manifestVersions(change.path, change.headText);
|
|
1175
|
+
if (before === null || after === null) continue;
|
|
1176
|
+
for (const [name, spec] of after) {
|
|
1177
|
+
const was = before.get(name);
|
|
1178
|
+
if (was === void 0) continue;
|
|
1179
|
+
const from = parseVersion(was);
|
|
1180
|
+
const to = parseVersion(spec);
|
|
1181
|
+
if (from !== void 0 && to !== void 0 && to.major > from.major) {
|
|
1182
|
+
bumps.add(`${name} ${from.text} \u2192 ${to.text}`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return [...bumps];
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1159
1189
|
// src/checks/title/type-paths.ts
|
|
1160
1190
|
function isMarkdownPath(path) {
|
|
1161
1191
|
return path.toLowerCase().endsWith(".md");
|
|
@@ -1208,6 +1238,7 @@ function decideTitle(pr) {
|
|
|
1208
1238
|
}
|
|
1209
1239
|
const findings = [];
|
|
1210
1240
|
const functional = isFunctionalType(title.type);
|
|
1241
|
+
const breakingTitle = `${title.type}${title.scope ? `(${title.scope})` : ""}!: ${title.subject}`;
|
|
1211
1242
|
const breakingLabel = labels.has(BREAKING_CHANGE_LABEL);
|
|
1212
1243
|
const breakingIntent = breakingLabel || labels.has(HOTFIX_LABEL);
|
|
1213
1244
|
if (!functional) {
|
|
@@ -1228,16 +1259,43 @@ function decideTitle(pr) {
|
|
|
1228
1259
|
} else if (breakingIntent && !title.breaking) {
|
|
1229
1260
|
findings.push(
|
|
1230
1261
|
block2(
|
|
1231
|
-
`The PR is labelled breaking but the title has no \`!\`, so the release would miss the major. Retitle to \`${
|
|
1262
|
+
`The PR is labelled breaking but the title has no \`!\`, so the release would miss the major. Retitle to \`${breakingTitle}\`.`
|
|
1232
1263
|
)
|
|
1233
1264
|
);
|
|
1234
1265
|
} else if (!breakingIntent && title.breaking) {
|
|
1235
1266
|
findings.push(
|
|
1236
1267
|
block2(
|
|
1237
|
-
`The title marks a breaking change but the PR lacks the \`${BREAKING_CHANGE_LABEL}\` label
|
|
1268
|
+
`The title marks a breaking change but the PR lacks the \`${BREAKING_CHANGE_LABEL}\` label; the two must agree. Add the label, or drop the \`!\`.`
|
|
1269
|
+
)
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
const containedBreakLabel = labels.has(CONTAINED_BREAK_LABEL);
|
|
1273
|
+
if (containedBreakLabel && (breakingIntent || title.breaking)) {
|
|
1274
|
+
findings.push(
|
|
1275
|
+
block2(
|
|
1276
|
+
`\`${CONTAINED_BREAK_LABEL}\` says the break doesn't reach consumers, but the PR is also marked breaking. Remove \`${CONTAINED_BREAK_LABEL}\`, or drop the \`!\` and the breaking label.`
|
|
1238
1277
|
)
|
|
1239
1278
|
);
|
|
1240
1279
|
}
|
|
1280
|
+
const majors = majorBumps(pr.manifestChanges);
|
|
1281
|
+
if (functional && !breakingIntent && !title.breaking && majors.length > 0) {
|
|
1282
|
+
const bumped = majors.map((bump) => `\`${bump}\``).join(", ");
|
|
1283
|
+
const waiver = signOffState(pr, [CONTAINED_BREAK_LABEL]);
|
|
1284
|
+
if (waiver.status === "trusted") {
|
|
1285
|
+
findings.push({
|
|
1286
|
+
check: TITLE_CHECK,
|
|
1287
|
+
effect: "info",
|
|
1288
|
+
message: `\`${waiver.appliedBy.login}\` waived the dependency major bump (${bumped}) with \`${CONTAINED_BREAK_LABEL}\`, so it releases without \`!\`.`
|
|
1289
|
+
});
|
|
1290
|
+
} else {
|
|
1291
|
+
const untrusted = waiver.status === "untrusted" ? ` The \`${CONTAINED_BREAK_LABEL}\` label doesn't count: ${waiver.reason}.` : "";
|
|
1292
|
+
findings.push(
|
|
1293
|
+
block2(
|
|
1294
|
+
`This PR bumps a dependency's major version (${bumped}), so it is a breaking change. Retitle to \`${breakingTitle}\` and add the \`${BREAKING_CHANGE_LABEL}\` label. If the bump is invisible to this package's consumers, someone who can merge may add \`${CONTAINED_BREAK_LABEL}\` instead.${untrusted}`
|
|
1295
|
+
)
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1241
1299
|
const pathViolation = typePathViolation(title.type, pr.changedFiles);
|
|
1242
1300
|
if (pathViolation !== void 0) findings.push(block2(pathViolation));
|
|
1243
1301
|
const mayRetitle = !functional && title.type !== "ci";
|
package/dist/index.d.ts
CHANGED
|
@@ -337,9 +337,9 @@ declare const ESCALATION_NEEDED_LABEL = "escalation needed";
|
|
|
337
337
|
declare const BLOCKING_LABELS: readonly ["do not merge", "dnm", "blocked", "escalation needed"];
|
|
338
338
|
/**
|
|
339
339
|
* Labels the title check reads and never writes. They belong to the review and
|
|
340
|
-
* release flow: `breaking change`
|
|
341
|
-
* `hotfix` implies one
|
|
342
|
-
* `autorelease: pending`.
|
|
340
|
+
* release flow: `breaking change` must agree with the title's `!`, which is what
|
|
341
|
+
* the release and merge-safety read; `hotfix` implies one; and release-please
|
|
342
|
+
* marks its release PRs with `autorelease: pending`.
|
|
343
343
|
*/
|
|
344
344
|
declare const BREAKING_CHANGE_LABEL = "breaking change";
|
|
345
345
|
declare const HOTFIX_LABEL = "hotfix";
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmartz/pr-policy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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",
|