chore: drop upstream gsd issue and pr governance
Some checks failed
Tests / lint-tests (push) Has been cancelled
Tests / plugin-validate (push) Has been cancelled
Tests / test (ubuntu-latest, 24, shard 1/3) (push) Has been cancelled
Tests / test (ubuntu-latest, 24, shard 2/3) (push) Has been cancelled
Tests / test (ubuntu-latest, 24, shard 3/3) (push) Has been cancelled
Tests / test (ubuntu-latest, 24) (push) Has been cancelled
Tests / test (inert CI) (push) Has been cancelled
Tests / conformance test (macos-latest, 24) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 1/3) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 2/3) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 3/3) (push) Has been cancelled
Tests / Coverage gate (merged shards) (push) Has been cancelled
Tests / QA loop walk (smell ratchet) (push) Has been cancelled
Tests / Required tests (push) Has been cancelled
Tests / Publish emitted-baseline artifact (push) Has been cancelled
Tests / PR mergeability (push) Has been cancelled
Tests / Base branch health (push) Has been cancelled
Tests / Detect test scope (push) Has been cancelled
Some checks failed
Tests / lint-tests (push) Has been cancelled
Tests / plugin-validate (push) Has been cancelled
Tests / test (ubuntu-latest, 24, shard 1/3) (push) Has been cancelled
Tests / test (ubuntu-latest, 24, shard 2/3) (push) Has been cancelled
Tests / test (ubuntu-latest, 24, shard 3/3) (push) Has been cancelled
Tests / test (ubuntu-latest, 24) (push) Has been cancelled
Tests / test (inert CI) (push) Has been cancelled
Tests / conformance test (macos-latest, 24) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 1/3) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 2/3) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 3/3) (push) Has been cancelled
Tests / Coverage gate (merged shards) (push) Has been cancelled
Tests / QA loop walk (smell ratchet) (push) Has been cancelled
Tests / Required tests (push) Has been cancelled
Tests / Publish emitted-baseline artifact (push) Has been cancelled
Tests / PR mergeability (push) Has been cancelled
Tests / Base branch health (push) Has been cancelled
Tests / Detect test scope (push) Has been cancelled
MSD does not use an issue tracker, and the inherited GSD community gates auto-closed PR #1 for lacking an issue-numbered title. Remove them: - workflows: require-issue-link, pr-title-validator, auto-close-unsolicited-prs, pr-template-format, close-draft-prs(-sweep), auto-label-issues, auto-branch, duplicate-check, duplicate-sweep, remove-duplicate-label - GSD PR and issue templates, plus the scripts only they used (require-issue-link-policy, pr-template-policy, pr-changed-files) and their tests - workflow lists in ci-test-scope, ci-pr-mergeability, workflow-maintainer-skip, lint-pr-check-project-dir, the docs-guard baseline and the conformance tiers - CONTRIBUTING: PR-against-next flow with no issue or template; PR titles are conventional without an issue ref; ADR/PRD files use the PR number - CONTEXT.md: drop the PR-template predicates (k328, templates-mandatory)
This commit is contained in:
@@ -7,9 +7,6 @@ const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
const { evaluateIssueLink, ISSUE_LINK_REASON } = require('../scripts/require-issue-link-policy.cjs');
|
||||
|
||||
const MAINTAINER_SKIP_EXPR = 'contains(fromJSON(\'["OWNER","MEMBER","COLLABORATOR"]\'), github.event.pull_request.author_association) == false';
|
||||
|
||||
@@ -53,42 +50,20 @@ function assertMaintainerSkip(source) {
|
||||
}
|
||||
|
||||
describe('PR policy workflow maintainer carve-outs', () => {
|
||||
test('draft PR auto-close does not run for maintainer-authored PRs', () => {
|
||||
const workflow = readWorkflow('.github/workflows/close-draft-prs.yml');
|
||||
|
||||
assert.match(workflow, /github\.event\.pull_request\.draft == true/);
|
||||
assertMaintainerSkip(workflow);
|
||||
});
|
||||
|
||||
test('draft PR auto-close triggers on pull_request_target so fork PRs cannot bypass it', () => {
|
||||
const workflow = readWorkflow('.github/workflows/close-draft-prs.yml');
|
||||
|
||||
// A bare `pull_request` trigger hands fork PRs (how first-time/external
|
||||
// contributors contribute) a read-only GITHUB_TOKEN, so the close/comment
|
||||
// API calls 403 and the draft PR survives — bypassing the auto-close.
|
||||
// `pull_request_target` runs in the base-repo context with a write-capable
|
||||
// token. Guard against a regression back to the bypassable trigger.
|
||||
assert.match(workflow, /^\s*pull_request_target:/m);
|
||||
assert.doesNotMatch(workflow, /^\s*pull_request:\s*$/m);
|
||||
});
|
||||
|
||||
test('PR target validator does not run for maintainer-authored PRs', () => {
|
||||
const workflow = readWorkflow('.github/workflows/pr-target-validator.yml');
|
||||
|
||||
assertMaintainerSkip(workflow);
|
||||
});
|
||||
|
||||
// #2331: same defect class as the close-draft-prs.yml trigger lock above,
|
||||
// swept across the three PR-policy workflows it had never covered. Each one
|
||||
// #2331: a PR-policy workflow that comments and THEN emits its verdict. Each one
|
||||
// comments on the PR and THEN emits its verdict; on a bare `pull_request`
|
||||
// trigger a fork PR's read-only GITHUB_TOKEN 403s the comment call, the
|
||||
// unhandled rejection kills the github-script step, and the verdict
|
||||
// (core.setFailed) never runs — the contributor gets an API stack trace
|
||||
// instead of the instructions the comment exists to deliver.
|
||||
for (const { file, name, scope, otherScope } of [
|
||||
{ file: '.github/workflows/pr-title-validator.yml', name: 'PR title validator', scope: 'pull-requests', otherScope: 'issues' },
|
||||
{ file: '.github/workflows/pr-target-validator.yml', name: 'PR target validator', scope: 'pull-requests', otherScope: 'issues' },
|
||||
{ file: '.github/workflows/require-issue-link.yml', name: 'Require issue link', scope: 'issues', otherScope: 'pull-requests' },
|
||||
]) {
|
||||
test(`${name} triggers on pull_request_target so fork PRs get the verdict, not a 403`, () => {
|
||||
const workflow = readWorkflow(file);
|
||||
@@ -108,9 +83,9 @@ describe('PR policy workflow maintainer carve-outs', () => {
|
||||
//
|
||||
// Each file needs only ONE: GitHub accepts either `issues: write` or
|
||||
// `pull-requests: write` for issues.createComment when the target is a
|
||||
// PR. Verified from this repo's history, not the docs — pr-title-validator
|
||||
// has posted on `pull-requests: write` alone, require-issue-link on
|
||||
// `issues: write` alone. The 403 was the fork downgrade, not the scope.
|
||||
// PR. Verified from this repo's history, not the docs — pr-target-validator
|
||||
// has posted on `pull-requests: write` alone. The 403 was the fork
|
||||
// downgrade, not the scope.
|
||||
//
|
||||
// The negative half is the point of this test: a pull_request_target
|
||||
// workflow must not carry privilege it never exercises, so adding the
|
||||
@@ -149,13 +124,12 @@ describe('PR policy workflow maintainer carve-outs', () => {
|
||||
});
|
||||
}
|
||||
|
||||
// #2331: these two workflows echo attacker-controlled text (PR title / fork
|
||||
// branch name) into a bot-authored comment posted with a write token. Raw
|
||||
// #2331: this workflow echoes attacker-controlled text (the fork branch
|
||||
// name) into a bot-authored comment posted with a write token. Raw
|
||||
// interpolation into an inline-code span lets a single backtick close the span
|
||||
// so the remainder renders as live Markdown — on a PR title (no charset limit)
|
||||
// that is enough to autolink an arbitrary URL from github-actions[bot].
|
||||
for (const { file, name, varName } of [
|
||||
{ file: '.github/workflows/pr-title-validator.yml', name: 'PR title validator', varName: 'titleForMarkdown' },
|
||||
{ file: '.github/workflows/pr-target-validator.yml', name: 'PR target validator', varName: 'headForMarkdown' },
|
||||
]) {
|
||||
test(`${name} strips backticks before echoing untrusted text into the comment`, () => {
|
||||
@@ -200,8 +174,8 @@ describe('PR policy workflow maintainer carve-outs', () => {
|
||||
// The exact trap that made the first cut of the ordering test fail against
|
||||
// correct code: these workflows name `core.setFailed` in their own comments,
|
||||
// before the call, so a raw-source indexOf compares the comment.
|
||||
const raw = readWorkflow('.github/workflows/pr-title-validator.yml');
|
||||
const code = readWorkflowCode('.github/workflows/pr-title-validator.yml');
|
||||
const raw = readWorkflow('.github/workflows/pr-target-validator.yml');
|
||||
const code = readWorkflowCode('.github/workflows/pr-target-validator.yml');
|
||||
|
||||
assert.ok(
|
||||
raw.indexOf('core.setFailed') < raw.indexOf('Could not post'),
|
||||
@@ -230,100 +204,6 @@ describe('PR policy workflow maintainer carve-outs', () => {
|
||||
assert.equal(sanitize('``a``'), "''a''");
|
||||
});
|
||||
|
||||
test('draft PR sweep enforces the same policy as the event-driven close', () => {
|
||||
const workflow = readWorkflow('.github/workflows/close-draft-prs-sweep.yml');
|
||||
|
||||
// Timer-driven in base-repo context, plus a manual dispatch for testing.
|
||||
// It must NOT be a fork-triggered event (no pull_request / pull_request_target trigger).
|
||||
assert.match(workflow, /schedule:/);
|
||||
assert.match(workflow, /cron:\s*'0 \*\/6 \* \* \*'/);
|
||||
assert.match(workflow, /workflow_dispatch:/);
|
||||
assert.doesNotMatch(workflow, /^\s*pull_request(_target)?:/m);
|
||||
|
||||
// Write-capable token (needed to close PRs from base context). Tolerant of
|
||||
// intervening blank lines or additional permission keys.
|
||||
assert.match(workflow, /permissions:\s+pull-requests:\s*write/);
|
||||
|
||||
// Identical maintainer carve-out to close-draft-prs.yml — a Set membership
|
||||
// test over author_association, negated (no github.event.pull_request in a
|
||||
// scheduled run).
|
||||
assert.match(workflow, /new Set\(\['OWNER', 'MEMBER', 'COLLABORATOR'\]\)/);
|
||||
assert.match(workflow, /!MAINTAINER_ASSOCIATIONS\.has\([^)]*\.author_association\)/);
|
||||
|
||||
// Paginates over open PRs and filters to drafts.
|
||||
assert.match(workflow, /github\.paginate\(github\.rest\.pulls\.list/);
|
||||
assert.match(workflow, /state:\s*'open'/);
|
||||
assert.match(workflow, /pr\.draft === true/);
|
||||
|
||||
// Same user-facing policy message as close-draft-prs.yml (locks the core
|
||||
// content so the sweep cannot silently drift to a weaker message).
|
||||
assert.match(workflow, /## Draft PRs are not accepted/);
|
||||
assert.match(workflow, /npm run test:coverage/);
|
||||
assert.match(workflow, /CONTRIBUTING\.md#pull-request-guidelines/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Require Issue Link back-merge automation carve-out', () => {
|
||||
// #3211 moved the whole verdict — including the #1389 backmerge carve-out —
|
||||
// out of the YAML `if:` and into scripts/require-issue-link-policy.cjs
|
||||
// (evaluateIssueLink), renaming the step from `check`/`found` to
|
||||
// `policy`/`ok`. The old assertions here measured the carve-out's PREVIOUS
|
||||
// location (raw `startsWith(github.head_ref, ...)` / `head.repo.full_name`
|
||||
// text inside the workflow's `if:`) and went stale once that logic
|
||||
// relocated — the property they guarded still holds, just not at that
|
||||
// text. This test locks the property at its new home: (a)+(b) assert the
|
||||
// workflow now delegates to the policy module at the correct step-level
|
||||
// `if:`, (c) asserts the carve-out itself BEHAVIORALLY against the real
|
||||
// module, and (d) keeps the bootstrap fallback's legacy grep locked so the
|
||||
// introducing-PR path (before the module exists on the base branch) is
|
||||
// never silently open.
|
||||
test('the backmerge carve-out survives the move into the policy module', () => {
|
||||
const workflow = readWorkflow('.github/workflows/require-issue-link.yml');
|
||||
|
||||
// (a) The failing step's `if:` is keyed on the policy output and is
|
||||
// STEP-level, not job-level. A job-level `if:` would make the required
|
||||
// "Issue link required" check report `skipped` instead of `success` on
|
||||
// an exempt PR, which blocks branch protection (#1389).
|
||||
assert.match(workflow, /if: steps\.policy\.outputs\.ok != 'true'/);
|
||||
|
||||
const doc = yaml.load(workflow);
|
||||
assert.equal(
|
||||
doc.jobs['check-issue-link'].if,
|
||||
undefined,
|
||||
'job-level `if:` would report "skipped" on an exempt PR and block branch protection (#1389)'
|
||||
);
|
||||
|
||||
// (b) The workflow delegates the verdict to the policy module.
|
||||
assert.match(workflow, /node scripts\/require-issue-link-policy\.cjs/);
|
||||
|
||||
// (c) The carve-out itself still holds — asserted BEHAVIORALLY against
|
||||
// the real module rather than by grepping YAML, since the verdict no
|
||||
// longer lives in the YAML text at all.
|
||||
const backmergeArgs = {
|
||||
prBody: 'Automated backmerge.',
|
||||
headRef: 'chore/backmerge-main-to-next-20260101',
|
||||
changedFiles: ['src/a.cts'],
|
||||
changedFilesTotal: 1,
|
||||
};
|
||||
assert.equal(
|
||||
evaluateIssueLink({ ...backmergeArgs, sameRepo: true }).reason,
|
||||
ISSUE_LINK_REASON.OK_BACKMERGE_EXEMPT
|
||||
);
|
||||
// #1389 anti-forgery: a fork must not be able to forge the exemption by
|
||||
// branch name alone — dropping the `sameRepo` conjunct would let a fork
|
||||
// PR name its branch `chore/backmerge-main-to-next-*` and bypass the
|
||||
// issue-link requirement entirely.
|
||||
assert.equal(
|
||||
evaluateIssueLink({ ...backmergeArgs, sameRepo: false }).reason,
|
||||
ISSUE_LINK_REASON.FAIL_NO_ISSUE_REFERENCE
|
||||
);
|
||||
|
||||
// (d) The bootstrap fallback (used only on the PR that first introduces
|
||||
// the policy module, before it exists on the base branch) still carries
|
||||
// the legacy closing-keyword grep, so the gate is never silently open
|
||||
// during the changeover.
|
||||
assert.match(workflow, /\(closes\|fixes\|resolves\)/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Auto-backmerge needs_review version-manifest carve-out (#1404)', () => {
|
||||
|
||||
Reference in New Issue
Block a user