Merge origin/main 70bbbb33b6 into fix/web-app-mediawiki/variant-budget-credit

Brings 27984bdf18 (PR 2562), which fixes this PR's Jenkins#0 failure in run 45037081070.

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-22 23:09:11 +00:00
commit 83ee9e5123
75 files changed
+2556 -270

No files matched your search

@@ -1,5 +1,6 @@
from __future__ import annotations
import importlib.metadata
import io
import json
import subprocess
@@ -365,6 +366,25 @@ class TestDeployAnsiblePlaybook(unittest.TestCase):
self.assertIn(absent, stderr.getvalue())
self.assertNotIn("PyYAML", stderr.getvalue())
def test_exits_naming_a_deploy_pin_the_interpreter_carries_at_another_version(
self,
):
installed = importlib.metadata.version("PyYAML")
pinned = f"PyYAML=={installed}.post999"
repo_root, bindir = self._checkout(
[pinned, f"ruamel.yaml=={importlib.metadata.version('ruamel.yaml')}"],
with_playbook=True,
)
stderr = io.StringIO()
with (
unittest.mock.patch.object(runner.sys, "stderr", stderr),
self.assertRaises(SystemExit) as ctx,
):
self._resolve(repo_root, bindir)
self.assertEqual(ctx.exception.code, 1)
self.assertIn(f"{pinned} (installed: {installed})", stderr.getvalue())
self.assertNotIn("ruamel.yaml", stderr.getvalue())
def test_exits_when_no_ansible_playbook_sits_beside_the_interpreter(self):
repo_root, bindir = self._checkout(["PyYAML"], with_playbook=False)
with (
@@ -7,8 +7,13 @@ from contextlib import redirect_stdout
from unittest.mock import patch
import cli.contributing.update.label.__main__ as label_main
from utils.update.level import LEVELS
REPO = "infinito-nexus/core"
UPDATE = label_main.UPDATE.name
MAJOR = label_main.MAJOR.name
MINOR = label_main.MINOR.name
PATCH = label_main.PATCH.name
class FakeGh:
@@ -44,21 +49,31 @@ class TestLevel(unittest.TestCase):
label_main.level(f"version-update:semver-{name}").name
for name in ("major", "minor", "patch")
],
["major", "minor", "patch"],
[MAJOR, MINOR, PATCH],
)
def test_an_unknown_or_empty_type_counts_as_major(self):
self.assertEqual(
{label_main.level(kind).name for kind in ("", "security", "semver-minor")},
{"major"},
{MAJOR},
)
def test_every_level_the_updater_prints_has_a_label(self):
self.assertEqual(set(label_main.LEVEL_OF_NAME), set(LEVELS))
def test_every_label_name_carries_an_emoji_before_its_word(self):
for label in (label_main.UPDATE, *label_main.LEVELS):
with self.subTest(label=label.name):
mark, _, word = label.name.partition(" ")
self.assertFalse(mark.isascii())
self.assertTrue(word.isascii() and word)
class TestSync(unittest.TestCase):
def test_a_bare_pull_request_gets_update_and_its_level(self):
gh = FakeGh({"update", "minor"}, set())
actions = label_main.sync(gh, REPO, 4, "version-update:semver-minor")
self.assertEqual(actions, ["added update, minor"])
gh = FakeGh({UPDATE, MINOR}, set())
actions = label_main.sync(gh, REPO, 4, label_main.MINOR)
self.assertEqual(actions, [f"added {UPDATE}, {MINOR}"])
self.assertEqual(
gh.writes,
[
@@ -68,35 +83,33 @@ class TestSync(unittest.TestCase):
"POST",
f"repos/{REPO}/issues/4/labels",
"-f",
"labels[]=update",
f"labels[]={UPDATE}",
"-f",
"labels[]=minor",
f"labels[]={MINOR}",
]
],
)
def test_labels_already_present_cause_no_write(self):
gh = FakeGh({"update", "patch"}, {"update", "patch", "dependencies"})
self.assertEqual(
label_main.sync(gh, REPO, 4, "version-update:semver-patch"), []
)
gh = FakeGh({UPDATE, PATCH}, {UPDATE, PATCH, "dependencies"})
self.assertEqual(label_main.sync(gh, REPO, 4, label_main.PATCH), [])
self.assertEqual(gh.writes, [])
def test_a_stale_level_is_removed(self):
gh = FakeGh({"update", "major", "minor"}, {"update", "minor"})
actions = label_main.sync(gh, REPO, 4, "version-update:semver-major")
self.assertEqual(actions, ["removed minor", "added major"])
gh = FakeGh({UPDATE, MAJOR, MINOR}, {UPDATE, MINOR})
actions = label_main.sync(gh, REPO, 4, label_main.MAJOR)
self.assertEqual(actions, [f"removed {MINOR}", f"added {MAJOR}"])
def test_missing_repository_labels_are_created_first(self):
gh = FakeGh(set(), set())
label_main.sync(gh, REPO, 4, "version-update:semver-patch")
label_main.sync(gh, REPO, 4, label_main.PATCH)
created = [write[2] for write in gh.writes if write[:2] == ["label", "create"]]
self.assertEqual(created, ["update", "patch"])
self.assertEqual(created, [UPDATE, PATCH])
def test_a_label_a_parallel_run_created_counts_as_done(self):
gh = FakeGh({"patch"}, set(), racing={"update"})
actions = label_main.sync(gh, REPO, 4, "version-update:semver-patch")
self.assertEqual(actions, ["added update, patch"])
gh = FakeGh({PATCH}, set(), racing={UPDATE})
actions = label_main.sync(gh, REPO, 4, label_main.PATCH)
self.assertEqual(actions, [f"added {UPDATE}, {PATCH}"])
def test_a_create_failure_that_leaves_the_label_missing_raises(self):
gh = FakeGh(set(), set())
@@ -107,24 +120,24 @@ class TestSync(unittest.TestCase):
return gh(args)
with self.assertRaises(subprocess.CalledProcessError):
label_main.sync(failing, REPO, 4, "")
label_main.sync(failing, REPO, 4, label_main.MAJOR)
class TestMain(unittest.TestCase):
def test_main_reports_when_nothing_changes(self):
gh = FakeGh({"update", "major"}, {"update", "major"})
gh = FakeGh({UPDATE, MAJOR}, {UPDATE, MAJOR})
out = io.StringIO()
with patch.object(label_main, "run_gh", gh), redirect_stdout(out):
code = label_main.main(["--repo", REPO, "--pr", "4", "--update-type", ""])
self.assertEqual((code, out.getvalue()), (0, "#4 already carries its labels\n"))
def test_ensure_only_creates_the_missing_labels_and_touches_no_pr(self):
gh = FakeGh({"update", "minor"}, set())
gh = FakeGh({UPDATE, MINOR}, set())
out = io.StringIO()
with patch.object(label_main, "run_gh", gh), redirect_stdout(out):
code = label_main.main(["--repo", REPO, "--ensure-only"])
created = [w[2] for w in gh.writes if w[:2] == ["label", "create"]]
self.assertEqual((code, created), (0, ["major", "patch"]))
self.assertEqual((code, created), (0, [MAJOR, PATCH]))
self.assertEqual(len(gh.writes), 2)
def test_without_ensure_only_the_pr_and_type_are_required(self):
@@ -132,6 +145,22 @@ class TestMain(unittest.TestCase):
label_main.main(["--repo", REPO, "--pr", "4"])
self.assertEqual(raised.exception.code, 2)
def test_the_level_labels_an_updater_pull_request(self):
gh = FakeGh({UPDATE, MINOR, PATCH}, {UPDATE, PATCH})
out = io.StringIO()
with patch.object(label_main, "run_gh", gh), redirect_stdout(out):
code = label_main.main(["--repo", REPO, "--pr", "4", "--level", "minor"])
self.assertEqual(
(code, out.getvalue()), (0, f"removed {PATCH}\nadded {MINOR}\n")
)
def test_a_level_and_an_update_type_together_are_refused(self):
with self.assertRaises(SystemExit) as raised, redirect_stdout(io.StringIO()):
label_main.main(
["--repo", REPO, "--pr", "4", "--level", "minor", "--update-type", ""]
)
self.assertEqual(raised.exception.code, 2)
if __name__ == "__main__":
unittest.main()
@@ -2,6 +2,7 @@ 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
@@ -14,7 +15,7 @@ def pull_request(**overrides):
"user": {"login": "dependabot[bot]"},
"head": {"ref": "dependabot/npm/left-pad-1.3.0", "repo": {"full_name": REPO}},
"base": {"ref": "main"},
"labels": [{"name": "update"}],
"labels": [{"name": UPDATE.name}],
}
pr.update(overrides)
return pr
@@ -10,6 +10,7 @@ from pathlib import Path
from unittest.mock import patch
import cli.contributing.update.merge.__main__ as merge_main
from cli.contributing.update.label import MINOR, UPDATE
from cli.contributing.update.merge import github
from utils.roles.mapping import ROLE_FILE_META_SERVICES
@@ -32,7 +33,7 @@ def pull_request(**overrides):
"repo": {"full_name": REPO},
},
"base": {"ref": "main"},
"labels": [{"name": "update"}, {"name": "minor"}],
"labels": [{"name": UPDATE.name}, {"name": MINOR.name}],
}
pr.update(overrides)
return pr
@@ -137,7 +138,7 @@ class TestEvaluate(unittest.TestCase):
def test_a_missing_update_label_is_refused(self):
unlabeled = pull_request(labels=[{"name": "minor"}])
refusals = evaluate(green_gh(prs=[unlabeled]))[1]
self.assertEqual(refusals, ["label update is missing"])
self.assertEqual(refusals, [f"label {UPDATE.name} is missing"])
def test_a_pending_check_refuses(self):
pending = check("🌐 Translate catalogs", status="in_progress", conclusion=None)