Skip to content

Commit 1960f6b

Browse files
authored
ci(triage): label fork PRs and stop auto-closing PRs that only lack an issue link (#107)
* ci(triage): run PR triage on pull_request_target so fork PRs can be labeled Fork PRs run the triage job with a read-only GITHUB_TOKEN under the pull_request event regardless of the workflow's declared write permissions, so addLabels/createComment fail with 403 'Resource not accessible by integration' for every external contributor (e.g. #103). Switch the trigger to pull_request_target, which runs in the base-repo context with the declared write token. The job never checks out or runs PR head code (it only reads context.payload and the pulls/files API and manages labels), so it carries none of the untrusted-code-execution risk that makes pull_request_target dangerous. * ci(stale): drop needs-issue from auto-close trigger, keep it advisory needs-issue flags PRs that link no issue, but linking one is a SHOULD in CONTRIBUTING (required only for protocol-level changes), and many legitimate small PRs (docs, obvious fixes) have none. Coupling it to the 14/21-day auto-close was overreach: a substantive, well-described PR could be closed purely for missing an issue reference. Keep needs-issue as an advisory label and guidance nudge; leave only needs-description (an empty/thin body, a far stronger low-effort signal) as the auto-close trigger. * ci(stale): align stale message with description-only close condition The auto-close trigger narrowed to needs-description, but the stale message still told contributors a PR could close for a missing linked issue. Drop that clause so the warning matches what actually closes a PR. * style(ci): replace em dashes in triage/stale contributor messages * docs(contributing): match stale close policy to description-only trigger Auto-close is driven by needs-description only; a missing issue link stays advisory. Align the contributor docs with the workflow so the OR wording no longer implies a missing issue link can close a PR.
1 parent abc9ad0 commit 1960f6b

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

‎.github/workflows/pr-triage.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: PR Triage
22

3+
# Runs on pull_request_target, not pull_request: fork PRs get a read-only
4+
# GITHUB_TOKEN under pull_request regardless of the permissions below, so the
5+
# label/comment writes 403. This job never checks out or runs PR head code (it
6+
# only reads context.payload and the files API), so pull_request_target is safe.
37
on:
4-
pull_request:
8+
pull_request_target:
59
types: [opened, edited, synchronize, reopened]
610

711
permissions:
@@ -64,8 +68,8 @@ jobs:
6468
if (isFork && touchesWorkflows) want.add("workflow-change");
6569
6670
const changedRust = names.some(n => n.startsWith("crates/") && n.endsWith(".rs"));
67-
// A test can live in a tests/ dir, a *_test.rs file, or — the common Rust
68-
// pattern — an inline #[test] / #[cfg(test)] block added inside the source file.
71+
// A test can live in a tests/ dir, a *_test.rs file, or (the common Rust
72+
// pattern) an inline #[test] / #[cfg(test)] block added inside the source file.
6973
const addsInlineTest = files.some(f =>
7074
f.filename.endsWith(".rs") && f.patch &&
7175
/^\+.*#\[(test\]|cfg\(test\))/m.test(f.patch));
@@ -104,7 +108,7 @@ jobs:
104108
105109
const reasons = {
106110
"needs-issue": "Link the issue this addresses (`Closes #123`). For protocol changes, open an issue first.",
107-
"needs-description": "Add a short summary of what changes and why — the template's Summary and Motivation sections.",
111+
"needs-description": "Add a short summary of what changes and why: the template's Summary and Motivation sections.",
108112
"needs-tests": "This changes Rust source but no tests changed. Tests are required for fixes and strongly encouraged for features.",
109113
};
110114
const lines = advisory.map(l => `- ${reasons[l]}`).join("\n");

‎.github/workflows/stale.yml‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ jobs:
2323
# Act on PRs only; never on issues.
2424
days-before-issue-stale: -1
2525
days-before-issue-close: -1
26-
# Only PRs the triage step flagged as needing an author response.
27-
only-pr-labels: "needs-issue,needs-description"
26+
# Only PRs the triage step flagged as missing a real description.
27+
# needs-issue is advisory-only (linking an issue is a SHOULD, and many
28+
# legitimate small PRs have none) so it does not drive auto-close.
29+
only-pr-labels: "needs-description"
2830
stale-pr-label: "stale"
2931
exempt-pr-labels: "workflow-change,security,pinned"
3032
remove-stale-when-updated: true
3133
stale-pr-message: >
32-
This PR has been inactive for 14 days and is still missing a linked issue
33-
or a description. It will be closed in 7 days if there's no update. Push a
34-
change or leave a comment to keep it open — no hard feelings, you can reopen
35-
anytime.
34+
This PR has been inactive for 14 days and is still missing a description.
35+
It will be closed in 7 days if there's no update. Push a change or leave a
36+
comment to keep it open. No hard feelings, you can reopen anytime.
3637
close-pr-message: >
37-
Closing due to inactivity. Reopen whenever you're ready to update it — see
38+
Closing due to inactivity. Reopen whenever you're ready to update it. See
3839
CONTRIBUTING.md for what helps us review quickly.
3940
ascending: true

‎CONTRIBUTING.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ expected to clear a basic quality bar:
6969
- **A real description.** Say what changes and why. "Update code" is not a description.
7070

7171
A triage bot labels PRs that are missing these and leaves a short note. Nothing is closed
72-
automatically while you're engaging. A flagged PR that goes 14 days with no linked issue or
73-
description gets a stale warning, and is closed 7 days later if still untouched. Closed PRs can
74-
be reopened at any time once updated.
72+
automatically while you're engaging. A flagged PR still missing a description after 14 days of
73+
inactivity gets a stale warning, and is closed 7 days later if still untouched. A missing issue
74+
link alone never triggers closure; that label stays advisory. Closed PRs can be reopened at any
75+
time once updated.
7576

7677
## Development environment
7778

0 commit comments

Comments
 (0)