π The fast, Pythonic way to build MCP servers and clients.
Close external PRs until their author is assigned again (#6227)
nate nowackc1a3f96e4827
diff --git a/.github/scripts/test-issue-link.mjs b/.github/scripts/test-issue-link.mjsindex 889543449..9a33dce71 100644--- a/.github/scripts/test-issue-link.mjs+++ b/.github/scripts/test-issue-link.mjs@@ -115,14 +115,17 @@ async function run(job, options = {}) {}const check = "check-issue-link";const assign = "reopen-on-assignment";-test("linked PR waits for assignment without closing", async () => {+test("linked but unassigned PR closes until assignment", async () => {const result = await run(check);assert.equal(result.failures.length, 1);- assert(!result.calls.some((c) => c.name === "updatePR"));+ assert.equal(+ result.calls.find((c) => c.name === "updatePR").args.state,+ "closed",+ );assert(result.calls.find((c) => c.name === "createComment")- .args.body.includes("awaiting maintainer assignment"),+ .args.body.includes("reopen automatically"),);});@@ -175,16 +178,13 @@ test("assignment does not change PRs for another issue", async () => {const botClosure = { event: "closed", actor: { login: "github-actions[bot]" } };-test("adding a link reopens a gate-closed PR but keeps assignment required", async () => {+test("adding a link to a gate-closed PR keeps it closed until assignment", async () => {const result = await run(check, {state: "closed",gated: true,events: [botClosure],});- assert.equal(- result.calls.find((c) => c.name === "updatePR")?.args.state,- "open",- );+ assert(!result.calls.some((c) => c.name === "updatePR"));assert.equal(result.failures.length, 1);assert(!result.calls.some((c) => c.name === "removeLabel"));});diff --git a/.github/workflows/require-issue-link.yml b/.github/workflows/require-issue-link.ymlindex 6e30f428d..8c7c837bc 100644--- a/.github/workflows/require-issue-link.yml+++ b/.github/workflows/require-issue-link.yml@@ -3,9 +3,9 @@# unless the referenced issue is labeled "prs welcome", which waives the# assignment requirement for everyone (the link itself is still required,# since that's how the check finds the issue to read the label from).-# Missing requirements fail the check and receive a "missing-issue-link"-# label and explanatory comment. Only PRs without a valid issue link are-# closed; linked PRs stay open while maintainers decide on assignment.+# Otherwise the PR is labeled "missing-issue-link", commented on, and+# closed. CONTRIBUTING.md requires external contributors to be assigned to+# an issue before opening a PR; this enforces that.## Adapted from langchain-ai/langchain's require_issue_link.yml. Differences:# - Self-contained: it does NOT depend on a separate labeler workflow@@ -302,8 +302,10 @@ jobs:}// The author must be assigned to at least one linked issue.- // Linked PRs remain open while maintainers decide on assignment;- // the failing check keeps them gated until that decision.+ // CONTRIBUTING.md requires external contributors to be assigned+ // before opening a PR (so maintainers can deconflict / steer+ // approach first). The issue stays open as the report, and+ // assignment reopens the PR automatically.//// Exception: an issue labeled OPEN_LABEL waives that requirement// for everyone. It's how maintainers advertise "the reporter@@ -372,7 +374,7 @@ jobs:console.log('Linked and assigned β clearing any prior enforcement');await clearEnforcement();- // ββ Explain missing requirements and fail ββββββββββββββββββββββββββββ+ // ββ Label, comment, close, and fail ββββββββββββββββββββββββββββ// `kind`: 'no-link' (no valid issue reference) or 'not-assigned'// (referenced an issue, but the author isn't assigned to it).async function enforceFailure(kind) {@@ -384,20 +386,20 @@ jobs:"2. Add `Fixes #<issue>`, `Closes #<issue>`, or `Resolves #<issue>` to **this** PR's description β edit it in place, don't open a new PR.",]: [- "1. A maintainer will review the issue and decide whether to assign you. Please don't comment just to request assignment.",+ "1. If you opened the linked issue, a maintainer will assign you when they pick it up and this PR reopens automatically. If someone else opened it, the PR reopens only if a maintainer chooses to assign it to you β please don't comment to ask.",];const commentBody = [MARKER,- kind === 'no-link'- ? '**This pull request was closed because it needs a valid issue link.** Please update this PR rather than opening a new one.'- : '**This pull request is awaiting maintainer assignment.** Linked PRs stay open while maintainers triage the issue; this check remains failing until assignment.',+ '**This pull request was closed because it must link to an issue assigned to you.** ' ++ 'Once this PR links to an issue and a maintainer assigns that issue to you, it will ' ++ 'reopen automatically. Please update this PR rather than opening a new one.','',`Per [CONTRIBUTING.md](https://github.com/${owner}/${repo}/blob/main/CONTRIBUTING.md), an external PR must reference an issue that's assigned to its author. To get there:`,'',...steps,'',- "Once you're assigned and the link is present, this check is re-run automatically. Previously gate-closed PRs also reopen β no further action needed.",+ "Once you're assigned and the link is present, this PR reopens automatically β no further action needed.",'',`*Maintainers: reopen this PR or remove the \`${LABEL}\` label to bypass this check.*`,].join('\n');@@ -419,27 +421,10 @@ jobs:console.log('Requirement comment already present β skipping');}- if (kind === 'no-link' && pr.state === 'open') {+ if (pr.state === 'open') {await mutate(`close PR #${prNumber}`, () => github.rest.pulls.update({owner, repo, pull_number: prNumber, state: 'closed',}));- } else if (- kind === 'not-assigned' && pr.state === 'closed' &&- pr.labels.some(label => label.name === LABEL)- ) {- // Adding the missing link moves a gate-closed PR back into- // the open triage queue. A later human closure takes priority- // even if the enforcement label was left on the PR.- const events = await github.paginate(- github.rest.issues.listEvents,- { owner, repo, issue_number: prNumber, per_page: 100 },- );- const lastClosure = events.filter(event => event.event === 'closed').pop();- if (lastClosure?.actor?.login === 'github-actions[bot]') {- await mutate(`reopen linked PR #${prNumber} for triage`, () => github.rest.pulls.update({- owner, repo, pull_number: prNumber, state: 'open',- }));- }}if (enforce) {diff --git a/docs/development/contributing.mdx b/docs/development/contributing.mdxindex 0e989e0ab..48de056bd 100644--- a/docs/development/contributing.mdx+++ b/docs/development/contributing.mdx@@ -20,7 +20,7 @@ FastMCP prioritizes readable Python, clear APIs, and fixes at the source of a pr### Issues and assignment-External PRs must link an issue with an auto-close keyword such as `Fixes #123`. The author must also be assigned to that issue, unless it carries the `prs welcome` label. You can open a linked PR before assignment; it waits with a failing gate check while maintainers evaluate it. A PR without a valid issue link is closed.+External PRs must link an issue with an auto-close keyword such as `Fixes #123`. The author must also be assigned to that issue, unless it carries the `prs welcome` label. A PR that doesn't meet both conditions is closed automatically. The issue stays open as your report, and the PR reopens on its own once the link is present and a maintainer assigns you.Assignment commits maintainers to reviewing a contribution, not to merging it. Assigning an author reruns the gate and can reopen their previously closed PR. Update that PR rather than opening a duplicate. The issue reporter has first claim on implementing the fix; an open issue does not by itself mean a maintainer has accepted a proposed solution.