mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
fix(ci): select only the roles whose rounds really deploy a changed role
PR 2846 changed only web-app-n8n and CI deployed every variant of ten unrelated roles: the disk closure linked each matrix consumer to n8n through matrix's dynamic n8n flag, and a role none of whose variant rounds deploys the seed fell back to all of its variants. The selection now drops such roles and keeps every other role only with the variants whose round deploys a seed. Its prefilter is built from the union of each role's disk, variant and nested services, so service keys only a variant declares (web-app-lam in moodle and openbao) are no longer missed. run_after no longer counts as an include, and a seed without application_id falls back to a full deploy. Checked against the planner's rounds for all 198 app seeds: exact. MEDUSA acceptances: RH005 on both existing raise SystemExit lines (exit contract, the caller maps any non-zero exit to __ALL__). 🎯 Fix: 95 % 💥 Break: 4 % 💸 Tokens: 100 % ⏱️ Velocity: 100 % 🛡️ Security: 100 % 🏆 Score: 91 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3be76454ee
commit
1539bb6698
4 files changed
+263
-90
No files matched your search
@@ -75,7 +75,7 @@ class TestAffected(unittest.TestCase):
|
||||
["leaf"],
|
||||
)
|
||||
|
||||
def test_run_after_consumer_is_included(self) -> None:
|
||||
def test_a_run_after_consumer_is_not_affected(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
_mk_app_role(root, "leaf", "leaf")
|
||||
@@ -83,10 +83,8 @@ class TestAffected(unittest.TestCase):
|
||||
_write_run_after(root, "consumer", ["leaf"])
|
||||
|
||||
with patch.object(repo_paths, "PROJECT_ROOT", root):
|
||||
self.assertEqual(
|
||||
affected_main.affected_roles(["leaf"]),
|
||||
["consumer", "leaf"],
|
||||
)
|
||||
self.assertEqual(affected_main.affected_roles(["leaf"]), ["leaf"])
|
||||
self.assertEqual(affected_main.affected_selection(["leaf"]), ["leaf"])
|
||||
|
||||
def test_dependencies_consumer_is_included_transitively(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
@@ -218,6 +216,90 @@ class TestAffected(unittest.TestCase):
|
||||
got = affected_main.affected_selection(["web-app-keycloak"])
|
||||
self.assertIn("web-app-consumer#0,1", got)
|
||||
|
||||
def test_a_role_no_round_of_which_deploys_the_seed_is_left_out(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
for role in ("web-app-n8n", "web-app-matrix", "web-app-discourse"):
|
||||
_mk_app_role(root, role, role)
|
||||
off = {"enabled": False, "shared": False}
|
||||
on = {"enabled": True, "shared": True}
|
||||
dynamic = "{{ 'web-app-n8n' in group_names }}"
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-matrix" / ROLE_FILE_META_SERVICES,
|
||||
{"matrix": {}, "n8n": {"enabled": dynamic, "shared": dynamic}},
|
||||
)
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-matrix" / ROLE_FILE_META_VARIANTS,
|
||||
[{"services": {"n8n": off}}, {"services": {"n8n": on}}],
|
||||
)
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-discourse" / ROLE_FILE_META_SERVICES,
|
||||
{"discourse": {}, "matrix": on},
|
||||
)
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-discourse" / ROLE_FILE_META_VARIANTS,
|
||||
[{}, {"services": {"matrix": off}}],
|
||||
)
|
||||
|
||||
with patch.object(repo_paths, "PROJECT_ROOT", root):
|
||||
self.assertIn(
|
||||
"web-app-discourse", affected_main.affected_roles(["web-app-n8n"])
|
||||
)
|
||||
got = affected_main.affected_selection(["web-app-n8n"])
|
||||
self.assertEqual(got, ["web-app-matrix#1", "web-app-n8n"])
|
||||
|
||||
def test_a_service_key_a_variant_switches_on_reaches_the_seed(self) -> None:
|
||||
shapes = {
|
||||
"only the variant declares it": (
|
||||
{"moodle": {}},
|
||||
{"enabled": True, "shared": True},
|
||||
),
|
||||
"disk shares it, the variant enables it": (
|
||||
{"moodle": {}, "lam": {"shared": True}},
|
||||
{"enabled": True},
|
||||
),
|
||||
}
|
||||
for label, (disk, variant) in shapes.items():
|
||||
with self.subTest(label), tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
_mk_app_role(root, "web-app-lam", "web-app-lam")
|
||||
_mk_app_role(root, "web-app-moodle", "web-app-moodle")
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-moodle" / ROLE_FILE_META_SERVICES, disk
|
||||
)
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-moodle" / ROLE_FILE_META_VARIANTS,
|
||||
[{"services": {"lam": variant}}, {}],
|
||||
)
|
||||
|
||||
with patch.object(repo_paths, "PROJECT_ROOT", root):
|
||||
got = affected_main.affected_selection(["web-app-lam"])
|
||||
self.assertEqual(got, ["web-app-lam", "web-app-moodle#0"])
|
||||
|
||||
def test_a_nested_services_demand_on_a_provider_reaches_the_seed(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
for role in ("web-app-keycloak", "web-app-matomo", "web-app-consumer"):
|
||||
_mk_app_role(root, role, role)
|
||||
off = {"enabled": False, "shared": False}
|
||||
on = {"enabled": True, "shared": True}
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-matomo" / ROLE_FILE_META_SERVICES,
|
||||
{"matomo": {"shared": True}, "sso": off},
|
||||
)
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-consumer" / ROLE_FILE_META_SERVICES,
|
||||
{"consumer": {}, "matomo": on},
|
||||
)
|
||||
dump_yaml(
|
||||
root / "roles" / "web-app-consumer" / ROLE_FILE_META_VARIANTS,
|
||||
[{"services": {"matomo": {**on, "services": {"sso": on}}}}, {}],
|
||||
)
|
||||
|
||||
with patch.object(repo_paths, "PROJECT_ROOT", root):
|
||||
got = affected_main.affected_selection(["web-app-keycloak"])
|
||||
self.assertIn("web-app-consumer#0", got)
|
||||
|
||||
def test_a_seed_keeps_every_variant_of_its_own_role(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
@@ -253,7 +335,7 @@ class TestAffected(unittest.TestCase):
|
||||
affected_main.EXIT_NON_MODELLABLE_SEED,
|
||||
)
|
||||
|
||||
def test_non_app_seed_reachable_via_run_after_is_modellable(self) -> None:
|
||||
def test_a_non_app_seed_behind_run_after_is_still_non_modellable(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
_mk_non_app_role(root, "sys-helper")
|
||||
@@ -261,16 +343,19 @@ class TestAffected(unittest.TestCase):
|
||||
_write_run_after(root, "consumer", ["sys-helper"])
|
||||
|
||||
with patch.object(repo_paths, "PROJECT_ROOT", root):
|
||||
got = affected_main.affected_roles(["sys-helper"])
|
||||
self.assertIn("sys-helper", got)
|
||||
self.assertIn("consumer", got)
|
||||
with self.assertRaises(SystemExit) as ctx:
|
||||
affected_main.affected_roles(["sys-helper"])
|
||||
self.assertEqual(
|
||||
ctx.exception.code,
|
||||
affected_main.EXIT_NON_MODELLABLE_SEED,
|
||||
)
|
||||
|
||||
def test_main_prints_space_separated_sorted(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
root = Path(td)
|
||||
_mk_app_role(root, "leaf", "leaf")
|
||||
_mk_app_role(root, "consumer", "consumer")
|
||||
_write_run_after(root, "consumer", ["leaf"])
|
||||
_write_dependencies(root, "consumer", ["leaf"])
|
||||
|
||||
with patch.object(repo_paths, "PROJECT_ROOT", root):
|
||||
buf = io.StringIO()
|
||||
|
||||
Reference in new issue
Block a user