feat(scripts): deny the production image set in the Collection's workflows

The pins check now fails when any file under .gitea/workflows mentions
git.rkdr.net/defame1297/, so the environment repo's production images can
never appear in the Collection's CI.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-25 21:08:14 +00:00
1 parent ec15abf400
commit 359e016307
2 files changed
+32 -1

No files matched your search

@@ -73,6 +73,14 @@ class PureTest(unittest.TestCase):
def matrix(self, mol="0.1.0", ci="0.2.0"):
return civ.matrix_of(IMAGE_YML.format(mol=mol, ci=ci))
def test_foreign_production_images_are_denied(self):
for text in ("image: git.rkdr.net/defame1297/gitea-ansible-runner:1@sha256:" + "a" * 64,
"# GIT.RKDR.NET:443/Defame1297/x", "image: git.rkdr.net/defame1297/y"):
self.assertEqual(len(civ.check_foreign_images({"w.yml": text})), 1, text)
for text in ("image: git.rkdr.net/mortis/ci:0.2.0", "https://git.rkdr.net/defame1297x",
"see Defame1297/ansible-homelab-mono"):
self.assertEqual(civ.check_foreign_images({"w.yml": text}), [], text)
def test_pins_ok_and_lagging(self):
pin = f"image: git.rkdr.net/mortis/ci:0.1.0@{DIGEST}\n"
self.assertEqual(civ.check_pins(self.matrix(), {"lint.yml": pin}), [])
@@ -243,6 +251,14 @@ class GitTest(unittest.TestCase):
self.assertIn(text, err)
self.assertEqual(len(err.strip().splitlines()), 1, err)
def test_pins_cli_denies_a_production_image_in_any_workflow(self):
self.write(".gitea/workflows/lint.yml", "name: Lint\n")
self.assertEqual(self.bump_args("pins")[0], 0)
self.write(".gitea/workflows/other.yaml", "container: git.rkdr.net/defame1297/runner:1\n")
code, err = self.bump_args("pins")
self.assertEqual(code, 1)
self.assertIn("other.yaml: mentions git.rkdr.net/defame1297/", err)
def test_moved_input_out_of_the_set_fails(self):
run(self.repo, "git", "mv", "images/mol/Dockerfile", "elsewhere.dockerfile")
self.commit("move out")