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:
Defame1297 committed 2026-12-06 17:01:55 +00:00
1 parent d1db4fb0db
commit 763ec5dfd3
4 files changed
+145 -11

No files matched your search

+36 -8
View File
@@ -26,7 +26,10 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
and a human sets the matrix `base:`, so neither is the bot's to change;
* .gitea/workflows/{lint,build,molecule,gitea-release-key}.yml: the version and digest of a
`git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` pin (the name stays), including
the MOLECULE_IMAGE value.
the MOLECULE_IMAGE value;
* .gitea/workflows/renovate.yml, and lint.yml's copy of it: the version and digest of the
`image: renovate/renovate:<version>-full@sha256:<digest>` line, in place; the name and the
`-full` flavour stay (the job's report check needs the python3 that only -full ships).
Every other file, every other line, an added, deleted or mode-changed file fails, with one
`::error::` line per offending file. renovate.json itself is not allowed: the bot does not
@@ -73,6 +76,11 @@ UV_TOKEN = re.compile(r"\buv==[0-9][0-9A-Za-z.+!_-]*")
UBUNTU_LINE = re.compile(
rf"^(\s*job_image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$"
)
RENOVATE_LINE = re.compile(
r"^(\s*image:\s*renovate/renovate:)[0-9]+(?:\.[0-9]+)*(-full)@sha256:[0-9a-f]{64}\s*$"
)
RENOVATE_WORKFLOW = ".gitea/workflows/renovate.yml"
LINT_WORKFLOW = ".gitea/workflows/lint.yml"
DOCKERFILE = re.compile(r"images/[^/]+/Dockerfile")
COLLECTION_PINS = {"requirements.yml", "extensions/molecule/requirements.yml"}
# Lint's and the molecule-controller image's requirements, each with its pip-compile lock.
@@ -80,7 +88,6 @@ REQUIREMENTS = {"requirements-dev.txt", "requirements-molecule.txt"}
LOCKS = {"requirements-dev.lock", "requirements-molecule.lock"}
UV_LOCK = "uv.lock"
CONSUMERS = {
".gitea/workflows/lint.yml",
".gitea/workflows/build.yml",
".gitea/workflows/molecule.yml",
".gitea/workflows/gitea-release-key.yml",
@@ -183,6 +190,28 @@ def reduce_pin(line):
return reduced if PIN.search(line) else None
def reduce_renovate_image(line):
m = RENOVATE_LINE.match(line)
return m[1] + "X" + m[2] if m else None
def reduce_lint_yml(line):
# Lint also validates renovate.json in a copy of renovate.yml's image.
return reduce_pin(line) or reduce_renovate_image(line)
MORTIS_PIN = (reduce_pin, "an image pin of the mortis registry")
# The workflows whose image lines a bot moves: (reduce_line, what may change).
WORKFLOW_PINS = {
**dict.fromkeys(CONSUMERS, MORTIS_PIN),
LINT_WORKFLOW: (
reduce_lint_yml,
"an image pin of the mortis registry or the Renovate image line",
),
RENOVATE_WORKFLOW: (reduce_renovate_image, "the Renovate image line"),
}
def file_problem(path, removed, added):
"""One-line reason why the change to `path` is not allowed for a bot, or None."""
if path in REQUIREMENTS:
@@ -216,10 +245,8 @@ def file_problem(path, removed, added):
reduce_image_yml,
"a `job_image:` ubuntu pin",
)
if path in CONSUMERS:
return same_shape(
removed, added, reduce_pin, "an image pin of the mortis registry"
)
if path in WORKFLOW_PINS:
return same_shape(removed, added, *WORKFLOW_PINS[path])
return "is not a file a bot pull request may change"
@@ -268,7 +295,8 @@ def parse_patch(text):
def moved_problem(removed, added):
"""A reason when a changed line changes position, else None; both lists are (line number, line).
A `job_image:` pin moved to another matrix entry would change which job runs on it."""
A `job_image:` pin moved to another matrix entry, or the Renovate image line moved out of its
`container:`, would change which job runs on it."""
if [n for n, unused in removed] != [n for n, unused in added]:
return "moves or deletes a line (the changed lines must stay where they are)"
return None
@@ -319,7 +347,7 @@ def check(entries, patch_of, show=None):
[line for unused, line in removed],
[line for unused, line in added],
)
if not reason and path == civ.MATRIX_FILE:
if not reason and path in (civ.MATRIX_FILE, RENOVATE_WORKFLOW):
reason = moved_problem(removed, added)
if reason:
problems.append(f"{path}: {reason}")