ci: label pull requests from a schedule, not pull_request_target #3353

Open
sdelectron wants to merge 2 commits from upstream-pr/3353 into main
sdelectron commented 2026-12-03 15:48:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sdelectron on 2026-12-03T15:48:59Z.


Fixes the area-labels workflow, which has failed every run since Dec 2: GitHub's default blocks pull_request_target on public repositories, so all runs ended in startup_failure (run 47109744557; Neutron-0's finding in #3312).

The labeling now runs hourly from main, one actions/labeler run for every open pull request that may need a label, through the action's pr-number input (it takes several numbers, one per line). The job still runs from main with a token that can write to pull requests, and it still never checks out or runs pull request code.

The list job only hands over PRs opened or updated in the last 25 hours, or carrying no area: label yet and updated in the last 7 days, so a full pass doesn't spend the token's 1,000 requests/hour on PRs whose labels are already right; workflow_dispatch with label_all re-labels everything (manual, on-demand — at ~215 open PRs that's most of the hourly budget).

Trade-off: labels now lag up to an hour after a PR is opened or pushed, and a PR opened and merged within the hour never gets labels. There is no push trigger on purpose: a push to main changes no PR's file list.

claiming: CI-LABELER-TRUSTED-TRIGGER

Verified locally at upstream main 128579e9e: new tests/test_area_labels_workflow.py, 6 tests / 8 subtests pass (11 failures against the old workflow); neighboring workflow tests pass; jactionlint 2.6.0 + shellcheck clean; check_no_game_data clean. Reviewed by two independent read-only reviewers.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5629886883 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3353). Originally posted by [sdelectron](https://github.com/sdelectron) on 2026-12-03T15:48:59Z. --- Fixes the area-labels workflow, which has failed every run since Dec 2: GitHub's default blocks `pull_request_target` on public repositories, so all runs ended in `startup_failure` (run 47109744557; Neutron-0's finding in #3312). The labeling now runs hourly from main, one actions/labeler run for every open pull request that may need a label, through the action's `pr-number` input (it takes several numbers, one per line). The job still runs from main with a token that can write to pull requests, and it still never checks out or runs pull request code. The list job only hands over PRs opened or updated in the last 25 hours, or carrying no `area:` label yet and updated in the last 7 days, so a full pass doesn't spend the token's 1,000 requests/hour on PRs whose labels are already right; workflow_dispatch with `label_all` re-labels everything (manual, on-demand — at ~215 open PRs that's most of the hourly budget). Trade-off: labels now lag up to an hour after a PR is opened or pushed, and a PR opened and merged within the hour never gets labels. There is no push trigger on purpose: a push to main changes no PR's file list. claiming: CI-LABELER-TRUSTED-TRIGGER Verified locally at upstream main 128579e9e: new `tests/test_area_labels_workflow.py`, 6 tests / 8 subtests pass (11 failures against the old workflow); neighboring workflow tests pass; jactionlint 2.6.0 + shellcheck clean; check_no_game_data clean. Reviewed by two independent read-only reviewers.
merzleckeier commented 2026-12-03 17:50:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T17:50:37Z.


Reviewed eef5f944 against main 0f0f268d. The merge is clean and all six area-label workflow tests passed on the same workflow and config.

[P2] A full relabel can report success with PRs left unlabeled. With no checkout, the pinned Labeler fetches the PR, its file list and the config for each number. When a label changes, it fetches the PR again and writes the labels. That is at least five REST requests per changed PR. The label_all input sends every open PR at once, so a change to the label rules can exceed the standard 1,000-request hourly limit at the current queue size. Pinned Labeler implementation · GitHub token rate limits

I ran the pinned bundle against a local stub with 214 synthetic PRs and one file each. Already-correct labels took 642 requests. Adding one label to each took 1,070 requests. At a simulated 1,000-request cap the action exited 0 after updating 200 of 214, because the subsequent pulls.get failures were treated as missing PRs. Consider fetching the trusted workflow-revision config once and giving label_all a way to resume a bounded batch. Pinned PR lookup

AI-assisted with OpenAI Codex. The budget test made no requests to GitHub.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387152573 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3353#issuecomment-7387152573). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T17:50:37Z. --- Reviewed `eef5f944` against `main` `0f0f268d`. The merge is clean and all six area-label workflow tests passed on the same workflow and config. **[P2] A full relabel can report success with PRs left unlabeled.** With no checkout, the pinned Labeler fetches the PR, its file list and the config for each number. When a label changes, it fetches the PR again and writes the labels. That is at least five REST requests per changed PR. The `label_all` input sends every open PR at once, so a change to the label rules can exceed the standard 1,000-request hourly limit at the current queue size. [Pinned Labeler implementation](https://github.com/actions/labeler/blob/bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13/src/labeler.ts#L82-L140) · [GitHub token rate limits](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#primary-rate-limit-for-github_token-in-github-actions) I ran the pinned bundle against a local stub with 214 synthetic PRs and one file each. Already-correct labels took 642 requests. Adding one label to each took 1,070 requests. At a simulated 1,000-request cap the action exited 0 after updating 200 of 214, because the subsequent `pulls.get` failures were treated as missing PRs. Consider fetching the trusted workflow-revision config once and giving `label_all` a way to resume a bounded batch. [Pinned PR lookup](https://github.com/actions/labeler/blob/bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13/src/api/get-changed-pull-requests.ts#L8-L23) AI-assisted with OpenAI Codex. The budget test made no requests to GitHub.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3353:upstream-pr/3353'
git switch 'upstream-pr/3353'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3353'
git switch 'upstream-pr/3353'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3353'
git switch 'upstream-pr/3353'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3353'
git switch 'main'
git merge --squash 'upstream-pr/3353'
git switch 'main'
git merge --ff-only 'upstream-pr/3353'
git switch 'main'
git merge 'upstream-pr/3353'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3353
No description provided.