diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 3ac55be..d49b4a9 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -28,7 +28,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.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc + image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d env: PIP_DISABLE_PIP_VERSION_CHECK: "1" steps: diff --git a/.gitea/workflows/gitea-release-key.yml b/.gitea/workflows/gitea-release-key.yml index 0e50ffe..ea44cc6 100644 --- a/.gitea/workflows/gitea-release-key.yml +++ b/.gitea/workflows/gitea-release-key.yml @@ -44,7 +44,7 @@ jobs: # The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the # release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here. container: - image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc + image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d steps: # The container has no Node, so JavaScript actions such as actions/checkout # cannot run; clone with git and the job token. diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index a069946..c88fae1 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -31,7 +31,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.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc + image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d env: PIP_DISABLE_PIP_VERSION_CHECK: "1" PRE_COMMIT_HOME: /opt/pre-commit diff --git a/.gitea/workflows/molecule.yml b/.gitea/workflows/molecule.yml index 6358ab5..b77804e 100644 --- a/.gitea/workflows/molecule.yml +++ b/.gitea/workflows/molecule.yml @@ -53,7 +53,7 @@ jobs: env: # The tools and collections molecule runs with: the image Lint and Build use. CI_IMAGE: >- - git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc + git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d # Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run # one locally. MOLECULE_IMAGE: >- diff --git a/docs/adr/0002-self-built-ci-and-molecule-images.md b/docs/adr/0002-self-built-ci-and-molecule-images.md index f208c4a..3e58423 100644 --- a/docs/adr/0002-self-built-ci-and-molecule-images.md +++ b/docs/adr/0002-self-built-ci-and-molecule-images.md @@ -12,6 +12,7 @@ and pin updates. The choice is hard to undo once every workflow pins an image. - **We build our own images:** a `ci` image, and one Dockerfile per molecule image (one per Ubuntu release, and later the Debian 13 one). + Molecule's controller image is added by [ADR 0003](0003-molecule-controller-image.md). - **The molecule images bake in everything except what a role installs itself.** The test fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still downloaded, because that install path is what the test exercises. A converge is not kept off diff --git a/docs/adr/0003-molecule-controller-image.md b/docs/adr/0003-molecule-controller-image.md new file mode 100644 index 0000000..dc39877 --- /dev/null +++ b/docs/adr/0003-molecule-controller-image.md @@ -0,0 +1,60 @@ +# 0003. Molecule runs in its own controller image, not the `ci` image + +Status: accepted + +## Context + +[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI +tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli, +antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin +pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed +inside an image, so it runs every scenario. 9 of 18 `ci` pin pull requests over two weeks +were Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull +request. + +## Decision + +- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what + Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker + connection, and the collections of `requirements.yml` and + `extensions/molecule/requirements.yml`. +- **Its Python packages come from a requirements file and hash-pinned lock of its own.** +- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`. +- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by + `@sha256:`, moved by Renovate. This adds to ADR 0002's set of images; the + rest of ADR 0002 stands. + +## Reason + +A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A +`molecule-controller` pin pull request still runs every scenario, which is right: it changes +Molecule's tools. + +The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit, +a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection +bump is an input of both images, so it publishes two versions and two pin pull requests. + +The controller's requirements file and lock must not be on the selector's IGNORED list, so a +bump of ansible-core or molecule there runs every scenario before it merges. Today +`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no +scenario unless it edits `meta/runtime.yml`; this decision does not change that list. + +The implementation updates: `image.yml` (matrix, and its push `paths` unless the new files live +under `images/`), `molecule.yml`, +`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums), +`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and +`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the +`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each +molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`, +`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci` +Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the +[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after +they merge", which counts on the `ci` pin pull request running every scenario. + +## Not done + +- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE` + bump matters:** a heuristic package list inside a script that judges pull requests. +- **Status quo:** every Lint-only tool change keeps costing a full Molecule run. +- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs + but not the cause. diff --git a/docs/contributing/making-a-change.md b/docs/contributing/making-a-change.md index 3772e0d..fc74cbc 100644 --- a/docs/contributing/making-a-change.md +++ b/docs/contributing/making-a-change.md @@ -15,10 +15,23 @@ trailers, are in [ai-assistance.md](ai-assistance.md). *Reason:* every change reaches `main` through the Lint and Build checks and a reviewer. *Held by:* control: branch protection on `main`. - **Do not push to someone else's branch or to a bot's branch; put your change in a pull request of - your own.** Updating a branch from `main` with Gitea's update button is allowed. + your own.** Updating a branch from `main` with Gitea's update button is allowed under the next + two rules. *Reason:* a push changes a head its author already reviewed or scheduled to merge, and a hand-made commit on a `renovate/` branch makes Renovate stop rebasing it. *Held by:* aspirational. +- **Update a pull request's branch from `main` only when it is next to merge: reviewed, green on its + previous head, and the only branch being updated. After updating your own pull request, give it a + scheduled merge; merge anyone else's as [reviewing.md](reviewing.md) says.** + *Reason:* `main` blocks an outdated branch, so every update re-runs Lint, Build and Molecule, and + a new head cancels the run in progress; an update made while another pull request merges first is + wasted. + *Held by:* aspirational. +- **Never press the update button on a `renovate/` branch. When a Renovate pull request is next to + merge and behind `main`, tick the rebase/retry checkbox in its description; Renovate rebases it at + its next run.** + *Reason:* the update button adds a hand-made commit, and Renovate stops rebasing that branch. + *Held by:* aspirational. - **File an issue or open a pull request with the headings of the matching template in `.gitea/`, also when you file through the API, `tea` or an MCP server.** *Reason:* those routes skip the templates, and an agent's built-in body leaves out what review needs. diff --git a/renovate.json b/renovate.json index 6193547..702af45 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit.", + "description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.", "extends": [ "config:recommended", ":enablePreCommit" @@ -19,7 +19,7 @@ ], "automerge": true, "automergeType": "pr", - "prHourlyLimit": 5, + "prHourlyLimit": 0, "minimumReleaseAge": "3 days", "minimumReleaseAgeBehaviour": "timestamp-optional", "timezone": "UTC", @@ -90,7 +90,7 @@ ], "packageRules": [ { - "description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version.", + "description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version. Today every Dockerfile is FROM ubuntu, whose bumps join the manual ubuntu base images group below; this rule is the safety net for a future base image of another kind.", "matchManagers": [ "dockerfile" ], @@ -145,12 +145,18 @@ "allowedVersions": "<=26.10.1" }, { - "description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged, and kept in their own branch so the Dockerfile base-image bumps are not held back with them.", + "description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged. Their ubuntu bumps share one branch with the Dockerfile FROM bumps (ubuntu base images rule below), so that pull request is manual too: a group automerges only if every update in it does.", "matchFileNames": [ ".gitea/workflows/image.yml" ], - "automerge": false, - "additionalBranchPrefix": "job-container-" + "automerge": false + }, + { + "description": "The Dockerfile FROM digests and the image.yml job_image digests of one Ubuntu update move in one pull request, so the release pair stays in step and one Images run covers both.", + "matchPackageNames": [ + "ubuntu" + ], + "groupName": "ubuntu base images" }, { "description": "Safety net only: kaniko is pinned by layer digests in image.yml and no Renovate manager reads them, so it is updated by hand. If a manager ever starts to read it, its bumps are not automerged.", @@ -160,11 +166,15 @@ "automerge": false }, { - "description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:@sha256: pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above).", + "description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:@sha256: pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci and both molecule images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.", "matchPackageNames": [ "git.rkdr.net/mortis/**" ], - "automerge": true + "automerge": true, + "groupName": "own CI images", + "schedule": [ + "at any time" + ] }, { "description": "Look the pre-commit hook repositories up with git ls-remote (git-tags) instead of the GitHub API. This run has no GitHub token, and the github-tags datasource then either skips every hook (skipReason github-token-required, dry run 3880) or is refused at once with 403 rate limit (githubTokenWarn off, local run). git-tags needs no API and no credential, and it uses the dereferenced hash of an annotated tag, so the new rev is the commit, as pre-commit needs. The `# frozen:` form is kept by the manager's own replace template. It works only together with RENOVATE_GITHUB_TOKEN_WARN=false in renovate.yml: the token check runs after extraction and skips every github-tags dependency before a package rule can change its datasource (local run, Renovate 44.161.0). git-tags has no release timestamps, so minimumReleaseAge cannot delay a hook bump: hook bumps are never automerged, a person reviews each one.", @@ -177,16 +187,45 @@ "overrideDatasource": "git-tags", "overridePackageName": "https://github.com/{{{depName}}}", "automerge": false + }, + { + "description": "Lint and build tooling in one weekly pull request across requirements-dev.lock and the ci image's uv pin, so one ci image build instead of one per tool.", + "matchDatasources": [ + "pypi" + ], + "matchPackageNames": [ + "apm-cli", + "antsibull-changelog", + "galaxy-importer", + "reuse", + "pre-commit", + "uv" + ], + "groupName": "lint tooling" + }, + { + "description": "The pre-commit hooks in one weekly pull request; never automerged (rule above).", + "matchManagers": [ + "pre-commit" + ], + "groupName": "pre-commit hooks" } ], "lockFileMaintenance": { "enabled": true, "schedule": [ - "before 6am on monday" + "on monday" ], "automerge": false, "labels": [ "lock-file-maintenance" ] + }, + "schedule": [ + "on monday" + ], + "osvVulnerabilityAlerts": true, + "vulnerabilityAlerts": { + "automerge": false } }