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

+16 -1
View File
@@ -11,7 +11,10 @@ cannot make a tag immutable), so an image whose content changes under an unchang
version is pushed as sha-*/latest only, and a hand-pasted <version>@<new digest> pin
would pair a tag with a digest it does not point to.
pins Every `git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` in the consumer
pins No file under .gitea/workflows may mention `git.rkdr.net/defame1297/`: the production
image set of the environment repo never belongs in this CI (the `mortis` side is the
untrusted one, ADR 0004 Runner isolation).
Every `git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` in the consumer
workflows must name an image of the matrix, with a well-formed digest and a
version that is not newer than the matrix (a pin lags the matrix between the PR
that bumps the version and the PR that moves the pin; it can never lead it).
@@ -59,6 +62,9 @@ PIN_RE = re.compile(r"git\.rkdr\.net/mortis/(?P<name>[a-z0-9._-]+):(?P<version>[
ANY_PIN_RE = re.compile(
r"""(?<![@\w.-])(?<!http://)(?<!https://)git\.rkdr\.net(?::[0-9]+)?/mortis/[A-Za-z0-9._/-]+"""
r"""(?:[:@][^\s,)\]}'"]*)?""", re.IGNORECASE)
# The production image namespace of the environment repo; any spelling of the host's case.
FOREIGN_RE = re.compile(r"git\.rkdr\.net(?::[0-9]+)?/defame1297/", re.IGNORECASE)
WORKFLOW_DIR = ".gitea/workflows"
# Semver 2.0.0: no leading zeros in numeric identifiers (core or prerelease).
_NUM = r"(?:0|[1-9][0-9]*)"
_PRE_ID = r"(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)"
@@ -260,6 +266,13 @@ def changed_images(head_matrix, changed, read_head_file):
return result
def check_foreign_images(workflow_texts):
"""Errors for each workflow file that mentions the production image namespace, comments included."""
return [f"{fname}: mentions git.rkdr.net/defame1297/, the production image set; the Collection's CI "
"must never use or name it" for fname, text in sorted(workflow_texts.items())
if FOREIGN_RE.search(text)]
def check_bump(base_matrix, head_matrix, changed, read_head_file):
errors = []
for name, hits in changed_images(head_matrix, changed, read_head_file).items():
@@ -320,6 +333,8 @@ def run(argv):
raise CheckError(f"{REQUIRED_CONSUMER} is missing: it runs this check and is a required consumer")
texts = {f: pathlib.Path(f).read_text() for f in CONSUMERS if pathlib.Path(f).exists()}
errors = check_pins(matrix, texts)
workflows = sorted(pathlib.Path(WORKFLOW_DIR).glob("*.y*ml")) if pathlib.Path(WORKFLOW_DIR).is_dir() else []
errors += check_foreign_images({str(f): f.read_text() for f in workflows})
note = " (checked: " + ", ".join(texts) + ")"
elif len(argv) == 3 and argv[1] == "bump":
if not REF_RE.fullmatch(argv[2]):