Add a pre-push hook that runs scripts/ansible-test-sanity.sh, so the Build job's sanity check, which ruff and the other hooks do not cover (it failed on a name only its pylint disallows), stops a push instead of the pull request. It is pre-push and not pre-commit because a cold run builds virtualenvs and needs the network; CI's pre-commit run does not run that stage, and a local system hook builds no environment. pre-push joins default_install_hook_types, and dev-setup.sh and its test treat it like the other two hook types, so its hook script also gets the virtualenv on PATH. Verified through git push --dry-run in a throwaway clone: a commit with a disallowed name inside a function is blocked (exit 1, the same pylint message as CI, failed to push), and the push passes once it is removed. Image input: .pre-commit-config.yaml is baked into the ci image, so ci 0.2.17 -> 0.2.18 (scripts/bump_image_versions.py). The new hook adds no hook environment and no layer size; the merge builds 0.2.18 and a pin PR follows. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
115 lines
4.1 KiB
YAML
115 lines
4.1 KiB
YAML
default_install_hook_types: [pre-commit, commit-msg, pre-push]
|
|
|
|
repos:
|
|
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
rev: v4.4.0
|
|
hooks:
|
|
- id: conventional-pre-commit
|
|
stages: [commit-msg]
|
|
|
|
- repo: https://github.com/gitleaks/gitleaks
|
|
rev: v8.30.1
|
|
hooks:
|
|
- id: gitleaks
|
|
stages: ['pre-commit']
|
|
|
|
- repo: https://github.com/adrienverge/yamllint
|
|
rev: v1.38.0
|
|
hooks:
|
|
- id: yamllint
|
|
args: [--strict]
|
|
stages: ['pre-commit']
|
|
|
|
# Python and shell scripts under scripts/ and tests/scripts/ (#112). ruff.toml holds the
|
|
# configuration. No --fix: a finding fails the hook instead of rewriting files in CI.
|
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
rev: v0.17.5
|
|
hooks:
|
|
- id: ruff-check
|
|
stages: ['pre-commit']
|
|
- id: ruff-format
|
|
stages: ['pre-commit']
|
|
|
|
# shellcheck-py ships the shellcheck binary as a wheel, so no system package is needed.
|
|
# Default severity, no .shellcheckrc. actionlint (below) covers the run: blocks of workflows.
|
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
rev: v0.11.0.1
|
|
hooks:
|
|
- id: shellcheck
|
|
stages: ['pre-commit']
|
|
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v6.0.0
|
|
hooks:
|
|
- id: check-toml
|
|
stages: ['pre-commit']
|
|
- id: check-merge-conflict
|
|
stages: ['pre-commit']
|
|
|
|
# Blocking. .gitea/actionlint.yaml declares the runner labels. The workflows use the
|
|
# github.* contexts (Gitea aliases them), because actionlint does not know gitea.*.
|
|
# actionlint runs shellcheck over run: blocks when shellcheck is on PATH.
|
|
- repo: https://github.com/rhysd/actionlint
|
|
rev: v1.7.12
|
|
hooks:
|
|
- id: actionlint
|
|
args: [-config-file, .gitea/actionlint.yaml]
|
|
files: ^\.gitea/workflows/.*\.ya?ml$
|
|
stages: ['pre-commit']
|
|
|
|
# ansible-lint and the changelog lint run from PATH (language: system): their
|
|
# versions are the pins in requirements-dev.txt, installed into a virtualenv by
|
|
# CI and locally. ansible-lint is the slowest hook, so fail_fast stops the run
|
|
# once it fails (a global fail_fast would hide every other failure).
|
|
- repo: local
|
|
hooks:
|
|
# REUSE compliance (licence files, SPDX data, REUSE.toml; docs/licensing.md in the
|
|
# environment repo). The wrapper tolerates only unused licence texts, see its docstring.
|
|
- id: reuse-lint
|
|
name: REUSE compliance
|
|
description: reuse lint, tolerating unused licence texts until the roles arrive
|
|
entry: python3 scripts/reuse_lint.py
|
|
language: system
|
|
pass_filenames: false
|
|
always_run: true
|
|
stages: ['pre-commit']
|
|
|
|
- id: antsibull-changelog-lint
|
|
name: Changelog fragments lint
|
|
description: antsibull-changelog lint over changelogs/
|
|
entry: antsibull-changelog lint
|
|
language: system
|
|
files: ^(changelogs/|galaxy\.yml$)
|
|
stages: ['pre-commit']
|
|
pass_filenames: false
|
|
|
|
# Pre-push only: the Build job's ansible-test sanity run, on HEAD (scripts/ansible-test-sanity.sh).
|
|
# The sanity tests carry their own pylint, pep8 and shellcheck settings, which the hooks above do
|
|
# not, and a cold run builds virtualenvs, so it is not a commit hook. CI's pre-commit run does not
|
|
# run this stage (the Build job runs sanity itself), and no hook environment is built for it.
|
|
- id: ansible-test-sanity
|
|
name: ansible-test sanity
|
|
description: ansible-test sanity on HEAD, as the Build job runs it
|
|
entry: scripts/ansible-test-sanity.sh
|
|
language: system
|
|
pass_filenames: false
|
|
always_run: true
|
|
require_serial: true
|
|
stages: ['pre-push']
|
|
|
|
- id: ansible-lint
|
|
name: ansible-lint
|
|
description: ansible-lint production profile, offline
|
|
entry: scripts/ansible-lint.sh
|
|
language: system
|
|
files: ^(roles/|plugins/|meta/|galaxy\.yml$|requirements\.yml$|\.ansible-lint$|\.yamllint$)
|
|
stages: ['pre-commit']
|
|
pass_filenames: false
|
|
require_serial: true
|
|
fail_fast: true
|
|
|
|
- repo: meta
|
|
hooks:
|
|
- id: check-hooks-apply
|
|
- id: check-useless-excludes
|