ci(lint): keep the job token away from renovate.json and pin image lines in place
The renovate-config job clones in its own step and validates in a second step, so the job token is not in the environment that reads the pull request's renovate.json. check_bot_pr_diff.py now refuses a moved image line in every workflow whose pins a bot may move, lint.yml included, not only in image.yml and renovate.yml. Tests cover a moved lint.yml line, an added second Renovate line and a changed indentation. Refs: #188 Assisted-by: Claude Code
This commit is contained in:
1 parent
076546f91b
commit
9fb3cbd4fd
3 files changed
+34
-14
No files matched your search
@@ -25,8 +25,8 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
|
||||
`job_image: ubuntu:...@sha256:...` lines (the name stays); CI assigns the image versions
|
||||
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;
|
||||
`git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` pin, in place (the name stays),
|
||||
including 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).
|
||||
@@ -295,8 +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, or the Renovate image line moved out of its
|
||||
`container:`, would change which job runs on it."""
|
||||
A `job_image:` pin moved to another matrix entry, or a workflow's image line moved to another
|
||||
job, 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
|
||||
@@ -347,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 in (civ.MATRIX_FILE, RENOVATE_WORKFLOW):
|
||||
if not reason and (path == civ.MATRIX_FILE or path in WORKFLOW_PINS):
|
||||
reason = moved_problem(removed, added)
|
||||
if reason:
|
||||
problems.append(f"{path}: {reason}")
|
||||
|
||||
Reference in new issue
Block a user