Repository navigation
Assign PR leads from "Part of #N" references and a twice-daily sweep - #14255
Conversation
new_pr_labeler only read closing keywords, so PRs that say "Part of #N" got no lead, and PRs whose issue got its Lead label later were never revisited. - Recognise non-closing references (Part of, Refs, Related to, Follow-up to, Works on, Towards) after closing keywords, and same-repo issue URLs. - Fall back to the parent epic's lead when the issue has none. Inherit the priority only from closing references. - Add pm_pr_lead_sweep, which runs the same decision at 6 AM and 6 PM Pacific on open PRs that have never had an assignee. Scheduled runs are dry runs. - Write the decision and its reason to the job summary.
|
@mekarpeles since this can really only be tested after merging I'm thinking I might just merge so we can see it works can you can review closer later. |
- Skip referenced numbers that are not issues or PRs (Discussions, typos) instead of throwing; GraphQL NOT_FOUND made Octokit throw before the type check, aborting the sweep and the labeler. - Keep the closing issue's priority when a later "Part of" reference supplies the lead (regression from master). - Report "could not assign" when GitHub silently drops the assignee, so the sweep doesn't silently retry a lead without repo access. - Ignore references inside HTML comments. - Isolate each PR in the sweep so one failure can't stop the run; failures are listed in the summary and fail the job.
- Move the sweep loop into runSweep()/formatSweepSummary() in pr_lead_resolver.mjs so it can be unit tested with a fake Octokit; pr_lead_sweep.mjs is now a thin entry point. - A failure while listing PRs no longer loses the summary: rows collected so far are reported and the run fails. - Escape newlines and pipes in summary table cells (GraphQL error messages are multi-line). - Only treat NOT_FOUND on the issue itself as "skip"; if only its parent can't be read, keep the issue's own labels. - Ignore parents in another repo. - Add a 10-minute timeout to the sweep job. - Fix stale comments and document the 5-reference cap, the self-assignment rule and how to make scheduled runs live.
|
Update after merge: it's working in production. What I ran
The 9 PRs it still can't assign
Next
@mekarpeles a closer review whenever you have time would still be welcome. |
…nternetarchive#14255) * Assign PR leads from "Part of #N" references and a twice-daily sweep new_pr_labeler only read closing keywords, so PRs that say "Part of #N" got no lead, and PRs whose issue got its Lead label later were never revisited. - Recognise non-closing references (Part of, Refs, Related to, Follow-up to, Works on, Towards) after closing keywords, and same-repo issue URLs. - Fall back to the parent epic's lead when the issue has none. Inherit the priority only from closing references. - Add pm_pr_lead_sweep, which runs the same decision at 6 AM and 6 PM Pacific on open PRs that have never had an assignee. Scheduled runs are dry runs. - Write the decision and its reason to the job summary. * Harden PR lead resolution after review - Skip referenced numbers that are not issues or PRs (Discussions, typos) instead of throwing; GraphQL NOT_FOUND made Octokit throw before the type check, aborting the sweep and the labeler. - Keep the closing issue's priority when a later "Part of" reference supplies the lead (regression from master). - Report "could not assign" when GitHub silently drops the assignee, so the sweep doesn't silently retry a lead without repo access. - Ignore references inside HTML comments. - Isolate each PR in the sweep so one failure can't stop the run; failures are listed in the summary and fail the job. * Make the sweep robust and testable; tighten comments - Move the sweep loop into runSweep()/formatSweepSummary() in pr_lead_resolver.mjs so it can be unit tested with a fake Octokit; pr_lead_sweep.mjs is now a thin entry point. - A failure while listing PRs no longer loses the summary: rows collected so far are reported and the run fails. - Escape newlines and pipes in summary table cells (GraphQL error messages are multi-line). - Only treat NOT_FOUND on the issue itself as "skip"; if only its parent can't be read, keep the issue's own labels. - Ignore parents in another repo. - Add a 10-minute timeout to the sweep job. - Fix stale comments and document the 5-reference cap, the self-assignment rule and how to make scheduled runs live.
Closes #14254
feature: assign PR leads from "Part of #N" references, fall back to the parent epic's lead, and add a twice-daily sweep for PRs that were missed when they opened. Part of #13160.
Technical
findIssueReferencesinnew_pr_labeler_core.mjs):Part of,Refs/References,Related to,Follow-up to,Works on,Towards.#N.#Nis still ignored.planForPrin the newpr_lead_resolver.mjs):issueOrPullRequestquery and skips references that are PRs.Issue.parent).#14140 (closing keyword) has no Lead label. A run that assigns nobody no longer looks the same as a success.pm_pr_lead_sweep.yml:0 14 * * *and0 2 * * *UTC, which is 6 AM / 6 PM PST and an hour later during daylight time. It can also be run by hand.liveinput. Going live on schedule is a one-line change once the reports look right.timelineItems(itemTypes: …).totalCountignores the filter, so "ever assigned" checks the returned nodes instead.Testing
npx vitest run tests/unit/js/new_pr_labeler.test.js: 54 pass, 40 of them new. They cover phrase matching, the parent fallback, the sweep's skip rules,planForPr, and the sweep loop (runSweep: dry-run vs live, pagination, per-PR and listing failures, a lead GitHub won't assign) against a fake Octokit.After review, checked live with
planForPr:Part of #13079(a Discussion) no longer throws.Closes #13770. Part of #14254now keepsPriority: 2while assigning @mekarpeles.A referenced number that isn't an issue (a Discussion or a typo) is skipped, so a bad reference no longer stops the sweep.
When GitHub silently drops an assignee (e.g. the user has no repo access), the run reports "could not assign".
I ran the sweep locally in dry-run mode against this repo with a personal token. It writes nothing. Result:
Not verifiable before merge:
GITHUB_TOKENcan make the GraphQL reads (the permissions matchnew_pr_labeler.yml, which already reads issues);After merge: run
pm_pr_lead_sweepby hand withliveunchecked and check the job summary. Then open a test PR that says "Part of #N" and confirm it gets assigned.Stakeholders
@mekarpeles (lead)