ci: check image pins and image version bumps in Lint #16

Merged
Defame1297 merged 4 commits from feat/ci-image-version-and-pin-check into main 2026-10-25 20:09:46 +00:00
Owner

What changed (head c3cd04e)

  • scripts/check_image_versions.py (no shebang, not executable, because ansible-test sanity rejects one on a non-module file):
    • pins mode: every git.rkdr.net/mortis/<name>:<version>@sha256:<digest> in the lint/build/molecule workflows must name an image in image.yml's build matrix, be well formed, and not be newer than the matrix version. Mentions are matched case-insensitively with an optional :port, a nested path and no tag, so Git.rkdr.net/mortis/ci:..., git.rkdr.net/Mortis/ci, git.rkdr.net:443/mortis/ci, git.rkdr.net/mortis/ci/sub and an untagged git.rkdr.net/mortis/ci are reported as malformed pins (URLs such as https://git.rkdr.net/mortis/kamino and SSH remotes are not mentions). lint.yml is a required consumer (error if missing); build.yml and molecule.yml are skipped when absent, and the success line lists the files checked.
    • bump <base-ref> mode: a diff against the merge-base that touches an image's inputs needs a higher version in the matrix; versions must not go backwards. Renames count as touching the old path. Paths are read with git diff -z as bytes; a path that is not valid UTF-8 fails with "path is not valid UTF-8".
    • The Dockerfile COPY/ADD reader fails closed with an error naming file and line on a source containing $, a quote or #, on an unparseable JSON form, and on a RUN --mount that binds the build context (cache/tmpfs/secret mounts and from= binds are fine). Continuation lines with trailing blanks after the backslash are joined; comment lines are skipped.
    • An empty or non-mapping image.yml says "image.yml is empty or not a mapping".
    • Strict semver, matrix validation, one ::error:: line per problem, no traceback.
    • Docstring "Known limits": merge-base collisions; tag-to-digest is a registry fact; renaming an image in the matrix in the same PR skips its bump check (the pins check still catches a stale pin); optional consumer files are skipped silently (now listed); duplicate YAML keys in a matrix entry are accepted; the COPY reader is not a Dockerfile parser.
  • tests/scripts/test_check_image_versions.py.
  • lint.yml: steps "Check image pins", "Check image versions were bumped" (pull_request only) and "Test the repository scripts".
  • galaxy.yml: tests/scripts added to build_ignore. Changelog fragment.

Verified

  • 34 unit tests pass locally (python3 -I -m unittest discover -s tests/scripts): the 24 earlier ones plus 10 new (pin spellings, URLs not mentions, fail-closed COPY sources and mounts, OK cases still pass, continuation with blanks, empty image.yml, non-UTF-8 path, empty image.yml via CLI, Dockerfile error with file and line, lint.yml required and consumers listed).
  • pins run on the real workflows of this branch: ok, 3 consumers listed.
  • ansible-test sanity --test pep8 --test pylint --test shebang run locally on the script and the test file: clean.
  • CI at this head, steps observed: Build job success (including ansible-test sanity); Lint job success with steps pre-commit, "Check image pins", "Check image versions were bumped", "Test the repository scripts", gitleaks scan, Conventional Commits; Molecule job success.

Not verified

  • Whether a tag really points at the pinned digest (a registry fact).
  • Bumps colliding with a newer bump already on main (documented limit).
  • Any Dockerfile construct beyond the ones listed (heredoc COPY, ARG-expanded sources other than $) is not parsed.

Merge order

Touches lint.yml and galaxy.yml, as do #15 (lint.yml), #17 (lint.yml) and #18 (galaxy.yml, lint.yml). Merge this first; the others need trivial rebases of the same lines.

🤖 Generated with Claude Code

