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

+15
View File
@@ -62,6 +62,11 @@ class RuleTest(unittest.TestCase):
" version: 14.1.0",
),
(".pre-commit-config.yaml", " rev: v1.0.0", " rev: v1.1.0"),
(
".pre-commit-config.yaml",
" rev: v1.0.0",
f" rev: {'a' * 40} # frozen: v1.1.0",
),
(
"images/ci/Dockerfile",
f"FROM ubuntu:24.04@{D1} AS os",
@@ -117,6 +122,16 @@ class RuleTest(unittest.TestCase):
),
("requirements-dev.txt", "reuse==6.2.0", "reuse @ https://x/y.tgz"),
(".pre-commit-config.yaml", " rev: v1.0.0", " repo: https://evil/x"),
(
".pre-commit-config.yaml",
" rev: v1.0.0",
f" rev: {'a' * 40} # frozen: v1.1.0 && evil",
),
(
".pre-commit-config.yaml",
" rev: v1.0.0",
f" rev: {'a' * 40} # note",
),
(
"images/ci/Dockerfile",
f"FROM ubuntu:24.04@{D1} AS os",