feat(image): describe every image: labels, a readme page and build metadata

The registry page shows the description as plain text, every label, and links to source,
documentation and licence; it renders no readme. Each Dockerfile now carries one label
block (title, description, source, url, documentation, licenses, authors, base.name and
net.rkdr.mortis.purpose/contents/usage), the build adds version, revision and created, and
docs/images/<name>.md says what the image is for, what it contains and how to use it.
check_image_versions.py pins fails when a label or that page is missing. The labels are
image inputs, so the three images get their PATCH bump.

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-26 19:27:15 +00:00
1 parent 01f90c1f6a
commit c3c665e799
11 files changed
+363 -11

No files matched your search

+49 -2
View File
@@ -36,6 +36,15 @@ jobs:
CI_DOCKERFILE = f"FROM {JOB} AS b\nCOPY requirements-dev.txt .pre-commit-config.yaml ./\nCOPY --from=b /a /b\n"
def labelled(name, body=""):
"""A Dockerfile text with the labels check_image_metadata requires."""
values = {key: "x" for key in civ.REQUIRED_LABELS}
values["org.opencontainers.image.title"] = name
values["org.opencontainers.image.documentation"] = f"https://example.org/src/branch/main/docs/images/{name}.md"
return (f"FROM {JOB}\nLABEL " + " \\\n ".join(f'{k}="{v}"' for k, v in values.items()) + "\n" + body)
def run(cwd, *cmd):
return subprocess.run(cmd, cwd=cwd, check=True, capture_output=True, text=True,
env={**os.environ, "GIT_CONFIG_GLOBAL": "/dev/null", "GIT_CONFIG_SYSTEM": "/dev/null"})
@@ -283,6 +292,42 @@ class PureTest(unittest.TestCase):
with self.assertRaises(civ.CheckError):
civ.matrix_of(text)
def test_image_metadata_labels_and_documentation(self):
text = IMAGE_YML.format(mol="0.1.0", ci="0.2.0")
matrix = civ.matrix_of(text)
base = "https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images"
def dockerfile(name, drop=(), doc=None):
values = {key: "x" for key in civ.REQUIRED_LABELS}
values["org.opencontainers.image.title"] = name
values["org.opencontainers.image.documentation"] = doc or f"{base}/{name}.md"
keys = [k for k in values if k not in drop]
return f"FROM {JOB}\nLABEL " + " \\\n ".join(f'{k}="{values[k]}"' for k in keys) + "\n"
files = {"images/mol/Dockerfile": dockerfile("mol"), "images/ci/Dockerfile": dockerfile("ci")}
have = {"docs/images/mol.md", "docs/images/ci.md"}
def check():
return civ.check_image_metadata(matrix, lambda path: files[path], lambda path: path in have)
self.assertEqual(check(), [])
files["images/ci/Dockerfile"] = dockerfile("ci", drop=("net.rkdr.mortis.usage",))
self.assertEqual(len(check()), 1)
self.assertIn("lacks the label(s) net.rkdr.mortis.usage", check()[0])
files["images/ci/Dockerfile"] = dockerfile("ci", doc=f"{base}/other.md")
self.assertIn("must link to docs/images/ci.md", check()[0])
files["images/ci/Dockerfile"] = dockerfile("renamed")
self.assertTrue(any("expected the image name" in e for e in check()))
files["images/ci/Dockerfile"] = dockerfile("ci")
have.discard("docs/images/ci.md")
self.assertIn("docs/images/ci.md is missing", check()[0])
def test_real_dockerfiles_carry_the_metadata(self):
root = pathlib.Path(__file__).resolve().parents[2]
matrix = civ.matrix_of((root / civ.MATRIX_FILE).read_text())
self.assertEqual(civ.check_image_metadata(matrix, lambda p: (root / p).read_text(),
lambda p: (root / p).is_file()), [])
def test_scripts_do_not_import_yaml(self):
# The bump step runs in the Renovate image, whose python3 has no PyYAML (dry run 2453).
for script in ("check_image_versions.py", "bump_image_versions.py"):
@@ -313,8 +358,10 @@ class GitTest(unittest.TestCase):
run(self.repo, "git", "config", "user.email", "[email protected]")
run(self.repo, "git", "config", "user.name", "t")
self.write(".gitea/workflows/image.yml", IMAGE_YML.format(mol="0.1.0", ci="0.2.0"))
self.write("images/ci/Dockerfile", CI_DOCKERFILE)
self.write("images/mol/Dockerfile", f"FROM {JOB}\n")
self.write("images/ci/Dockerfile", labelled("ci", CI_DOCKERFILE.split("\n", 1)[1]))
self.write("images/mol/Dockerfile", labelled("mol"))
self.write("docs/images/ci.md", "ci\n")
self.write("docs/images/mol.md", "mol\n")
self.write("requirements-dev.txt", "a==1\n")
self.write(".pre-commit-config.yaml", "repos: []\n")
self.commit("base")