From 30e1ee311f75a9feb2d1588b22e5508a91dc99fb Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sun, 8 Feb 2026 15:16:51 +0000 Subject: [PATCH] test: ensure every Renovate preset is validated --- .cicd/hooks/check-json-in-config.py | 36 +++++++++++++++++++++++++++++ .pre-commit-config.yaml | 8 +++++++ 2 files changed, 44 insertions(+) create mode 100755 .cicd/hooks/check-json-in-config.py diff --git a/.cicd/hooks/check-json-in-config.py b/.cicd/hooks/check-json-in-config.py new file mode 100755 index 0000000..69328b9 --- /dev/null +++ b/.cicd/hooks/check-json-in-config.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +import sys +import pathlib + +ROOT = pathlib.Path(__file__).resolve().parent.parent.parent +CONFIG_FILE = ROOT / ".pre-commit-config.yaml" + + +def main(argv: list[str]) -> int: + if not CONFIG_FILE.exists(): + print(".pre-commit-config.yaml not found in repo root") + return 1 + + config_text = CONFIG_FILE.read_text() + + missing = [] + for file_arg in argv: + path = pathlib.Path(file_arg) + + # only care about JSONs in repo root + if path.suffix == ".json" and path.parent.resolve() == ROOT: + print(f"Checking {path.name}...", flush=True) + if path.name not in config_text: + missing.append(path.name) + + if missing: + print("\nThese JSON files are missing from .pre-commit-config.yaml:") + for m in missing: + print(f" - {m}") + return 1 + + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fea0d55..97b4037 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,13 @@ # See https://pre-commit.com/hooks.html for more hooks repos: + - repo: local + hooks: + - id: check-json-in-config + name: Check Renovate presets are listed in pre-commit-config.yaml + entry: .cicd/hooks/check-json-in-config.py + language: python + types: [json] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: @@ -31,6 +38,7 @@ repos: (^|/).?renovate(?:rc)?(?:\.json5?)?$| default.json| copier.json| + groupManager.json| pre-commit.json| monthly.json| weekly.json|