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

Manually merged
github merged 1 commit from gh-pr/155/head into gh-pr/155/base 2026-11-26 08:46:44 +00:00
Owner

@⁠Mouad-Scriptz-0 on GitHub · 2026-11-24 02:31 UTC · original
Mouad-Scriptz-0:ci/needs-rebase-label → main · +373 −8 · 6 files · 1 commits · merged 2026-11-24 03:09 UTC

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

  • tests/test_pr_conflict_label.py: 12 tests against a fake GitHub API, all OK. They cover every decide() case, retrying an uncomputed merge and then leaving it alone, creating the label once and only when needed, an existing label (422), a label removed in the meantime (404), closed pull requests being skipped, dry runs writing nothing, paging past 100, and the workflow's checkout and permission rules. Breaking decide() makes the suite fail.
  • Dry run on this repository (--dry-run, read-only GETs with my token): 109 checked: 23 labeled, 0 unlabeled, 0 not computed yet. I spot-checked against GitHub: #100, #52 and #141 report CONFLICTING and were flagged; #98 and #24 report MERGEABLE and were not.
  • These also pass: tests/test_docs_pr_template.py, test_ci_registration.py (the new test file is picked up by the standard-library loop), test_docs_links.py, test_text_write_line_endings.py, test_runtime_paths.py, test_no_game_data_workflow.py, python -m compileall -q make_game.py tools tests, and scripts/check_no_game_data.py on every changed file.
  • The workflow YAML parses. actionlint isn't installed here, so the jactionlint job in CI is the first lint of it.

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)
**@⁠Mouad-Scriptz-0** on GitHub · 2026-11-24 02:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/155) `Mouad-Scriptz-0:ci/needs-rebase-label` → `main` · +373 −8 · 6 files · 1 commits · merged 2026-11-24 03:09 UTC 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](https://github.com/boykopovar/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 - `tests/test_pr_conflict_label.py`: 12 tests against a fake GitHub API, all OK. They cover every `decide()` case, retrying an uncomputed merge and then leaving it alone, creating the label once and only when needed, an existing label (422), a label removed in the meantime (404), closed pull requests being skipped, dry runs writing nothing, paging past 100, and the workflow's checkout and permission rules. Breaking `decide()` makes the suite fail. - **Dry run on this repository** (`--dry-run`, read-only GETs with my token): `109 checked: 23 labeled, 0 unlabeled, 0 not computed yet`. I spot-checked against GitHub: #100, #52 and #141 report `CONFLICTING` and were flagged; #98 and #24 report `MERGEABLE` and were not. - These also pass: `tests/test_docs_pr_template.py`, `test_ci_registration.py` (the new test file is picked up by the standard-library loop), `test_docs_links.py`, `test_text_write_line_endings.py`, `test_runtime_paths.py`, `test_no_game_data_workflow.py`, `python -m compileall -q make_game.py tools tests`, and `scripts/check_no_game_data.py` on every changed file. - The workflow YAML parses. `actionlint` isn't installed here, so the `jactionlint` job in CI is the first lint of it. GPUs tested: n/a (CI and docs only) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:46:40 +00:00
github manually merged commit 4f7a347775 into gh-pr/155/base 2026-11-26 08:46:44 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.