feat(ci): pin hook revisions by SHA and install dev tools from a hashed lock
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 1m37s
Molecule / molecule (pull_request) Successful in 5m26s

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, installed with
  `pip install --require-hashes` by scripts/dev-setup.sh, the ci image and the fallback
  install of the Lint and Build workflows.
- scripts/lock-requirements.sh regenerates the lock; scripts/check_requirements_lock.py
  (offline, a pre-commit hook) fails when it drifts from the direct pins.
- check_bot_pr_diff.py accepts a `rev:` line with a `# frozen:` comment and nothing else.
- ci image 0.2.16 -> 0.2.17 (image inputs changed).
This commit is contained in:
Dragonish committed 2026-11-14 15:14:39 +00:00
1 parent 212dd7aea8
commit 1184938f1e
21 files changed
+1648 -36

No files matched your search

+3 -3
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Sets up a local checkout for development: a virtualenv with the pinned tools
# (requirements-dev.txt, the versions CI runs), the pinned collections the roles call
# (requirements-dev.lock, the hashed lock of requirements-dev.txt: the versions CI runs), the pinned collections the roles call
# (requirements.yml) and git hooks that find the tools.
#
# scripts/dev-setup.sh # KAMINO_PYTHON=python3.13 scripts/dev-setup.sh to pick one
@@ -21,7 +21,7 @@
# of requirements.yml into .ansible/collections of this clone: scripts/ansible-lint.sh (the
# ansible-lint hook) resolves modules from there, so local lint sees the collection versions CI
# does (the ci image bakes requirements.yml) and not the control host's ~/.ansible. It is
# idempotent; run it again after changing requirements-dev.txt, requirements.yml or the hook types.
# idempotent; run it again after changing requirements-dev.txt or its lock, requirements.yml or the hook types.
set -euo pipefail
# ansible-core 2.22 (requirements-dev.txt) needs Python 3.13+. Renovate raises that pin, so
@@ -120,7 +120,7 @@ if [ -x .venv/bin/python ] && ! .venv/bin/python -c "$py_ok" 2>/dev/null; then
rm -rf "$root/.venv"
fi
[ -x .venv/bin/python ] || "$python" -m venv .venv
.venv/bin/pip install --quiet --disable-pip-version-check -r requirements-dev.txt
.venv/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock
.venv/bin/pre-commit install --install-hooks
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by