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

Closed
opened 2026-11-26 20:17:08 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/155
Author: @Mouad-Scriptz-0
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: ci/needs-rebase-label


📝 Commits (1)

  • 4f7a347 ci: label pull requests that conflict with main needs rebase (PR-CONFLICT-LABEL)

📊 Changes

6 files changed (+373 additions, -8 deletions)

View changed files

📝 .github/pull_request_template.md (+6 -0)
➕ .github/workflows/conflict-label.yml (+41 -0)
📝 CONTRIBUTING.md (+10 -0)
📝 tests/test_docs_pr_template.py (+10 -8)
➕ tests/test_pr_conflict_label.py (+157 -0)
➕ tools/pr_conflict_label.py (+149 -0)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/155 **Author:** [@Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `ci/needs-rebase-label` --- ### 📝 Commits (1) - [`4f7a347`](https://github.com/ubiquitarianism/leonida/commit/4f7a34777532930b2fe3f9c8b5d65afe04a480e4) ci: label pull requests that conflict with main `needs rebase` (PR-CONFLICT-LABEL) ### 📊 Changes **6 files changed** (+373 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `.github/pull_request_template.md` (+6 -0) ➕ `.github/workflows/conflict-label.yml` (+41 -0) 📝 `CONTRIBUTING.md` (+10 -0) 📝 `tests/test_docs_pr_template.py` (+10 -8) ➕ `tests/test_pr_conflict_label.py` (+157 -0) ➕ `tools/pr_conflict_label.py` (+149 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:08 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#206
No description provided.