ci(pre-commit): run check-json, the script tests and the image pins as hooks

A contributor learns about a broken renovate.json, a failing script test or
a bad image pin from Lint today; as hooks they fail before the push.

- check-json from pre-commit-hooks covers renovate.json.
- script-tests runs the suite at pre-push, since it takes minutes. Its
  GIT_DIR points at an uncreatable path, so a fixture that keeps the
  caller's git environment fails instead of writing to this repository.
  Lint runs it by id; the suite now runs under the network guard.
- check-image-pins runs check_image_versions.py pins on every commit: its
  inputs span workflows, Dockerfiles and docs/images, and it fails when one
  is missing. Lint's pre-commit run replaces its separate step.

Adding hooks changes .pre-commit-config.yaml, an input of the ci image, so
this pull request takes Lint's slow path and the next Images run publishes
a new ci version.

Refs: #187

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-12-06 19:11:42 +00:00
1 parent b2e547edd5
commit fac7ed47be
8 files changed
+39 -27

No files matched your search

+23
View File
@@ -49,6 +49,8 @@ repos:
hooks:
- id: check-toml
stages: ['pre-commit']
- id: check-json
stages: ['pre-commit']
- id: check-merge-conflict
stages: ['pre-commit']
@@ -114,6 +116,27 @@ repos:
require_serial: true
stages: ['pre-push']
# Pre-push only: the suite takes minutes. Lint runs it by id. The uncreatable GIT_DIR makes a
# git fixture that keeps the caller's GIT_* fail instead of writing to this repository.
- id: script-tests
name: A script change passes its tests in tests/scripts (scripts/AGENTS.md)
description: python3 -m unittest discover -s tests/scripts
entry: env GIT_DIR=/dev/null/not-a-repo python3 -m unittest discover -s tests/scripts
language: system
files: ^(scripts/|tests/scripts/|roles/[^/]+/meta/)
pass_filenames: false
stages: ['pre-push']
# always_run: its inputs span workflows, Dockerfiles and docs/images, and it fails on a missing one.
- id: check-image-pins
name: Image pins name an image of the image.yml matrix, which has its job image, labels and docs (images/AGENTS.md)
description: python3 scripts/check_image_versions.py pins
entry: python3 scripts/check_image_versions.py pins
language: system
pass_filenames: false
always_run: true
stages: ['pre-commit']
# SECURITY.md's accepted risks rest on the Collection shipping roles only. It sits before
# ansible-lint, whose fail_fast would otherwise hide this message.
- id: refuse-plugins