@rmartz/pr-policy 1.5.0 → 1.5.1

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.
@@ -8,7 +8,7 @@ import {
8
8
  postVerdict,
9
9
  resolveRepoTarget,
10
10
  selectChecks
11
- } from "../chunk-RHHCFDMG.js";
11
+ } from "../chunk-KWZP3U4O.js";
12
12
 
13
13
  // src/bin/pr-policy.ts
14
14
  import { readFile } from "fs/promises";
@@ -117,20 +117,21 @@ function untrustedCreator(creator, trustedBots) {
117
117
  const vetted = vet(creator);
118
118
  return typeof vetted === "string" ? vetted : void 0;
119
119
  }
120
- function untrustedReason(status, trustedBots) {
121
- if (status.state !== "success") return `its state is \`${status.state}\`, not \`success\``;
122
- if (status.creator === void 0) return "GitHub names no account that posted it";
123
- return untrustedCreator(status.creator, trustedBots);
124
- }
125
120
  function readSignOffStatus(pr, trustedBots = []) {
126
121
  const status = pr.signOffStatus;
127
122
  if (status === void 0) return { kind: "absent" };
128
- const untrusted = untrustedReason(status, trustedBots);
129
- if (untrusted !== void 0) return { kind: "rejected", reason: untrusted };
123
+ const untrusted = status.creator === void 0 ? "GitHub names no account that posted it" : untrustedCreator(status.creator, trustedBots);
124
+ if (untrusted !== void 0) return { kind: "ignored", reason: untrusted };
125
+ if (status.state !== "success") {
126
+ return { kind: "rejected", reason: `its state is \`${status.state}\`, not \`success\`` };
127
+ }
130
128
  const parsed = parseSignOffDescription(status.description);
131
129
  if (typeof parsed === "string") return { kind: "rejected", reason: parsed };
132
130
  return { kind: "valid", classification: parsed, postedBy: status.creator?.login ?? "" };
133
131
  }
132
+ function ignoredStatusMessage(reason) {
133
+ return `Ignored the \`${SIGN_OFF_STATUS_CONTEXT}\` status on this head, because ${reason}. This check classified the PR itself instead.`;
134
+ }
134
135
  function rejectedStatusMessage(reason) {
135
136
  return `Waiting on pr-lifecycle: its \`${SIGN_OFF_STATUS_CONTEXT}\` status on this head can't be used, because ${reason}. pr-lifecycle posts a fresh one on its next run.`;
136
137
  }
