Refs #113. - .pre-commit-config.yaml: every hook repo is pinned by commit SHA with the release in a `# frozen:` comment, so a moved tag cannot change the code a hook environment is built from. - requirements-dev.lock: hashed lock of requirements-dev.txt. Installs use `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt` (dev-setup.sh, the ci image, the fallback install of Lint and Build): pip refuses an unhashed package and any disagreement between the two files. - scripts/lock-requirements.sh regenerates the lock (pinned pip and pip-tools, --upgrade mode). - renovate.json: the pip-compile manager replaces pip_requirements for the lock, plus a weekly, never automerged lock-file maintenance PR for transitive packages. Not yet dry-run on Renovate. - check_bot_pr_diff.py accepts `rev: <sha> # frozen: <tag>` and lock entries, hashes and plain comments, but not a changed pip-compile header command. - ci image 0.2.18 -> 0.2.19 (image inputs changed).
121 lines
5.0 KiB
YAML
121 lines
5.0 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: 91ab4bf57e58b32adf1a122681f6ebe164d081c8 # frozen: v4.4.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: ef6cf06c079dd6b299dfc720b0f14400c9d168e1 # frozen: 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: 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']
|
|
|
|
# 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
|