ci(lint): validate renovate.json in the pinned Renovate image
Add a renovate-config job to Lint that runs renovate-config-validator --strict --no-global in a copy of renovate.yml's Renovate image, so the config is checked by the Renovate that runs it and the check can be required. The ci image stays without Node. check_bot_pr_diff.py now lets a bot pull request move the tag and digest of the renovate/renovate image line in renovate.yml and lint.yml, in place, keeping the name and the -full flavour. A test holds the two pins equal. Refs: #188 Assisted-by: Claude Code
This commit is contained in:
1 parent
d1db4fb0db
commit
763ec5dfd3
4 files changed
+145
-11
No files matched your search
@@ -16,6 +16,8 @@ import check_bot_pr_diff as cbd
|
||||
from test_check_uv_lock import APM_NEW, APM_OLD, CLICK_OLD, UV_LOCK, uv_files
|
||||
|
||||
D1, D2 = "sha256:" + "a" * 64, "sha256:" + "b" * 64
|
||||
RENOVATE_OLD = f" image: renovate/renovate:44.161.0-full@{D1}"
|
||||
RENOVATE_NEW = f" image: renovate/renovate:44.170.2-full@{D2}"
|
||||
FILES = {
|
||||
"requirements-dev.txt": "# pins\nansible-core==2.19.14\nreuse==6.2.0\n",
|
||||
"requirements.yml": "---\ncollections:\n - name: community.general\n version: 14.0.0\n",
|
||||
@@ -28,7 +30,14 @@ FILES = {
|
||||
" container:\n image: ${{ matrix.job_image }}\n"
|
||||
" steps:\n - run: echo ok\n"
|
||||
),
|
||||
".gitea/workflows/lint.yml": f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n",
|
||||
".gitea/workflows/lint.yml": (
|
||||
f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n"
|
||||
f"jobs:\n renovate-config:\n container:\n{RENOVATE_OLD}\n"
|
||||
),
|
||||
".gitea/workflows/renovate.yml": (
|
||||
f"jobs:\n renovate:\n container:\n{RENOVATE_OLD}\n"
|
||||
" steps:\n - env:\n LOG_LEVEL: info\n run: renovate\n"
|
||||
),
|
||||
".gitea/workflows/molecule.yml": f"env:\n MOLECULE_IMAGE: >-\n git.rkdr.net/mortis/mol:0.1.0@{D1}\n",
|
||||
"renovate.json": "{}\n",
|
||||
"pyproject.toml": '[project]\nrequires-python = ">=3.11"\n\n[dependency-groups]\ndev = ["apm-cli==0.39.3"]\n',
|
||||
@@ -228,6 +237,8 @@ class RuleTest(unittest.TestCase):
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.1@{D2}",
|
||||
),
|
||||
(".gitea/workflows/renovate.yml", RENOVATE_OLD, RENOVATE_NEW),
|
||||
(".gitea/workflows/lint.yml", RENOVATE_OLD, RENOVATE_NEW),
|
||||
]
|
||||
for path, old, new in cases:
|
||||
self.assertIsNone(self.problem(path, old, new), (path, old, new))
|
||||
@@ -311,11 +322,54 @@ class RuleTest(unittest.TestCase):
|
||||
f" image: git.rkdr.net/defame1297/ci:0.2.0@{D1}",
|
||||
),
|
||||
("renovate.json", "{}", '{"a": 1}'),
|
||||
(
|
||||
".gitea/workflows/renovate.yml",
|
||||
" run: renovate",
|
||||
" run: evil",
|
||||
),
|
||||
(
|
||||
".gitea/workflows/renovate.yml",
|
||||
" LOG_LEVEL: info",
|
||||
" LOG_LEVEL: debug",
|
||||
),
|
||||
(
|
||||
".gitea/workflows/renovate.yml",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.1@{D2}",
|
||||
),
|
||||
(
|
||||
".gitea/workflows/lint.yml",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
|
||||
RENOVATE_NEW,
|
||||
),
|
||||
("roles/x/tasks/main.yml", "a", "b"),
|
||||
]
|
||||
for path, old, new in cases:
|
||||
self.assertIsNotNone(self.problem(path, old, new), (path, old, new))
|
||||
|
||||
def test_the_renovate_image_pins_are_the_same(self):
|
||||
# Lint validates renovate.json in the image renovate.yml runs; one bot PR moves both copies.
|
||||
pins = []
|
||||
for name in ("renovate.yml", "lint.yml"):
|
||||
text = (SCRIPTS.parent / ".gitea/workflows" / name).read_text()
|
||||
lines = [line for line in text.splitlines() if "renovate/renovate:" in line]
|
||||
self.assertEqual(len(lines), 1, (name, lines))
|
||||
self.assertIsNotNone(cbd.RENOVATE_LINE.match(lines[0]), (name, lines[0]))
|
||||
pins.append(lines[0].strip())
|
||||
self.assertEqual(pins[0], pins[1])
|
||||
|
||||
def test_the_renovate_image_keeps_its_name_flavour_and_digest(self):
|
||||
for path in (".gitea/workflows/renovate.yml", ".gitea/workflows/lint.yml"):
|
||||
for new in (
|
||||
RENOVATE_NEW.replace("renovate/renovate", "evil/renovate"),
|
||||
RENOVATE_NEW.replace("-full@", "@"),
|
||||
RENOVATE_NEW.replace("-full@", "-slim@"),
|
||||
RENOVATE_NEW.replace(f"@{D2}", ""),
|
||||
RENOVATE_NEW.replace("44.170.2", "latest"),
|
||||
RENOVATE_NEW + " # evil",
|
||||
):
|
||||
self.assertIsNotNone(self.problem(path, RENOVATE_OLD, new), (path, new))
|
||||
|
||||
def test_job_image_lines_cannot_be_added_removed_or_moved(self):
|
||||
path = ".gitea/workflows/image.yml"
|
||||
line = f" job_image: ubuntu:24.04@{D1}"
|
||||
@@ -565,6 +619,25 @@ class RepoTest(unittest.TestCase):
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("5 file(s)", out)
|
||||
|
||||
def test_a_renovate_self_bump_passes(self):
|
||||
self.edit(".gitea/workflows/renovate.yml", RENOVATE_OLD, RENOVATE_NEW)
|
||||
self.edit(".gitea/workflows/lint.yml", RENOVATE_OLD, RENOVATE_NEW)
|
||||
self.commit("bot")
|
||||
code, out, err = self.gate()
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("2 file(s)", out)
|
||||
|
||||
def test_a_moved_renovate_image_line_is_refused(self):
|
||||
path = ".gitea/workflows/renovate.yml"
|
||||
self.edit(path, f"{RENOVATE_OLD}\n", "")
|
||||
self.edit(
|
||||
path, " run: renovate\n", f" run: renovate\n{RENOVATE_NEW}\n"
|
||||
)
|
||||
self.commit("bot")
|
||||
code, _unused, err = self.gate()
|
||||
self.assertEqual(code, 1, err)
|
||||
self.assertIn(path, err)
|
||||
|
||||
def bump_apm_cli(self):
|
||||
"""The change Renovate makes for apm-cli 0.39.4, as uv 0.13.1 writes it."""
|
||||
self.edit("pyproject.toml", "apm-cli==0.39.3", "apm-cli==0.39.4")
|
||||
|
||||
Reference in new issue
Block a user