@@ -658,6 +659,15 @@ function decideCiChange(classification, pr, trustedBots = []) {
658
659
  switch (reading.kind) {
659
660
  case "valid":
660
661
  return decideFromStatus(classification, pr, reading.classification);
662
+ case "ignored": {
663
+ const result = decideWithoutStatus(classification, pr);
664
+ const note = {
665
+ check: CI_CHANGE_CHECK,
666
+ message: ignoredStatusMessage(reading.reason),
667
+ effect: "info"
668
+ };
669
+ return { ...result, findings: [...result.findings, note] };
670
+ }
661
671
  case "absent":
662
672
  case "rejected":
663
673
  return decideWithoutStatus(classification, pr);
@@ -1633,6 +1643,10 @@ function decideUat(pr, trustedBots = []) {
1633
1643
  switch (reading.kind) {
1634
1644
  case "absent":
1635
1645
  return { findings: decideWithoutStatus2(pr) };
1646
+ case "ignored":
1647
+ return {
1648
+ findings: [...decideWithoutStatus2(pr), info2(ignoredStatusMessage(reading.reason))]
1649
+ };
1636
1650
  case "rejected":
1637
1651
  return { findings: [hold(rejectedStatusMessage(reading.reason))] };
1638
1652
  case "valid":
package/dist/index.d.ts CHANGED
@@ -236,10 +236,12 @@ declare const RELEASE_PLEASE_PENDING_LABEL = "autorelease: pending";
236
236
  * GitHub ties a status to its SHA, so a push can never leave the gate reading a
237
237
  * classification of an older head. The gate never reads pr-lifecycle's labels.
238
238
  *
239
- * Everything here fails closed: an unknown version, an unknown key or value, a
240
- * status that isn't `success`, or a creator who couldn't sign off a PR is
241
- * `rejected`, and the checks hold. Only a missing status is `absent`, which
242
- * keeps the checks on their own classification until the repo cuts over.
239
+ * A status from a creator the gate doesn't trust is `ignored`: the checks
240
+ * classify the PR themselves, exactly as with no status, so it can't loosen
241
+ * anything. A trusted creator's status that the gate can't use (an unknown
242
+ * version, an unknown key or value, a state other than `success`) is
243
+ * `rejected`, and the checks hold. A missing status is `absent`, which keeps
244
+ * the checks on their own classification until the repo cuts over.
243
245
  */
244
246
 
245
247
  /** The description format versions this gate understands. */
@@ -260,8 +262,20 @@ type SignOffClassification = {
260
262
  loosening: boolean;
261
263
  waiver: WaiverState;
262
264
  };
265
+ /**
266
+ * - `absent`: no status on the head.
267
+ * - `ignored`: a status from a creator the gate doesn't trust. It is treated as
268
+ * no status, so the checks fall back to their own classification
269
+ * (rmartz/pr-policy#101); `reason` says who posted it and how to trust them.
270
+ * - `rejected`: a status from a trusted creator that the gate can't use (a
271
+ * state other than `success`, or an unknown format). The checks hold.
272
+ * - `valid`: a trusted, well-formed status.
273
+ */
263
274
  type SignOffStatusReading = {
264
275
  kind: 'absent';
276
+ } | {
277
+ kind: 'ignored';
278
+ reason: string;
265
279
  } | {
266
280
  kind: 'rejected';
267
281
  reason: string;
@@ -294,6 +308,13 @@ declare function parseSignOffStatusCreators(entries: readonly string[]): string[
294
308
  * Read pr-lifecycle's sign-off status on the head, judging its creator and
295
309
  * format. The creator must be a `User` who could merge, or a Bot named in
296
310
  * `trustedBots` (validated by `parseSignOffStatusCreators`).
311
+ *
312
+ * An untrusted creator is `ignored`, not held on. While the checks keep their
313
+ * own classification, ignoring a status can't loosen anything: the PR is
314
+ * judged as if pr-lifecycle hadn't posted. Holding instead would lock the repo
315
+ * whenever pr-lifecycle's identity and the caller's trust list drift apart,
316
+ * including the PR that fixes the list (rmartz/pr-policy#101). Once
317
+ * rmartz/pr-policy#85 removes the fallback, this has to hold again.
297
318
  */
298
319
  declare function readSignOffStatus(pr: Pick<PullRequestFacts, 'signOffStatus'>, trustedBots?: readonly string[]): SignOffStatusReading;
299
320
 
@@ -356,10 +377,11 @@ type CiFacts = Pick<PullRequestFacts, 'labels' | 'signOffs' | 'signOffStatus'>;
356
377
  * Decide the findings and label edits for one classified PR. With a valid
357
378
  * `pr-lifecycle/sign-off` status, that status says whether a CI sign-off is
358
379
  * needed, and this check edits no label: pr-lifecycle writes `CI approval
359
- * needed` then. Without one, or with one the gate can't trust (the `uat` check
360
- * holds on that), this check classifies the workflow diff itself, as before
361
- * the cutover. `trustedBots` are the GitHub Apps the caller trusts to post the
362
- * status, besides a trusted person.
380
+ * needed` then. Without one, with one from a creator the gate doesn't trust,
381
+ * or with a trusted one it can't use (the `uat` check holds on that), this
382
+ * check classifies the workflow diff itself, as before the cutover.
383
+ * `trustedBots` are the GitHub Apps the caller trusts to post the status,
384
+ * besides a trusted person.
363
385
  */
364
386
  declare function decideCiChange(classification: Classification, pr: CiFacts, trustedBots?: readonly string[]): CheckResult;
365
387
  /** The CI-change check trusting only people to post the sign-off status. */
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  sensitiveBumps,
58
58
  statusBody,
59
59
  titleCheck
60
- } from "./chunk-RHHCFDMG.js";
60
+ } from "./chunk-KWZP3U4O.js";
61
61
  export {
62
62
  AMBIGUOUS_INDICATORS,
63
63
  BLOCKED_LABEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmartz/pr-policy",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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",