## What changed (head c3cd04e) - `scripts/check_image_versions.py` (no shebang, not executable, because `ansible-test sanity` rejects one on a non-module file): - `pins` mode: every `git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` in the lint/build/molecule workflows must name an image in image.yml's build matrix, be well formed, and not be newer than the matrix version. Mentions are matched case-insensitively with an optional `:port`, a nested path and no tag, so `Git.rkdr.net/mortis/ci:...`, `git.rkdr.net/Mortis/ci`, `git.rkdr.net:443/mortis/ci`, `git.rkdr.net/mortis/ci/sub` and an untagged `git.rkdr.net/mortis/ci` are reported as malformed pins (URLs such as `https://git.rkdr.net/mortis/kamino` and SSH remotes are not mentions). lint.yml is a required consumer (error if missing); build.yml and molecule.yml are skipped when absent, and the success line lists the files checked. - `bump <base-ref>` mode: a diff against the merge-base that touches an image's inputs needs a higher version in the matrix; versions must not go backwards. Renames count as touching the old path. Paths are read with `git diff -z` as bytes; a path that is not valid UTF-8 fails with "path is not valid UTF-8". - The Dockerfile COPY/ADD reader fails closed with an error naming file and line on a source containing `$`, a quote or `#`, on an unparseable JSON form, and on a `RUN --mount` that binds the build context (cache/tmpfs/secret mounts and `from=` binds are fine). Continuation lines with trailing blanks after the backslash are joined; comment lines are skipped. - An empty or non-mapping image.yml says "image.yml is empty or not a mapping". - Strict semver, matrix validation, one `::error::` line per problem, no traceback. - Docstring "Known limits": merge-base collisions; tag-to-digest is a registry fact; renaming an image in the matrix in the same PR skips its bump check (the pins check still catches a stale pin); optional consumer files are skipped silently (now listed); duplicate YAML keys in a matrix entry are accepted; the COPY reader is not a Dockerfile parser. - `tests/scripts/test_check_image_versions.py`. - lint.yml: steps "Check image pins", "Check image versions were bumped" (pull_request only) and "Test the repository scripts". - galaxy.yml: `tests/scripts` added to build_ignore. Changelog fragment. ## Verified - 34 unit tests pass locally (`python3 -I -m unittest discover -s tests/scripts`): the 24 earlier ones plus 10 new (pin spellings, URLs not mentions, fail-closed COPY sources and mounts, OK cases still pass, continuation with blanks, empty image.yml, non-UTF-8 path, empty image.yml via CLI, Dockerfile error with file and line, lint.yml required and consumers listed). - `pins` run on the real workflows of this branch: ok, 3 consumers listed. - `ansible-test sanity --test pep8 --test pylint --test shebang` run locally on the script and the test file: clean. - CI at this head, steps observed: Build job success (including `ansible-test sanity`); Lint job success with steps pre-commit, "Check image pins", "Check image versions were bumped", "Test the repository scripts", gitleaks scan, Conventional Commits; Molecule job success. ## Not verified - Whether a tag really points at the pinned digest (a registry fact). - Bumps colliding with a newer bump already on main (documented limit). - Any Dockerfile construct beyond the ones listed (heredoc COPY, ARG-expanded sources other than `$`) is not parsed. ## Merge order Touches lint.yml and galaxy.yml, as do #15 (lint.yml), #17 (lint.yml) and #18 (galaxy.yml, lint.yml). Merge this first; the others need trivial rebases of the same lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-10-25 18:22:41 +00:00
ci: check image pins and image version bumps in Lint
Build / build (pull_request) Failing after 10s
Lint / lint (pull_request) Successful in 6s
Molecule / molecule (pull_request) Successful in 30s
a51090192e
Add scripts/check_image_versions.py (pins mode, and bump mode on pull requests) with
unit tests, and run both plus the scripts' tests in lint.yml. tests/scripts is added
to galaxy.yml build_ignore.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 18:51:56 +00:00
fix(ci): harden check_image_versions against renames, odd refs and parse errors
Build / build (pull_request) Failing after 11s
Lint / lint (pull_request) Successful in 8s
Molecule / molecule (pull_request) Successful in 32s
8a0c5bf3dd
Renamed or moved input files now count as touched (git diff --no-renames), so a
rename can no longer hide a changed image input. The base ref must be a plain ref
name and is passed after --end-of-options. Parse and git failures exit 1 with a
one-line message instead of a traceback. Prerelease versions compare per semver
(numeric identifiers numerically, numeric below alphanumeric). Whole-line YAML
comments are ignored when looking for pins.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 19:18:15 +00:00
fix(ci): make check_image_versions pass ansible-test sanity and harden its input handling
Build / build (pull_request) Successful in 8s
Lint / lint (pull_request) Successful in 7s
Molecule / molecule (pull_request) Successful in 35s
4fabe1358e
Sanity (pylint, shebang) failed the Build check: drop the shebang and the
executable bit, simplify a comprehension, define functions instead of
assigning lambdas and pass check= to every subprocess.run.

Read the changed files with git diff -z so non-ASCII paths are compared
unquoted. Validate the matrix shape (non-empty list of mappings, string
name/version/dockerfile/subpath, no duplicate names) with one-line errors.
Match semver with fullmatch and reject leading zeros. Let a pin end at
, ) ] } or a quote. Document the known limits.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 19:54:36 +00:00
fix(ci): make the image pin check fail closed on odd spellings and Dockerfile sources
Build / build (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 8s
Molecule / molecule (pull_request) Successful in 29s
c3cd04e013
Pin mentions are matched case-insensitively with an optional port, a nested path
and no tag, so a mis-spelled or untagged pin is reported instead of ignored. The
Dockerfile COPY/ADD reader raises an error naming file and line on a source with
a variable, quote or comment character and on a RUN --mount of the build context,
and joins continuation lines with trailing blanks. A non-UTF-8 diff path and an
empty image.yml get their own messages, lint.yml is a required consumer, the
success line lists the consumers checked, and the docstring states the known limits.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 approved these changes 2026-10-25 20:09:41 +00:00
Defame1297 merged commit f271730f6e into main 2026-10-25 20:09:46 +00:00
Defame1297 deleted branch feat/ci-image-version-and-pin-check 2026-10-25 20:09:46 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#16