ci(images): assign image versions in CI and open the pin PR right after a push
Build / build (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 0s
Molecule / molecule (pull_request) Canceled after 0s

The image.yml matrix holds a hand-edited base (MAJOR.MINOR) per image instead
of a version. On main, scripts/next_image_version.py compares a checksum of the
image's inputs with the inputs-sha256 label of the newest published <base>.N
and the job publishes <base>.N+1 when they differ, or builds nothing when they
match. A published tag is still never moved.

renovate.yml runs live on the successful completion of Images (workflow_run),
so the pin pull request opens minutes after a push instead of on the schedule.

Removed: bump_image_versions.py and its tests, check_image_versions.py bump,
Lint's bump step, Renovate's postUpgradeTasks, and the bot-diff allowance for
matrix version lines.

Closes #165

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Defame1297 committed 2026-11-23 21:15:16 +00:00
1 parent 8da65bd08e
commit b12c990b6a
23 files changed
+484 -1064

No files matched your search

+20 -36
View File
@@ -23,7 +23,7 @@ FILES = {
"images/molecule-ubuntu2404/Dockerfile": f"FROM ubuntu:24.04@{D1}\n",
".gitea/workflows/image.yml": (
f"jobs:\n image:\n matrix:\n include:\n - name: ci\n"
f" version: 0.2.0\n job_image: ubuntu:24.04@{D1}\n"
f' base: "0.2"\n job_image: ubuntu:24.04@{D1}\n'
" container:\n image: ${{ matrix.job_image }}\n"
" steps:\n - run: echo ok\n"
),
@@ -121,11 +121,6 @@ class RuleTest(unittest.TestCase):
"RUN pip install uv==0.13.5 \\",
"RUN pip install uv==0.14.0 \\",
),
(
".gitea/workflows/image.yml",
" version: 0.2.0",
" version: 0.2.1",
),
(
".gitea/workflows/image.yml",
f" job_image: ubuntu:24.04@{D1}",
@@ -239,7 +234,7 @@ class RuleTest(unittest.TestCase):
line = f" job_image: ubuntu:24.04@{D1}"
for old, new in (
(line, ""),
(" version: 0.2.0", f" version: 0.2.0\n{line}"),
(' base: "0.2"', f' base: "0.2"\n{line}'),
(" steps:", f" steps:\n{line}"),
):
self.assertIsNotNone(self.problem(path, old, new), (old, new))
@@ -301,25 +296,19 @@ class RuleTest(unittest.TestCase):
for path, old, new in cases:
self.assertIsNotNone(self.problem(path, old, new), (path, old, new))
def test_version_lines_stay_in_place_and_rise(self):
v = " version: {}"
self.assertIsNone(
cbd.version_problem([(5, v.format("0.2.0"))], [(5, v.format("0.2.1"))])
)
self.assertIsNotNone(
cbd.version_problem([(5, v.format("0.2.0"))], [(9, v.format("0.2.1"))])
)
self.assertIsNotNone(
cbd.version_problem([(5, v.format("0.2.1"))], [(5, v.format("0.2.0"))])
)
self.assertIsNotNone(
cbd.version_problem([(5, v.format("0.2.0"))], [(5, v.format("0.2.0"))])
)
swapped = cbd.version_problem(
[(5, v.format("0.1.0")), (9, v.format("0.2.0"))],
[(5, v.format("0.2.0")), (9, v.format("0.1.0"))],
)
self.assertIsNotNone(swapped)
def test_matrix_version_and_base_lines_are_refused(self):
# CI assigns image versions and a human edits `base:`; the bot changes neither.
path = ".gitea/workflows/image.yml"
for old, new in (
(" version: 0.2.0", " version: 0.2.1"),
(' base: "0.2"', ' base: "0.3"'),
):
self.assertIsNotNone(self.problem(path, old, new), (old, new))
def test_changed_lines_stay_in_place(self):
line = f" job_image: ubuntu:24.04@{D1}"
self.assertIsNone(cbd.moved_problem([(7, line)], [(7, line)]))
self.assertIsNotNone(cbd.moved_problem([(7, line)], [(3, line)]))
def test_unequal_line_counts_are_refused(self):
self.assertIsNotNone(
@@ -471,23 +460,18 @@ class RepoTest(unittest.TestCase):
)
self.assertEqual(proc.returncode, 0, proc.stderr)
def test_lowering_a_matrix_version_fails_and_raising_it_passes(self):
self.edit(".gitea/workflows/image.yml", "version: 0.2.0", "version: 0.1.9")
self.commit("lower")
def test_a_matrix_base_change_is_refused(self):
self.edit(".gitea/workflows/image.yml", 'base: "0.2"', 'base: "0.3"')
self.commit("base")
code, _unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn("version", err)
run(self.repo, "git", "checkout", "-q", "main")
run(self.repo, "git", "checkout", "-q", "-b", "renovate/ok")
self.edit(".gitea/workflows/image.yml", "version: 0.2.0", "version: 0.2.1")
self.commit("raise")
self.assertEqual(self.gate(head="renovate/ok")[0], 0)
self.assertIn(".gitea/workflows/image.yml", err)
def test_a_realistic_bot_pr_passes(self):
self.edit("requirements-dev.txt", "reuse==6.2.0", "reuse==6.3.0")
self.edit(".pre-commit-config.yaml", "v1.0.0", "v1.1.0")
self.edit("images/ci/Dockerfile", "uv==0.13.5", "uv==0.14.0")
self.edit(".gitea/workflows/image.yml", "version: 0.2.0", "version: 0.2.1")
self.edit(".gitea/workflows/image.yml", D1, D2)
self.edit(".gitea/workflows/molecule.yml", D1, D2)
self.commit("bot")
code, out, err = self.gate()