Skip to content

Commit 7584bf7

Browse files
committed
feat(ci): enforce PR ancestry and description in target gate
1 parent 90d4962 commit 7584bf7

2 files changed

Lines changed: 216 additions & 58 deletions

File tree

.github/scripts/enforce-pr-target.test.cjs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe("enforce-pr-target workflow", () => {
1313
assert.match(workflow, /pull_request_target:/);
1414
assert.doesNotMatch(
1515
workflow,
16-
/actions\/checkout@/,
17-
"wrong-branch enforcer must not check out untrusted PR code",
16+
/ref:\s*\$\{\{\s*github\.event\.pull_request\.head/,
17+
"enforcer must not check out untrusted PR head code",
1818
);
1919
});
2020

@@ -43,4 +43,21 @@ describe("enforce-pr-target workflow", () => {
4343
assert.match(workflow, /readyConversionFailed/);
4444
assert.match(workflow, /Could not mark pull request ready for review/);
4545
});
46+
47+
it("listens for synchronize so rebase can clear ancestry failures", () => {
48+
assert.match(workflow, /synchronize/);
49+
});
50+
51+
it("checks out trusted default-branch scripts only (never PR head)", () => {
52+
assert.match(workflow, /actions\/checkout@[0-9a-f]{40}/);
53+
assert.match(workflow, /ref:\s*\$\{\{\s*github\.event\.repository\.default_branch\s*\}\}/);
54+
assert.match(workflow, /sparse-checkout:\s*\.github\/scripts/);
55+
assert.match(workflow, /persist-credentials:\s*false/);
56+
assert.doesNotMatch(workflow, /ref:\s*\$\{\{\s*github\.event\.pull_request\.head/);
57+
});
58+
59+
it("loads pr-quality via require from the checked-out scripts", () => {
60+
assert.match(workflow, /pr-quality\.cjs/);
61+
assert.match(workflow, /collectPrQualityFailures/);
62+
});
4663
});

0 commit comments

Comments
 (0)