Files
Kamino/.pre-commit-config.yaml
T
Defame1297andClaude Opus 5.5 e45b92551a ci: lint workflows with zizmor
Add zizmor (v1.32.0, pinned by SHA) as a pre-commit hook over
.gitea/workflows, offline at its default level; it fails on
pull_request_target and on ${{ }} expanded into run:. The ci image
bakes and smoke-tests the new hook environment, so its version moves
to 0.2.32.

image.yml drops `packages: write` and the job-token probe: Gitea 28
refuses the job token for organisation packages, and the latest build
used the org push token. One probe of that token now fails fast.

Refs #145

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-21 18:52:22 +00:00

133 lines
5.6 KiB
YAML

# Hook repositories are pinned by commit SHA, with the release in a `# frozen:` comment: a
# tag can be moved, a commit cannot, so a moved tag shows up as a failed fetch and not as
# new code in the hook environment (supply chain, ci image and contributors alike).
# Renovate's pre-commit manager keeps a frozen rev in its frozen form when it updates it (it never
# creates one). To pin by hand, list both refs and take the `^{}` (peeled) line when there is one,
# the plain line otherwise: `git ls-remote <repo> "refs/tags/<tag>" "refs/tags/<tag>^{}"`.
default_install_hook_types: [pre-commit, commit-msg, pre-push]
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: 33b50eb042bee26eac0ee96ad84aa9c1b4dccdd8 # frozen: v4.5.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/gitleaks/gitleaks
rev: 83d9cd684c87d95d656c1458ef04895a7f1cbd8e # frozen: v8.30.1
hooks:
- id: gitleaks
stages: ['pre-commit']
- repo: https://github.com/adrienverge/yamllint
rev: cba56bcde1fdd01c1deb3f945e69764c291a6530 # frozen: 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: 9026c9127e153371d7a78dfcb0c45ae2046a3d10 # frozen: v0.17.6
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: 745eface02aef23e168a8afb6b5737818efbea95 # frozen: v0.11.0.1
hooks:
- id: shellcheck
stages: ['pre-commit']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: 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: 914e7df21a07ef503a81201c76d2b11c789d3fca # frozen: v1.7.12
hooks:
- id: actionlint
args: [-config-file, .gitea/actionlint.yaml]
files: ^\.gitea/workflows/.*\.ya?ml$
stages: ['pre-commit']
# zizmor finds security problems in workflows (pull_request_target, ${{ }} expanded into
# run:). Its own files: pattern only matches .github/, so point it at .gitea/workflows.
# --offline: no network audits, so a run needs no token and gives the same result everywhere.
# Overriding args drops the hook's default, so --no-progress is repeated here.
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: 06a39750ec31860bb44f2acf67182c40016cd1e7 # frozen: v1.32.0
hooks:
- id: zizmor
args: [--no-progress, --offline]
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). 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