Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .cicd/hooks/check-json-in-config.py
Original file line number Diff line number Diff line change
@@ -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:]))
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -31,6 +38,7 @@ repos:
(^|/).?renovate(?:rc)?(?:\.json5?)?$|
default.json|
copier.json|
groupManager.json|
pre-commit.json|
monthly.json|
weekly.json|
Expand Down
Loading