Skip to content

ci: label pull requests that conflict with main needs rebase (PR-CONFLICT-LABEL) - #155

Merged
ubiquitarianism merged 1 commit into
ProjectLeonida:mainfrom
Mouad-Scriptz-0:ci/needs-rebase-label
Nov 24, 2026
Merged

ubiquitarianism merged 1 commit into
ProjectLeonida:mainfrom
Mouad-Scriptz-0:ci/needs-rebase-label

Conversation

@Mouad-Scriptz-0

Copy link
Copy Markdown

Claimed in the coordination issue as: PR-CONFLICT-LABEL (#14)

Depends on: none. #56 and #100 also edit CONTRIBUTING.md, but only its lines 15–25; this adds a section at the end of the file and does not conflict with either.

What and why

Every pull request here is reviewed by hand, and 109 are open. Right now, 23 of them conflict with main and can't be merged until their authors rebase, but nothing marks which ones. This adds a needs rebase label so a reviewer can skip them and their authors know what to do. It's modelled on AnyPS5's contributing pipeline. The code was written here, not copied (AnyPS5 is GPL-2.0).

tools/pr_conflict_label.py (standard library only)

  • For each open pull request (or the ones given with --pr), it reads GitHub's mergeable answer and labels the conflicting ones needs rebase. Once a pull request merges cleanly again, the label is removed.
  • GitHub computes mergeable in the background and answers null until it's done. An unknown answer is asked again up to 4 times, 10 s apart, and otherwise left alone for the next run. The tool never guesses.
  • The label is created the first time it's needed (d93f0b, "Conflicts with the base branch: rebase it on main").
  • --dry-run prints what it would change and writes nothing.

.github/workflows/conflict-label.yml runs the tool:

  • on a push to main, checking all open pull requests, since a merge can make others conflict;
  • on pull_request_target opened / reopened / synchronize, checking that one pull request, since a rebase can clear a conflict;
  • hourly at :17, to catch merges GitHub hadn't computed yet;
  • on workflow_dispatch.

Security. pull_request_target is what gives a fork's pull request a token that can write labels. Here it's safe:

  • The job checks out the default branch, never the pull request.
  • persist-credentials: false.
  • The tool reads nothing but the API, so no pull request code ever runs.
  • Top-level permissions: {}. The job gets contents: read and pull-requests: write only.
  • actions/checkout is pinned to the same SHA as the other workflows.

tests/test_pr_conflict_label.py checks all of these properties in the workflow file.

PR template and CONTRIBUTING.md

  • The template gets new prompt lines: Fixes: (Fixes: #N closes the issue on merge) and GPUs tested: (vendor, model, driver and OS).
  • It also gets two checklist items: "based on current main and merges cleanly" and "one topic; follow-up work goes in a new pull request". The existing claim, Depends on: and AI-assisted: lines are kept.
  • tests/test_docs_pr_template.py now requires the new prompts.
  • CONTRIBUTING.md gets a short Pull requests section at the end: one topic per pull request, fill in the template, and what the label means.

This workflow only starts running once it's on main, because pull_request_target uses the base branch's copy. So it can't label anything from this pull request.

Tested

GPUs tested: n/a (CI and docs only)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

…NFLICT-LABEL)

Every pull request is reviewed by hand, and with over a hundred open the
reviewer has no quick way to skip the ones that cannot merge as they
stand. tools/pr_conflict_label.py asks the GitHub API for each open pull
request's `mergeable` and labels the conflicting ones `needs rebase`,
removing the label once they merge cleanly again; an answer GitHub has
not computed yet is asked again a few times and otherwise left for the
next run. .github/workflows/conflict-label.yml runs it on a push to main
(all open pull requests), on a pull request being opened, reopened or
pushed to (that one), and hourly.

The job uses pull_request_target so a fork's pull request can be
labeled, and is safe with it: it checks out main, never the pull
request, and the tool reads only the API, so no pull request code runs.
Its token can read contents and write pull requests, nothing else;
tests/test_pr_conflict_label.py checks that, and the tool against a fake
API.

The pull request template also asks for `Fixes: #N` and `GPUs tested:`
lines and has checklist items for "based on current main" and "one
topic"; tests/test_docs_pr_template.py checks the new prompts, and
CONTRIBUTING.md gets a short Pull requests section. The process is
modelled on AnyPS5's (boykopovar/AnyPS5); the code is written here, not
copied.
@ubiquitarianism
ubiquitarianism merged commit 48dcf5d into ProjectLeonida:main Nov 24, 2026
aslan2142 pushed a commit that referenced this pull request Nov 24, 2026
…-CONFLICT-LABEL-LOAD)

conflict-label.yml (#155) started a run on every push to every pull
request through pull_request_target. On this repository that queued 265
runs within a day, some waiting five hours, in the same runner queue as
CI, No Game Data and Runtime, whose oldest queued run waited six hours.

Drop the pull_request_target trigger and put every run in one
concurrency group. Each run already checks every open pull request, so
a push to main and the hourly schedule cover what the per-PR runs did;
a rebased pull request loses the label within the hour instead of at
once. At most one run waits at a time. The workflow also no longer has a
trigger that hands a fork's pull request a write token.

tests/test_pr_conflict_label.py fails on the old workflow and checks
that no pull request trigger, per-PR group or --pr comes back; the tool's
docstring and CONTRIBUTING.md say what runs it now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants