Files
kevinveenbirkenbachandClaude Opus 5.5 3308499701 feat(ci): add a Run all PR label and emoji CI labels
A PR run stops at its first failure: on pull request events the deploy matrix runs with fail-fast, so one failed row cancels the rest of its batch, and the batch 1 gate stops every later batch, so PR #2006 showed one failure per run. With the 🏃 Run all label the PR workflow calls the orchestrator with chunk_gate false, and call-test-deploy ties the matrix fail-fast to chunk_gate, so every row and batch deploys to its end; push and dispatch runs are unchanged. Every labeled event used to cancel the running PR pipeline and start a new one (42 of the last 200 PR runs): a run whose jobs all skip still joins the concurrency group, and the superseded-run canceller keeps it as the newest. Only 🧩 Subset, 🛡️ Trusted and 🏃 Run all now restart PR CI; any other label gets a group of its own and skips, in the PR workflow and in the canceller. The labels CI sets carry an emoji: ⬆️ update, 🔴 major, 🟡 minor, 🟢 patch, 💥 ci-failure, 🔓 vulnerability, 🔥 vulnerability-runtime, 💤 stale. pr.sh labels updater PRs through the label CLI with a new --level option, which also drops a stale level label when an existing PR changes level. test_pr_ci_labels.py keeps the three label lists equal and fails against the main workflows. Tests: update, security, meta/ci, workflow and repository lint suites green after the fixture updates (65 + 3 passed, 826 in the first full run); MEDUSA 100 %.

🎯 Fix: 88 %
💥 Break: 7 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 82
🚦 Gate: ⛔ fix 88 % < 90, break 7 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:07:27 +00:00

133 lines
4.7 KiB
Python

from __future__ import annotations
import unittest
from cli.contributing.update.label import UPDATE
from cli.contributing.update.merge import gate
from utils.roles.mapping import ROLE_FILE_META_SERVICES
REPO = "infinito-nexus/core"
def pull_request(**overrides):
pr = {
"draft": False,
"user": {"login": "dependabot[bot]"},
"head": {"ref": "dependabot/npm/left-pad-1.3.0", "repo": {"full_name": REPO}},
"base": {"ref": "main"},
"labels": [{"name": UPDATE.name}],
}
pr.update(overrides)
return pr
def check(**overrides):
run = {
"name": "🧹 Lint",
"status": "completed",
"conclusion": "success",
"details_url": "https://github.example/o/r/actions/runs/1/job/2",
}
run.update(overrides)
return run
class TestPullRequestRefusals(unittest.TestCase):
def test_an_update_bot_pull_request_passes(self):
self.assertEqual(gate.pull_request_refusals(pull_request(), REPO, "main"), [])
def test_a_bot_outside_its_branch_prefix_is_refused(self):
head = {"ref": "update/sneaky", "repo": {"full_name": REPO}}
self.assertEqual(
gate.pull_request_refusals(pull_request(head=head), REPO, "main"),
["branch update/sneaky lacks the dependabot/ prefix of dependabot[bot]"],
)
def test_a_head_in_another_repository_is_refused(self):
head = {"ref": "dependabot/npm/x", "repo": {"full_name": "fork/core"}}
refusals = gate.pull_request_refusals(pull_request(head=head), REPO, "main")
self.assertEqual(
refusals, [f"head branch dependabot/npm/x lives outside {REPO}"]
)
def test_a_deleted_head_repository_is_refused(self):
head = {"ref": "dependabot/npm/x", "repo": None}
refusals = gate.pull_request_refusals(pull_request(head=head), REPO, "main")
self.assertEqual(len(refusals), 1)
def test_a_draft_is_refused(self):
refusals = gate.pull_request_refusals(pull_request(draft=True), REPO, "main")
self.assertEqual(refusals, ["pull request is a draft"])
def test_another_base_branch_is_refused(self):
base = {"ref": "release"}
refusals = gate.pull_request_refusals(pull_request(base=base), REPO, "main")
self.assertEqual(refusals, ["base branch is release, not main"])
class TestCheckRefusals(unittest.TestCase):
def test_skipped_and_neutral_count_as_green(self):
runs = [check(conclusion="skipped"), check(conclusion="neutral")]
self.assertEqual(gate.check_refusals(runs, [], own_run_id=9), [])
def test_no_check_run_at_all_refuses(self):
self.assertEqual(
gate.check_refusals([], [], own_run_id=9),
["no check run on the head commit"],
)
def test_only_the_own_run_left_refuses(self):
own = check(details_url="https://github.example/o/r/actions/runs/9/job/3")
self.assertEqual(
gate.check_refusals([own], [], own_run_id=9),
["no check run on the head commit"],
)
def test_a_pending_status_refuses(self):
statuses = [{"context": "ci/external", "state": "pending"}]
self.assertEqual(
gate.check_refusals([check()], statuses, own_run_id=9),
["status ci/external is pending"],
)
class TestRoles(unittest.TestCase):
def test_changed_roles_reads_the_role_directory(self):
paths = [
f"roles/web-app-nextcloud/{ROLE_FILE_META_SERVICES}",
f"roles/sys-lint/{ROLE_FILE_META_SERVICES}",
"pyproject.toml",
"docs/roles/web-app-matomo.md",
]
self.assertEqual(gate.changed_roles(paths), {"web-app-nextcloud", "sys-lint"})
def test_deployed_roles_unions_the_role_column(self):
first = "role,seconds\nweb-app-nextcloud,3.0\nsvc-db-postgres,1.0\n"
second = "round,role,seconds\n1,web-app-matomo,2.0\n1,,0.5\n"
self.assertEqual(
gate.deployed_roles([first, second]),
{"web-app-nextcloud", "svc-db-postgres", "web-app-matomo"},
)
def test_a_csv_without_a_role_column_proves_nothing(self):
self.assertEqual(gate.deployed_roles(["name,seconds\nweb-app-x,1\n"]), set())
def test_no_changed_role_needs_no_proof(self):
self.assertEqual(gate.role_refusals(set(), []), [])
def test_every_missing_role_is_named(self):
csv_text = "role,seconds\nweb-app-nextcloud,1.0\n"
self.assertEqual(
gate.role_refusals(
{"web-app-nextcloud", "web-app-a", "web-app-b"}, [csv_text]
),
[
"role web-app-a changed, but no deploy row ran it",
"role web-app-b changed, but no deploy row ran it",
],
)
if __name__ == "__main__":
unittest.main()