feat(ci): pin hook revisions by SHA and install dev tools from a hashed lock
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:
1 parent
212dd7aea8
commit
1184938f1e
21 files changed
+1648
-36
No files matched your search
@@ -9,7 +9,7 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
|
||||
* requirements-dev.txt: pinned `name==version` lines, the same packages before and after;
|
||||
* requirements.yml and extensions/molecule/requirements.yml: `version:` lines (the collection
|
||||
names, and every other line, stay);
|
||||
* .pre-commit-config.yaml: `rev:` lines;
|
||||
* .pre-commit-config.yaml: `rev:` lines (a tag, or a commit SHA with its `# frozen: <tag>` comment);
|
||||
* images/<name>/Dockerfile: the tag and digest of FROM lines (the image name stays), and
|
||||
the `uv==<version>` token of a line that holds one;
|
||||
* .gitea/workflows/image.yml: the matrix `version:` lines, and the tag and digest of the
|
||||
@@ -49,7 +49,9 @@ PREFIX = "renovate/"
|
||||
TAG = r"[A-Za-z0-9._-]+"
|
||||
PIN = re.compile(rf"(git\.rkdr\.net/mortis/[a-z0-9._-]+):{TAG}@sha256:[0-9a-f]{{64}}")
|
||||
REQ_LINE = re.compile(r"^([A-Za-z0-9][A-Za-z0-9._-]*)==[0-9][0-9A-Za-z.+!_-]*$")
|
||||
REV_LINE = re.compile(r"^\s*rev:\s*\S+\s*$")
|
||||
# A hook `rev:` is a tag or a commit SHA; a SHA carries its release in a `# frozen: <tag>` comment.
|
||||
# Nothing else may trail it, so the comment cannot hide a second instruction.
|
||||
REV_LINE = re.compile(r"^\s*rev:\s*\S+(?:\s+#\s*frozen:\s*\S+)?\s*$")
|
||||
VERSION_LINE = re.compile(
|
||||
r"""^\s*(?:-\s*)?version:\s*["']?(?P<v>[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?)["']?\s*(?:#.*)?$"""
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user