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
@@ -367,6 +367,7 @@ class RuleTest(unittest.TestCase):
|
||||
RENOVATE_NEW.replace(f"@{D2}", ""),
|
||||
RENOVATE_NEW.replace("44.170.2", "latest"),
|
||||
RENOVATE_NEW + " # evil",
|
||||
RENOVATE_NEW.replace(" image:", " image:"),
|
||||
):
|
||||
self.assertIsNotNone(self.problem(path, RENOVATE_OLD, new), (path, new))
|
||||
|
||||
@@ -627,16 +628,30 @@ class RepoTest(unittest.TestCase):
|
||||
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"
|
||||
def test_an_added_renovate_image_line_is_refused(self):
|
||||
for path in (".gitea/workflows/renovate.yml", ".gitea/workflows/lint.yml"):
|
||||
self.assertIsNotNone(cbd.file_problem(path, [], [RENOVATE_NEW]), path)
|
||||
self.assertIsNotNone(
|
||||
cbd.file_problem(path, [RENOVATE_OLD], [RENOVATE_NEW, RENOVATE_NEW]),
|
||||
path,
|
||||
)
|
||||
|
||||
def assert_moved_line_refused(self, path, anchor):
|
||||
self.edit(path, f"{RENOVATE_OLD}\n", "")
|
||||
self.edit(
|
||||
path, " run: renovate\n", f" run: renovate\n{RENOVATE_NEW}\n"
|
||||
)
|
||||
self.edit(path, anchor, f"{anchor}{RENOVATE_NEW}\n")
|
||||
self.commit("bot")
|
||||
code, _unused, err = self.gate()
|
||||
self.assertEqual(code, 1, err)
|
||||
self.assertIn(path, err)
|
||||
self.assertIn("moves or deletes a line", err)
|
||||
|
||||
def test_a_moved_renovate_image_line_is_refused(self):
|
||||
self.assert_moved_line_refused(
|
||||
".gitea/workflows/renovate.yml", " run: renovate\n"
|
||||
)
|
||||
|
||||
def test_a_moved_image_line_in_lint_yml_is_refused(self):
|
||||
self.assert_moved_line_refused(".gitea/workflows/lint.yml", "run: echo a\n")
|
||||
|
||||
def bump_apm_cli(self):
|
||||
"""The change Renovate makes for apm-cli 0.39.4, as uv 0.13.1 writes it."""
|
||||
|
||||
Reference in new issue
Block a user