ci(images): assign image versions in CI and open the pin PR right after a push #340

Merged
Defame1297 merged 2 commits from ci/165-image-versions-in-ci into main 2026-11-23 21:34:28 +00:00
Owner

What and why

Closes #165

  • Versions come from CI, not from a hand edit.
    • Each image.yml matrix entry has a base: "MAJOR.MINOR" instead of version:. A person edits base only for a minor or major.
    • On main, the new scripts/next_image_version.py checksums the image's inputs: its build context, or the files its Dockerfile copies from the repository root (reusing check_image_versions.inputs_of).
    • It compares that checksum with the net.rkdr.mortis.inputs-sha256 label of the newest published <base>.N and prints <base>.N+1, or nothing when they match.
    • The job publishes that version and latest, with the checksum as a label, or builds nothing.
    • The tag lookup with the push credential now fails the job on anything but 404, so a published tag is never moved.
  • Where the script runs. It runs inside the image job's prepare step, from this commit's source archive.
    • python3 is installed next to curl and purged by the existing pristine-filesystem logic. The script runs with env -u PAT_USER -u PAT_TOKEN -u JOB_TOKEN, so the registry credential never reaches it.
    • It reads the registry anonymously (the images are public).
    • A separate job in the ci image would have put a ci pin in image.yml and depended on per-matrix needs outputs, which are unverified on this Gitea.
  • The pin PR opens right after a push. renovate.yml runs on workflow_run of Images, live, and only when conclusion == 'success'.
    • I read the Gitea v28.3.0 source (the server runs 28.3.0) to check that this fires. notifier_helper.go drops an event only when its doer is the Actions user. For workflow_run, the doer is the trigger user of the finished run, and Images runs only on a push or dispatch by a person. ToActionWorkflowRun sets conclusion. So the dispatch fallback is not needed.
    • zizmor exception: workflow_run: # zizmor: ignore[dangerous-triggers], with its reason in the comment above it. Images never runs on a pull request, and this job reads nothing from the run except its conclusion.
  • Removed: bump_image_versions.py and its tests, check_image_versions.py bump, Lint's bump step, Renovate's postUpgradeTasks and RENOVATE_ALLOWED_COMMANDS, and the bot-diff allowance for matrix version: lines. The bot-diff gate now also refuses a change to base:, and it still refuses a job_image: line moved to another entry.
  • Docs updated to drop the bump: images/AGENTS.md, .gitea/workflows/AGENTS.md, scripts/AGENTS.md, code-style.md, making-a-change.md, the three docs/images/*.md, renovate.json descriptions, and comments in lock-requirements.sh and images/ci/Dockerfile. The root AGENTS.md had no line on it.
  • No changelog fragment: a consumer of the Collection sees no change.

Soft limits (code-style.md):

  • image.yml (about 350 lines), check_image_versions.py (714, down from 834) and check_bot_pr_diff.py (355) were already over 200 lines.
  • This change keeps to the smallest edit, as the issue asks. The script's rewrite is #169.
  • The prepare step's comment block grows by 4 lines for the version step.
  • Existing tool ruled out: skopeo and crane could read the registry, but neither computes the input set from the Dockerfile. They would also be one more pinned download in a job that must leave its container pristine.

On the first merge, all three images republish once:

  • molecule-ubuntu2404 0.1.10, molecule-ubuntu2604 0.1.6, ci 0.2.39.
  • No published version has the checksum label yet, so their content is unchanged apart from the ci Dockerfile's comment fix.
  • Renovate should then open the pin PR for them.

Verified

  • python3 -m unittest discover -s tests/scripts: 221 tests pass.
    • New: test_next_image_version.py, covering version choice and what counts as an input change, written test-first.
    • Changed: check_image_versions (base matrix, bump removed) and check_bot_pr_diff (version and base lines refused).
  • pre-commit run --all-files: all hooks pass, including zizmor, actionlint and REUSE.
  • ansible-test sanity (pre-push hook) passes.
  • I ran the script on a git archive of this tree against the live registry (read-only). It prints 0.1.10, 0.1.6 and 0.2.39, each with a checksum, so the anonymous tag and label reads work.
  • A code review (standards and spec, two separate reviews) was run. Its findings are fixed: stale bump text in the docs and the ci Dockerfile, and one comment that narrated the change.

Not verified

  • Molecule did not run locally; it runs in CI.
  • The Images job itself has not run. Not checked:
    • that installing, running and purging python3 passes the pristine-filesystem check on both job containers (Debian's py3compile/py3clean, and possibly tzdata). If anything is left behind, the job fails before building.
    • the source archive download with the job token.
    • that kaniko writes the label.
    • that a second run with unchanged inputs builds nothing.
  • That Gitea actually starts Renovate after Images. I only read the source.
  • How long the pin PR takes to open after the image push. The proposal is 15 minutes; the number is the maintainer's, observed after the merge.
  • If one matrix image fails, the Images run's conclusion is failure and Renovate does not start; images that did publish then wait for the daily schedule.
  • Automerge after one maintainer approval (#210 point 1) depends on CODEOWNERS and the protection setting; this change does not touch it.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code:claude-opus-5-5

## What and why Closes #165 - **Versions come from CI, not from a hand edit.** - Each `image.yml` matrix entry has a `base: "MAJOR.MINOR"` instead of `version:`. A person edits `base` only for a minor or major. - On `main`, the new `scripts/next_image_version.py` checksums the image's inputs: its build context, or the files its Dockerfile copies from the repository root (reusing `check_image_versions.inputs_of`). - It compares that checksum with the `net.rkdr.mortis.inputs-sha256` label of the newest published `<base>.N` and prints `<base>.N+1`, or nothing when they match. - The job publishes that version and `latest`, with the checksum as a label, or builds nothing. - The tag lookup with the push credential now fails the job on anything but 404, so a published tag is never moved. - **Where the script runs.** It runs inside the image job's prepare step, from this commit's source archive. - `python3` is installed next to `curl` and purged by the existing pristine-filesystem logic. The script runs with `env -u PAT_USER -u PAT_TOKEN -u JOB_TOKEN`, so the registry credential never reaches it. - It reads the registry anonymously (the images are public). - A separate job in the `ci` image would have put a `ci` pin in `image.yml` and depended on per-matrix `needs` outputs, which are unverified on this Gitea. - **The pin PR opens right after a push.** `renovate.yml` runs on `workflow_run` of Images, live, and only when `conclusion == 'success'`. - I read the Gitea v28.3.0 source (the server runs 28.3.0) to check that this fires. `notifier_helper.go` drops an event only when its doer is the Actions user. For `workflow_run`, the doer is the trigger user of the finished run, and Images runs only on a push or dispatch by a person. `ToActionWorkflowRun` sets `conclusion`. So the dispatch fallback is not needed. - **zizmor exception:** `workflow_run: # zizmor: ignore[dangerous-triggers]`, with its reason in the comment above it. Images never runs on a pull request, and this job reads nothing from the run except its conclusion. - **Removed:** `bump_image_versions.py` and its tests, `check_image_versions.py bump`, Lint's bump step, Renovate's `postUpgradeTasks` and `RENOVATE_ALLOWED_COMMANDS`, and the bot-diff allowance for matrix `version:` lines. The bot-diff gate now also refuses a change to `base:`, and it still refuses a `job_image:` line moved to another entry. - **Docs updated** to drop the bump: `images/AGENTS.md`, `.gitea/workflows/AGENTS.md`, `scripts/AGENTS.md`, `code-style.md`, `making-a-change.md`, the three `docs/images/*.md`, `renovate.json` descriptions, and comments in `lock-requirements.sh` and `images/ci/Dockerfile`. The root `AGENTS.md` had no line on it. - **No changelog fragment:** a consumer of the Collection sees no change. **Soft limits (code-style.md):** - `image.yml` (about 350 lines), `check_image_versions.py` (714, down from 834) and `check_bot_pr_diff.py` (355) were already over 200 lines. - This change keeps to the smallest edit, as the issue asks. The script's rewrite is #169. - The prepare step's comment block grows by 4 lines for the version step. - **Existing tool ruled out:** `skopeo` and `crane` could read the registry, but neither computes the input set from the Dockerfile. They would also be one more pinned download in a job that must leave its container pristine. **On the first merge, all three images republish once:** - molecule-ubuntu2404 0.1.10, molecule-ubuntu2604 0.1.6, ci 0.2.39. - No published version has the checksum label yet, so their content is unchanged apart from the `ci` Dockerfile's comment fix. - Renovate should then open the pin PR for them. ## Verified - `python3 -m unittest discover -s tests/scripts`: 221 tests pass. - New: `test_next_image_version.py`, covering version choice and what counts as an input change, written test-first. - Changed: `check_image_versions` (base matrix, bump removed) and `check_bot_pr_diff` (version and base lines refused). - `pre-commit run --all-files`: all hooks pass, including zizmor, actionlint and REUSE. - `ansible-test sanity` (pre-push hook) passes. - I ran the script on a `git archive` of this tree against the live registry (read-only). It prints `0.1.10`, `0.1.6` and `0.2.39`, each with a checksum, so the anonymous tag and label reads work. - A code review (standards and spec, two separate reviews) was run. Its findings are fixed: stale bump text in the docs and the `ci` Dockerfile, and one comment that narrated the change. ## Not verified - Molecule did not run locally; it runs in CI. - The Images job itself has not run. Not checked: - that installing, running and purging `python3` passes the pristine-filesystem check on both job containers (Debian's `py3compile`/`py3clean`, and possibly `tzdata`). If anything is left behind, the job fails before building. - the source archive download with the job token. - that kaniko writes the label. - that a second run with unchanged inputs builds nothing. - That Gitea actually starts Renovate after Images. I only read the source. - How long the pin PR takes to open after the image push. The proposal is 15 minutes; the number is the maintainer's, observed after the merge. - If one matrix image fails, the Images run's conclusion is failure and Renovate does not start; images that did publish then wait for the daily schedule. - Automerge after one maintainer approval (#210 point 1) depends on CODEOWNERS and the protection setting; this change does not touch it. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code:claude-opus-5-5
Claude added this to the CI velocity (emergency) milestone 2026-11-23 21:16:05 +00:00
Defame1297 was assigned by Claude 2026-11-23 21:16:05 +00:00
Claude added 1 commit 2026-11-23 21:16:05 +00:00
ci(images): assign image versions in CI and open the pin PR right after a push
Build / build (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 0s
Molecule / molecule (pull_request) Canceled after 0s
b12c990b6a
The image.yml matrix holds a hand-edited base (MAJOR.MINOR) per image instead
of a version. On main, scripts/next_image_version.py compares a checksum of the
image's inputs with the inputs-sha256 label of the newest published <base>.N
and the job publishes <base>.N+1 when they differ, or builds nothing when they
match. A published tag is still never moved.

renovate.yml runs live on the successful completion of Images (workflow_run),
so the pin pull request opens minutes after a push instead of on the schedule.

Removed: bump_image_versions.py and its tests, check_image_versions.py bump,
Lint's bump step, Renovate's postUpgradeTasks, and the bot-diff allowance for
matrix version lines.

Closes #165

Assisted-by: Claude Code:claude-opus-5-5
CODEOWNERS rules requested review from Defame1297 2026-11-23 21:16:05 +00:00
Defame1297 added 1 commit 2026-11-23 21:18:09 +00:00
Merge branch 'main' into ci/165-image-versions-in-ci
Build / build (pull_request) Successful in 15s
Lint / lint (pull_request) Successful in 57s
Molecule / molecule (pull_request) Successful in 14m45s
e8ca2548a8
Defame1297 approved these changes 2026-11-23 21:19:36 +00:00
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-23 21:19:53 +00:00
Defame1297 merged commit 5af66ed941 into main 2026-11-23 21:34:28 +00:00
Defame1297 deleted branch ci/165-image-versions-in-ci 2026-11-23 21:34:28 +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#340