From 87b23ea4f33603baaca1e3e5805b26264afc36d3 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sat, 14 Nov 2026 13:51:58 +0000 Subject: [PATCH] ci(renovate): track requirements.yml and allow its version bumps Enable Renovate's ansible-galaxy manager for requirements.yml and let a bot pull request change only the version: lines of that file (check_bot_pr_diff.py), so a collection bump can automerge like the other pins while a changed name or source still fails the gate (#118). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG --- renovate.json | 6 ++++++ scripts/check_bot_pr_diff.py | 7 +++++++ tests/scripts/test_check_bot_pr_diff.py | 13 +++++++++++++ 3 files changed, 26 insertions(+) diff --git a/renovate.json b/renovate.json index 9999383..6f3c4ee 100644 --- a/renovate.json +++ b/renovate.json @@ -11,6 +11,7 @@ "semanticCommitScope": "deps", "enabledManagers": [ "pip_requirements", + "ansible-galaxy", "pre-commit", "github-actions", "dockerfile", @@ -26,6 +27,11 @@ "/^requirements-dev\\.txt$/" ] }, + "ansible-galaxy": { + "managerFilePatterns": [ + "/^requirements\\.yml$/" + ] + }, "pre-commit": { "enabled": true, "managerFilePatterns": [ diff --git a/scripts/check_bot_pr_diff.py b/scripts/check_bot_pr_diff.py index 353770f..eaf40ec 100644 --- a/scripts/check_bot_pr_diff.py +++ b/scripts/check_bot_pr_diff.py @@ -7,6 +7,7 @@ When starts with `renovate/`, the diff of ...HEAD may only touch: * requirements-dev.txt: pinned `name==version` lines, the same packages before and after; + * requirements.yml: `version:` lines (the collection names, and every other line, stay); * .pre-commit-config.yaml: `rev:` lines; * images//Dockerfile: the tag and digest of FROM lines (the image name stays), and the `uv==` token of a line that holds one; @@ -93,6 +94,10 @@ def reduce_requirement(line): return m[1].lower() if m else None +def reduce_version(line): + return "version" if VERSION_LINE.match(line) else None + + def reduce_rev(line): return "rev" if REV_LINE.match(line) else None @@ -127,6 +132,8 @@ def file_problem(path, removed, added): reduce_requirement, "a pinned `name==version` line of the same package", ) + if path == "requirements.yml": + return same_shape(removed, added, reduce_version, "a `version:` line") if path == ".pre-commit-config.yaml": return same_shape(removed, added, reduce_rev, "a `rev:` line") if DOCKERFILE.fullmatch(path): diff --git a/tests/scripts/test_check_bot_pr_diff.py b/tests/scripts/test_check_bot_pr_diff.py index f5c1c80..9d4645c 100644 --- a/tests/scripts/test_check_bot_pr_diff.py +++ b/tests/scripts/test_check_bot_pr_diff.py @@ -17,6 +17,7 @@ import check_bot_pr_diff as cbd D1, D2 = "sha256:" + "a" * 64, "sha256:" + "b" * 64 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", ".pre-commit-config.yaml": "repos:\n - repo: https://github.com/x/y\n rev: v1.0.0\n hooks:\n - id: y\n", "images/ci/Dockerfile": f"FROM ubuntu:24.04@{D1} AS os\nRUN pip install uv==0.13.5 \\\n && echo hi\nRUN echo x\n", "images/molecule-ubuntu2404/Dockerfile": f"FROM ubuntu:24.04@{D1}\n", @@ -54,6 +55,7 @@ class RuleTest(unittest.TestCase): def test_allowed_edits(self): cases = [ ("requirements-dev.txt", "reuse==6.2.0", "reuse==6.3.0"), + ("requirements.yml", " version: 14.0.0", " version: 14.1.0"), (".pre-commit-config.yaml", " rev: v1.0.0", " rev: v1.1.0"), ( "images/ci/Dockerfile", @@ -92,6 +94,17 @@ class RuleTest(unittest.TestCase): def test_refused_edits(self): cases = [ ("requirements-dev.txt", "reuse==6.2.0", "evil==1.0"), + ("requirements.yml", " version: 14.0.0", " version: '*'"), + ( + "requirements.yml", + " version: 14.0.0", + " source: https://evil.example", + ), + ( + "requirements.yml", + " - name: community.general", + " - name: evil.collection", + ), ("requirements-dev.txt", "reuse==6.2.0", "reuse @ https://x/y.tgz"), (".pre-commit-config.yaml", " rev: v1.0.0", " repo: https://evil/x"), (