Merge pull request 'ci(renovate): validate the config in Lint, bump Renovate's own image weekly, run on push to main' (#525) from ci/188-172-renovate-self-bump into main
Renovate / renovate (push) Successful in 29s
Renovate / renovate (push) Successful in 29s
Reviewed-on: #525 Reviewed-by: Defame1297 <[email protected]>
This commit was merged in pull request #525.
This commit is contained in:
commit
d6037df6e4
8 files changed
+254
-55
No files matched your search
@@ -39,7 +39,8 @@ issue.
|
||||
while a content check must see the content it is given. *Held:* review (`CODEOWNERS`).
|
||||
- **A pull request from a `renovate/` branch changes only version, tag, digest and pin lines**
|
||||
(tool pins with their lock entries and hashes, hook `rev:` lines, Dockerfile `FROM` tags and
|
||||
digests, `job_image:` pins, consumer image pins). In `pyproject.toml` only a pin's version
|
||||
digests, `job_image:` pins, consumer image pins, and the tag and digest of the Renovate image
|
||||
line of `renovate.yml` and of its copy in `lint.yml`). In `pyproject.toml` only a pin's version
|
||||
moves; in `uv.lock` only apm-cli moves, to that pin, with its files from PyPI by sha256, and
|
||||
every other package stays as it is.
|
||||
*Why:* the bot's minor and patch pull requests automerge, so they must not be able to change
|
||||
@@ -55,7 +56,7 @@ issue.
|
||||
## Lint and Build
|
||||
|
||||
- **Lint and Build run in the pinned `ci` image and compare the pin files with the checksums
|
||||
baked into it (`/opt/ci-pins.sha256`).** A pull request that changes `requirements-dev.txt`,
|
||||
baked into it (`/opt/ci-pins.sha256`)**, except Lint's `renovate-config` job (below). A pull request that changes `requirements-dev.txt`,
|
||||
`requirements-dev.lock`, `requirements.yml` or `.pre-commit-config.yaml` takes the slow path,
|
||||
which installs the pinned tools and collections.
|
||||
*Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds.
|
||||
@@ -71,6 +72,19 @@ issue.
|
||||
- **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
|
||||
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
|
||||
install. *Held:* review.
|
||||
- **Lint's `renovate-config` job runs `renovate-config-validator --strict --no-global` on
|
||||
`renovate.json`, in the same Renovate image as `renovate.yml`, on every run with no `if:`.**
|
||||
Renovate moves both pins in one pull request. *Why:* the config is checked by the Renovate
|
||||
that runs it, and a check that always reports can be required. *Held:* control:
|
||||
`test_the_renovate_image_pins_are_the_same` in `tests/scripts/test_check_bot_pr_diff.py` for
|
||||
the equal pins; review for the job.
|
||||
|
||||
## Renovate
|
||||
|
||||
- **Triggers:** a push to `main`, the daily schedule and a successful Images run are live; a
|
||||
manual dispatch is a dry run unless its input says otherwise. Runs share the `renovate`
|
||||
group without cancelling. *Why:* a run after each merge rebases the next bot pull request,
|
||||
and an Images run's pin pull request opens within minutes. *Held:* review.
|
||||
|
||||
## Molecule
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Lint
|
||||
# Runs only on the Collection's own runner (label kamino-docker, scoped to the mortis org).
|
||||
# No org secret is used: the only credential is the
|
||||
# job token (secrets.GITHUB_TOKEN), which is read-only for a fork pull request. No pull_request_target.
|
||||
# The tools come from the ci image (images/ci, built by image.yml): the pinned Python
|
||||
# The lint job's tools come from the ci image (images/ci, built by image.yml): the pinned Python
|
||||
# tools of requirements-dev.txt, the collections of requirements.yml and the hook
|
||||
# environments of .pre-commit-config.yaml are baked in. When a PR changes one of those
|
||||
# files the checksum check below fails and the job installs the pinned tools and
|
||||
@@ -148,3 +148,36 @@ jobs:
|
||||
echo "Checking $sha"
|
||||
pre-commit run --hook-stage commit-msg --commit-msg-filename "$MSG_FILE"
|
||||
done
|
||||
|
||||
# renovate.json checked by the validator of the Renovate that runs it. The image is a copy of
|
||||
# renovate.yml's pin (test_the_renovate_image_pins_are_the_same); the ci image has no Node.
|
||||
renovate-config:
|
||||
runs-on: kamino-docker
|
||||
# Ceiling only: it includes a cold pull of the large -full image after a bump.
|
||||
timeout-minutes: 15
|
||||
container:
|
||||
image: renovate/renovate:44.161.0-full@sha256:ddbf02e44b542343c9df696b88fd953f04cc3ee5f771221805ff8efb26595416
|
||||
steps:
|
||||
# The image runs as a non-root user, so the clone goes to the runner's temp directory.
|
||||
- name: Checkout the commit under test
|
||||
env:
|
||||
GIT_CONFIG_COUNT: "1"
|
||||
GIT_CONFIG_KEY_0: http.extraheader
|
||||
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
|
||||
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
REF: ${{ github.ref }}
|
||||
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
||||
run: |
|
||||
src="${RUNNER_TEMP:-/tmp}/renovate-config"
|
||||
git clone "$REPO_URL" "$src"
|
||||
cd "$src"
|
||||
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
|
||||
echo "Checked out $(git rev-parse HEAD)"
|
||||
|
||||
# A step of its own, so the clone credential (http.extraheader) is not in the environment
|
||||
# that reads renovate.json.
|
||||
# --no-global: renovate.json is a repository config, not the bot's global one.
|
||||
- name: Validate renovate.json
|
||||
run: |
|
||||
cd "${RUNNER_TEMP:-/tmp}/renovate-config"
|
||||
renovate-config-validator --strict --no-global renovate.json
|
||||
@@ -5,18 +5,21 @@ name: Renovate
|
||||
# The credential is the token of a Kamino-only bot user, held as
|
||||
# the repository secret RENOVATE_BOT_TOKEN (not an org secret: only image.yml may reference those).
|
||||
# The job token cannot be used: Renovate filters every pull request lookup by its own username,
|
||||
# which is the virtual user gitea-actions with the job token, and Gitea answers 400 "user does not
|
||||
# exist" (dry run 2445). No GitHub token exists (no RENOVATE_GITHUB_COM_TOKEN): the github-tags
|
||||
# datasource then skips every pre-commit hook (skipReason github-token-required, dry run 3880), and
|
||||
# unauthenticated GitHub API lookups are refused at once (403 rate limit). The hooks are looked up
|
||||
# with git ls-remote instead (renovate.json, packageRule overrideDatasource git-tags), which needs
|
||||
# RENOVATE_GITHUB_TOKEN_WARN=false below: the token check runs before package rules apply.
|
||||
# which is the virtual user gitea-actions with the job token, and Gitea refuses that user.
|
||||
# No GitHub token exists, so the pre-commit hooks are looked up with git ls-remote instead
|
||||
# (renovate.json, git-tags), which needs RENOVATE_GITHUB_TOKEN_WARN=false below.
|
||||
#
|
||||
# Dry run: Actions > Renovate > Run workflow, dry_run=true (the default for a manual run), then
|
||||
# read the debug log. The schedule runs live, and so does a successful Images run's completion, so
|
||||
# the pin pull request for a new image version opens within minutes of its push. Gitea starts a
|
||||
# workflow_run only for a run a person triggered, and its event carries no input or credential.
|
||||
# read the debug log. Every other trigger runs live: a push to main rebases the next bot pull
|
||||
# request, and an Images run's completion opens the pin pull request for a new image version.
|
||||
# Gitea starts a workflow_run only for a run a person triggered, and its event carries no input
|
||||
# or credential.
|
||||
on: # yamllint disable-line rule:truthy
|
||||
# Only one bot pull request merges per run when main must be up to date; a run after each merge
|
||||
# rebases the next one.
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# Images runs only on main (push, dispatch), and this job reads nothing from its run but the conclusion.
|
||||
workflow_run: # zizmor: ignore[dangerous-triggers]
|
||||
workflows: [Images]
|
||||
@@ -50,15 +53,17 @@ jobs:
|
||||
(github.repository == 'mortis/kamino' || github.repository == 'Mortis/Kamino') &&
|
||||
(github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
|
||||
runs-on: kamino-docker
|
||||
timeout-minutes: 30
|
||||
# A run takes seconds to about two minutes.
|
||||
timeout-minutes: 10
|
||||
# Docker Hub image, pinned by digest. The -full flavour ships python3 for the report check
|
||||
# below and pip-compile for lock refreshes. Hand-bumped: renovate.json
|
||||
# disables updates for this file. The image sets RENOVATE_BINARY_SOURCE=global, so pip-compile
|
||||
# runs on the image's own python (3.14.8 in 44.161.0) and ignores the Python that Renovate
|
||||
# reads from the lock header: that python's minor version must equal .python-version, or a lock
|
||||
# refresh rewrites the header (check_image_versions.py pins then fails the pull request). When
|
||||
# bumping this image, check its python first; RENOVATE_BINARY_SOURCE=install would make Renovate
|
||||
# install the header's python, but it also downloads tools at run time (pip-tools included).
|
||||
# below and pip-compile for lock refreshes. Renovate proposes its own bump weekly, never
|
||||
# automerged (renovate.json), and moves lint.yml's copy of this pin in the same pull request.
|
||||
# The image sets RENOVATE_BINARY_SOURCE=global, so pip-compile runs on the image's own python
|
||||
# and ignores the Python that Renovate reads from the lock header: that python's minor version
|
||||
# must equal .python-version, or a lock refresh rewrites the header (check_image_versions.py
|
||||
# pins then fails the pull request). Check the image's python before merging a bump;
|
||||
# RENOVATE_BINARY_SOURCE=install would make Renovate install the header's python, but it also
|
||||
# downloads tools at run time (pip-tools included).
|
||||
container:
|
||||
image: renovate/renovate:44.161.0-full@sha256:ddbf02e44b542343c9df696b88fd953f04cc3ee5f771221805ff8efb26595416
|
||||
steps:
|
||||
@@ -74,14 +79,17 @@ jobs:
|
||||
# No GitHub token exists, and the hooks go through git-tags (see the header). Without this
|
||||
# Renovate marks every github-tags dependency as skipped before the package rule applies.
|
||||
RENOVATE_GITHUB_TOKEN_WARN: "false"
|
||||
# Docker Hub refuses anonymous paging past page 10; at more pages renovate/renovate gets
|
||||
# no release timestamps, so its minimumReleaseAge would not apply.
|
||||
RENOVATE_DOCKER_MAX_PAGES: "10"
|
||||
# Renovate exits 0 when a repository run fails (e.g. the clone): with this it exits with
|
||||
# an error-specific code instead (7 for an external host error such as a failed clone).
|
||||
RENOVATE_EXIT_CODE_FOR_ERRORS: "true"
|
||||
# The JSON report is checked after the run (see below).
|
||||
RENOVATE_REPORT_TYPE: file
|
||||
LOG_LEVEL: ${{ github.event_name == 'workflow_dispatch' && 'debug' || 'info' }}
|
||||
# Fail safe: only the schedule and workflow_run are live. A manual dispatch is a dry run unless
|
||||
# the input is exactly the string "false" (an empty input from an API or CLI dispatch stays one).
|
||||
# Fail safe: a manual dispatch is a dry run unless the input is exactly the string "false"
|
||||
# (an empty input from an API or CLI dispatch stays one); every other trigger is live.
|
||||
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run != 'false' && 'true' || 'false' }}
|
||||
run: |
|
||||
if [ -z "$RENOVATE_TOKEN" ]; then
|
||||
@@ -90,7 +98,7 @@ jobs:
|
||||
fi
|
||||
# Git over HTTPS with the bot token. Renovate's own rewrite puts the token in the URL
|
||||
# (https://<token>@host/...), which git drops when the server redirects, and Gitea
|
||||
# redirected the clone (dry run 2439). The header is sent on every request to the host,
|
||||
# redirects the clone. The header is sent on every request to the host,
|
||||
# as lint.yml does with its token. Renovate does not pass GIT_CONFIG_* from its environment to git
|
||||
# (only an allowlist, util/exec/env.js), but it does pass HOME, so a global git config
|
||||
# is the path that reaches its git children. The token is read from the environment.
|
||||
|
||||
@@ -107,5 +107,6 @@ renovate.json dependency automation
|
||||
- Changing a workflow: read [.gitea/workflows/AGENTS.md](.gitea/workflows/AGENTS.md) first.
|
||||
- Changing an image or an image-smoke scenario: read [images/AGENTS.md](images/AGENTS.md) first.
|
||||
- Before writing an ADR: read [docs/adr/AGENTS.md](docs/adr/AGENTS.md) first.
|
||||
- Before changing `renovate.json`: read its rule descriptions, and test with `renovate --platform=local`
|
||||
at the version in `.gitea/workflows/renovate.yml`.
|
||||
- Before changing `renovate.json`: read its rule descriptions. Lint's `renovate-config` job checks
|
||||
its syntax; test a behaviour change with `renovate --platform=local` at the version in
|
||||
`.gitea/workflows/renovate.yml`.
|
||||
@@ -107,8 +107,18 @@ limit), [.gitea/workflows/AGENTS.md](../../.gitea/workflows/AGENTS.md) (workflow
|
||||
bot-diff check `scripts/check_bot_pr_diff.py`) and [docs/adr/AGENTS.md](../adr/AGENTS.md) (decision
|
||||
records).
|
||||
|
||||
- **Test a change to `renovate.json` before the merge with `renovate --platform=local`** (the version
|
||||
in `.gitea/workflows/renovate.yml`), which reads your checkout.
|
||||
- **Test a change to how Renovate behaves before the merge with `renovate --platform=local`** (the
|
||||
version in `.gitea/workflows/renovate.yml`), which reads your checkout. Syntax needs no local run.
|
||||
*Reason:* a dry run in Actions (Run workflow with `dry_run=true`) reads `renovate.json` from `main`,
|
||||
so it cannot test a pull request's change.
|
||||
*Held by:* review (`renovate.json` is under `CODEOWNERS`).
|
||||
*Held by:* for the syntax, Lint's `renovate-config` job (`renovate-config-validator --strict
|
||||
--no-global renovate.json`): a control once `Lint / renovate-config` is a required check, review
|
||||
until then; review for the behaviour (`renovate.json` is under `CODEOWNERS`).
|
||||
- **Every description in `renovate.json` is at most two short sentences: why the rule exists, plus
|
||||
how it works when that is not obvious.** Investigation notes stay in the pull request.
|
||||
*Reason:* the descriptions are read on every change to the config, and notes age into noise.
|
||||
*Held by:* review.
|
||||
- **A broken unattended merge is fixed with a test or a check; an automerge exception is added only
|
||||
when no test can catch it, and its description names the failure it prevents.**
|
||||
*Reason:* an exception costs a manual review on every later update, a test does not.
|
||||
*Held by:* review.
|
||||
+34
-17
@@ -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, and in uv.lock only the apm-cli bump to the pin in pyproject.toml (scripts/check_uv_lock.py). 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.",
|
||||
"description": "Run by .gitea/workflows/renovate.yml: minor and patch updates automerge once scripts/check_bot_pr_diff.py and CI pass, and those to code-owned files only once a code owner approves; majors, vulnerability fixes (which skip the release-age wait) and the exceptions below stay manual. Updates open on Mondays (UTC) after a 3-day release age, and an update with no release timestamp gets no wait.",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":enablePreCommit"
|
||||
@@ -60,7 +60,7 @@
|
||||
"customManagers": [
|
||||
{
|
||||
"customType": "regex",
|
||||
"description": "The uv pin that installs the build-stage Python interpreters of the ci and molecule-controller images (their Dockerfiles). It is an image input: the merge publishes a new version of each.",
|
||||
"description": "The uv pin that installs the build-stage Python of the ci and molecule-controller images. It is an image input: the merge publishes a new version of each.",
|
||||
"managerFilePatterns": [
|
||||
"/^images/ci/Dockerfile$/",
|
||||
"/^images/molecule-controller/Dockerfile$/"
|
||||
@@ -73,7 +73,7 @@
|
||||
},
|
||||
{
|
||||
"customType": "regex",
|
||||
"description": "The job container of each image of image.yml (matrix job_image, ubuntu by digest). kaniko unpacks the image over the job container, so its release must equal the Dockerfile's (check_image_versions.py pins). Tag and digest updates within a release arrive here; a new release is a deliberate edit of both (rule below disables major ubuntu updates). Never automerged: the job holds the registry push credential (image.yml rule below).",
|
||||
"description": "The ubuntu job container of each image in image.yml, whose release must equal its Dockerfile's because kaniko unpacks the image over it. Never automerged: the job holds the registry push credential (image.yml rule below).",
|
||||
"managerFilePatterns": [
|
||||
"/^\\.gitea/workflows/image\\.yml$/"
|
||||
],
|
||||
@@ -85,7 +85,7 @@
|
||||
},
|
||||
{
|
||||
"customType": "regex",
|
||||
"description": "The CONTROLLER_IMAGE (molecule-controller), MOLECULE_IMAGE and MOLECULE_IMAGE_<release> values of molecule.yml are a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Used by the pin-follow rule below.",
|
||||
"description": "The image pins of molecule.yml are multi-line `>-` scalars, which the github-actions manager does not read. Used by the pin-follow rule below.",
|
||||
"managerFilePatterns": [
|
||||
"/^\\.gitea/workflows/molecule\\.yml$/"
|
||||
],
|
||||
@@ -98,21 +98,28 @@
|
||||
],
|
||||
"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. 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.",
|
||||
"description": "Dockerfile base-image bumps automerge once a code owner approves (images/** is in CODEOWNERS); the Images workflow builds the new image after the merge, and the pin-follow pull request's CI then runs on it. Placed first so the majors rule below still turns automerge off.",
|
||||
"matchManagers": [
|
||||
"dockerfile"
|
||||
],
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"description": "The Renovate job container of renovate.yml runs with the job token: hand-bumped, never by the bot (the bot-diff check would refuse a change to that file anyway).",
|
||||
"matchFileNames": [
|
||||
".gitea/workflows/renovate.yml"
|
||||
"description": "Renovate's own image never automerges: its job runs with the write-capable bot token. One weekly pull request moves the pin in renovate.yml and lint.yml's copy together.",
|
||||
"matchDatasources": [
|
||||
"docker"
|
||||
],
|
||||
"enabled": false
|
||||
"matchPackageNames": [
|
||||
"renovate/renovate"
|
||||
],
|
||||
"schedule": [
|
||||
"on monday"
|
||||
],
|
||||
"minimumReleaseAge": "3 days",
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "A new Ubuntu release is a deliberate edit, never a bump. The molecule-ubuntu<NNNN> images are one release by name and by contract (extensions/molecule/image-smoke* assert it), and every image's job container must run the same release as its Dockerfile (check_image_versions.py pins), so a base-image major in one file alone would fail the check or the build. Tag and digest updates within a release still arrive.",
|
||||
"description": "A new Ubuntu release is a deliberate edit, never a bump: each molecule-ubuntu<NNNN> image is one release by contract, and each job container must run its Dockerfile's release. Tag and digest updates within a release still arrive.",
|
||||
"matchPackageNames": [
|
||||
"ubuntu"
|
||||
],
|
||||
@@ -132,7 +139,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "ansible-core and ansible-lint move together (the lint rules follow the core version). Minor and patch bumps automerge like the rest, majors are manual. A new ansible-core minor can bring new sanity findings: the shared tests/sanity/ignore-common.txt covers the known ones, and the Build check (ansible-test sanity) is the gate, so a bump that shows new findings stays red and is not merged. The group spans requirements-dev.lock and requirements-molecule.lock, so one pull request moves both ansible-core pins, which check_image_versions.py pins holds equal.",
|
||||
"description": "ansible-core and ansible-lint move together, because the lint rules follow the core version. One pull request moves the ansible-core pins of both locks, which check_image_versions.py pins holds equal.",
|
||||
"groupName": "ansible tooling",
|
||||
"matchDatasources": [
|
||||
"pypi"
|
||||
@@ -143,7 +150,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Hold ansible-lint at the newest version galaxy-importer allows. galaxy-importer 0.4.44 (the newest release, used by the Build job) declares ansible-lint<=26.10.1, so a pin above that makes pip fail with ResolutionImpossible and Lint and Build go red (seen on the 26.11.0 bump). Remove this rule, and raise the cap, once a galaxy-importer release lifts its ansible-lint limit.",
|
||||
"description": "Hold ansible-lint at the newest version galaxy-importer allows, or pip cannot install Lint's and Build's tools. Raise or remove the cap once galaxy-importer lifts its ansible-lint limit.",
|
||||
"matchDatasources": [
|
||||
"pypi"
|
||||
],
|
||||
@@ -153,28 +160,38 @@
|
||||
"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. 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.",
|
||||
"description": "The job containers of image.yml hold the registry push credential while the image job runs, so their bumps never automerge. Their ubuntu bumps share a branch with the Dockerfile FROM bumps, so that group is manual too.",
|
||||
"matchFileNames": [
|
||||
".gitea/workflows/image.yml"
|
||||
],
|
||||
"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.",
|
||||
"description": "The Dockerfile FROM and image.yml job_image digests of one Ubuntu update move in one pull request, so each 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.",
|
||||
"description": "Safety net: kaniko is pinned by layer digests that no manager reads, so it is updated by hand. If a manager ever reads it, its bumps do not automerge.",
|
||||
"matchPackageNames": [
|
||||
"/kaniko/"
|
||||
],
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> 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, molecule-controller and both molecule target 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.",
|
||||
"description": "Our own images are built from main by the Images workflow, so there is no third-party release to wait for. Docker only, so another kind of dependency from this organisation keeps the wait.",
|
||||
"matchDatasources": [
|
||||
"docker"
|
||||
],
|
||||
"matchPackageNames": [
|
||||
"git.rkdr.net/mortis/**"
|
||||
],
|
||||
"minimumReleaseAge": "0 days"
|
||||
},
|
||||
{
|
||||
"description": "Moves the pins of our own images in the workflows to the newest published version in one pull request at any time, so main catches up minutes after an Images run. It automerges once a code owner approves (CODEOWNERS), after its own Lint, Build and Molecule run on the new images.",
|
||||
"matchPackageNames": [
|
||||
"git.rkdr.net/mortis/**"
|
||||
],
|
||||
@@ -185,7 +202,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"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.",
|
||||
"description": "Look the pre-commit hooks up with git ls-remote (git-tags), because this run has no GitHub token; it needs RENOVATE_GITHUB_TOKEN_WARN=false in renovate.yml. git-tags has no release timestamps, so no wait applies and a person reviews every hook bump.",
|
||||
"matchManagers": [
|
||||
"pre-commit"
|
||||
],
|
||||
|
||||
@@ -25,8 +25,11 @@ When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only
|
||||
`job_image: ubuntu:...@sha256:...` lines (the name stays); CI assigns the image versions
|
||||
and a human sets the matrix `base:`, so neither is the bot's to change;
|
||||
* .gitea/workflows/{lint,build,molecule,gitea-release-key}.yml: the version and digest of a
|
||||
`git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` pin (the name stays), including
|
||||
the MOLECULE_IMAGE value.
|
||||
`git.rkdr.net/mortis/<name>:<version>@sha256:<digest>` pin, in place (the name stays),
|
||||
including the MOLECULE_IMAGE value;
|
||||
* .gitea/workflows/renovate.yml, and lint.yml's copy of it: the version and digest of the
|
||||
`image: renovate/renovate:<version>-full@sha256:<digest>` line, in place; the name and the
|
||||
`-full` flavour stay (the job's report check needs the python3 that only -full ships).
|
||||
|
||||
Every other file, every other line, an added, deleted or mode-changed file fails, with one
|
||||
`::error::` line per offending file. renovate.json itself is not allowed: the bot does not
|
||||
@@ -73,6 +76,11 @@ UV_TOKEN = re.compile(r"\buv==[0-9][0-9A-Za-z.+!_-]*")
|
||||
UBUNTU_LINE = re.compile(
|
||||
rf"^(\s*job_image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$"
|
||||
)
|
||||
RENOVATE_LINE = re.compile(
|
||||
r"^(\s*image:\s*renovate/renovate:)[0-9]+(?:\.[0-9]+)*(-full)@sha256:[0-9a-f]{64}\s*$"
|
||||
)
|
||||
RENOVATE_WORKFLOW = ".gitea/workflows/renovate.yml"
|
||||
LINT_WORKFLOW = ".gitea/workflows/lint.yml"
|
||||
DOCKERFILE = re.compile(r"images/[^/]+/Dockerfile")
|
||||
COLLECTION_PINS = {"requirements.yml", "extensions/molecule/requirements.yml"}
|
||||
# Lint's and the molecule-controller image's requirements, each with its pip-compile lock.
|
||||
@@ -80,7 +88,6 @@ REQUIREMENTS = {"requirements-dev.txt", "requirements-molecule.txt"}
|
||||
LOCKS = {"requirements-dev.lock", "requirements-molecule.lock"}
|
||||
UV_LOCK = "uv.lock"
|
||||
CONSUMERS = {
|
||||
".gitea/workflows/lint.yml",
|
||||
".gitea/workflows/build.yml",
|
||||
".gitea/workflows/molecule.yml",
|
||||
".gitea/workflows/gitea-release-key.yml",
|
||||
@@ -183,6 +190,28 @@ def reduce_pin(line):
|
||||
return reduced if PIN.search(line) else None
|
||||
|
||||
|
||||
def reduce_renovate_image(line):
|
||||
m = RENOVATE_LINE.match(line)
|
||||
return m[1] + "X" + m[2] if m else None
|
||||
|
||||
|
||||
def reduce_lint_yml(line):
|
||||
# Lint also validates renovate.json in a copy of renovate.yml's image.
|
||||
return reduce_pin(line) or reduce_renovate_image(line)
|
||||
|
||||
|
||||
MORTIS_PIN = (reduce_pin, "an image pin of the mortis registry")
|
||||
# The workflows whose image lines a bot moves: (reduce_line, what may change).
|
||||
WORKFLOW_PINS = {
|
||||
**dict.fromkeys(CONSUMERS, MORTIS_PIN),
|
||||
LINT_WORKFLOW: (
|
||||
reduce_lint_yml,
|
||||
"an image pin of the mortis registry or the Renovate image line",
|
||||
),
|
||||
RENOVATE_WORKFLOW: (reduce_renovate_image, "the Renovate image line"),
|
||||
}
|
||||
|
||||
|
||||
def file_problem(path, removed, added):
|
||||
"""One-line reason why the change to `path` is not allowed for a bot, or None."""
|
||||
if path in REQUIREMENTS:
|
||||
@@ -216,10 +245,8 @@ def file_problem(path, removed, added):
|
||||
reduce_image_yml,
|
||||
"a `job_image:` ubuntu pin",
|
||||
)
|
||||
if path in CONSUMERS:
|
||||
return same_shape(
|
||||
removed, added, reduce_pin, "an image pin of the mortis registry"
|
||||
)
|
||||
if path in WORKFLOW_PINS:
|
||||
return same_shape(removed, added, *WORKFLOW_PINS[path])
|
||||
return "is not a file a bot pull request may change"
|
||||
|
||||
|
||||
@@ -268,7 +295,8 @@ def parse_patch(text):
|
||||
|
||||
def moved_problem(removed, added):
|
||||
"""A reason when a changed line changes position, else None; both lists are (line number, line).
|
||||
A `job_image:` pin moved to another matrix entry would change which job runs on it."""
|
||||
A `job_image:` pin moved to another matrix entry, or a workflow's image line moved to another
|
||||
job, would change which job runs on it."""
|
||||
if [n for n, unused in removed] != [n for n, unused in added]:
|
||||
return "moves or deletes a line (the changed lines must stay where they are)"
|
||||
return None
|
||||
@@ -319,7 +347,7 @@ def check(entries, patch_of, show=None):
|
||||
[line for unused, line in removed],
|
||||
[line for unused, line in added],
|
||||
)
|
||||
if not reason and path == civ.MATRIX_FILE:
|
||||
if not reason and (path == civ.MATRIX_FILE or path in WORKFLOW_PINS):
|
||||
reason = moved_problem(removed, added)
|
||||
if reason:
|
||||
problems.append(f"{path}: {reason}")
|
||||
|
||||
@@ -16,6 +16,8 @@ import check_bot_pr_diff as cbd
|
||||
from test_check_uv_lock import APM_NEW, APM_OLD, CLICK_OLD, UV_LOCK, uv_files
|
||||
|
||||
D1, D2 = "sha256:" + "a" * 64, "sha256:" + "b" * 64
|
||||
RENOVATE_OLD = f" image: renovate/renovate:44.161.0-full@{D1}"
|
||||
RENOVATE_NEW = f" image: renovate/renovate:44.170.2-full@{D2}"
|
||||
FILES = {
|
||||
"requirements-dev.txt": "# pins\nansible-core==2.19.14\nreuse==6.2.0\n",
|
||||
"requirements.yml": "---\ncollections:\n - name: community.general\n version: 14.0.0\n",
|
||||
@@ -28,7 +30,14 @@ FILES = {
|
||||
" container:\n image: ${{ matrix.job_image }}\n"
|
||||
" steps:\n - run: echo ok\n"
|
||||
),
|
||||
".gitea/workflows/lint.yml": f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n",
|
||||
".gitea/workflows/lint.yml": (
|
||||
f"container:\n image: git.rkdr.net/mortis/ci:0.2.0@{D1}\nrun: echo a\n"
|
||||
f"jobs:\n renovate-config:\n container:\n{RENOVATE_OLD}\n"
|
||||
),
|
||||
".gitea/workflows/renovate.yml": (
|
||||
f"jobs:\n renovate:\n container:\n{RENOVATE_OLD}\n"
|
||||
" steps:\n - env:\n LOG_LEVEL: info\n run: renovate\n"
|
||||
),
|
||||
".gitea/workflows/molecule.yml": f"env:\n MOLECULE_IMAGE: >-\n git.rkdr.net/mortis/mol:0.1.0@{D1}\n",
|
||||
"renovate.json": "{}\n",
|
||||
"pyproject.toml": '[project]\nrequires-python = ">=3.11"\n\n[dependency-groups]\ndev = ["apm-cli==0.39.3"]\n',
|
||||
@@ -228,6 +237,8 @@ class RuleTest(unittest.TestCase):
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.1@{D2}",
|
||||
),
|
||||
(".gitea/workflows/renovate.yml", RENOVATE_OLD, RENOVATE_NEW),
|
||||
(".gitea/workflows/lint.yml", RENOVATE_OLD, RENOVATE_NEW),
|
||||
]
|
||||
for path, old, new in cases:
|
||||
self.assertIsNone(self.problem(path, old, new), (path, old, new))
|
||||
@@ -311,11 +322,55 @@ class RuleTest(unittest.TestCase):
|
||||
f" image: git.rkdr.net/defame1297/ci:0.2.0@{D1}",
|
||||
),
|
||||
("renovate.json", "{}", '{"a": 1}'),
|
||||
(
|
||||
".gitea/workflows/renovate.yml",
|
||||
" run: renovate",
|
||||
" run: evil",
|
||||
),
|
||||
(
|
||||
".gitea/workflows/renovate.yml",
|
||||
" LOG_LEVEL: info",
|
||||
" LOG_LEVEL: debug",
|
||||
),
|
||||
(
|
||||
".gitea/workflows/renovate.yml",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.1@{D2}",
|
||||
),
|
||||
(
|
||||
".gitea/workflows/lint.yml",
|
||||
f" image: git.rkdr.net/mortis/ci:0.2.0@{D1}",
|
||||
RENOVATE_NEW,
|
||||
),
|
||||
("roles/x/tasks/main.yml", "a", "b"),
|
||||
]
|
||||
for path, old, new in cases:
|
||||
self.assertIsNotNone(self.problem(path, old, new), (path, old, new))
|
||||
|
||||
def test_the_renovate_image_pins_are_the_same(self):
|
||||
# Lint validates renovate.json in the image renovate.yml runs; one bot PR moves both copies.
|
||||
pins = []
|
||||
for name in ("renovate.yml", "lint.yml"):
|
||||
text = (SCRIPTS.parent / ".gitea/workflows" / name).read_text()
|
||||
lines = [line for line in text.splitlines() if "renovate/renovate:" in line]
|
||||
self.assertEqual(len(lines), 1, (name, lines))
|
||||
self.assertIsNotNone(cbd.RENOVATE_LINE.match(lines[0]), (name, lines[0]))
|
||||
pins.append(lines[0].strip())
|
||||
self.assertEqual(pins[0], pins[1])
|
||||
|
||||
def test_the_renovate_image_keeps_its_name_flavour_and_digest(self):
|
||||
for path in (".gitea/workflows/renovate.yml", ".gitea/workflows/lint.yml"):
|
||||
for new in (
|
||||
RENOVATE_NEW.replace("renovate/renovate", "evil/renovate"),
|
||||
RENOVATE_NEW.replace("-full@", "@"),
|
||||
RENOVATE_NEW.replace("-full@", "-slim@"),
|
||||
RENOVATE_NEW.replace(f"@{D2}", ""),
|
||||
RENOVATE_NEW.replace("44.170.2", "latest"),
|
||||
RENOVATE_NEW + " # evil",
|
||||
RENOVATE_NEW.replace(" image:", " image:"),
|
||||
):
|
||||
self.assertIsNotNone(self.problem(path, RENOVATE_OLD, new), (path, new))
|
||||
|
||||
def test_job_image_lines_cannot_be_added_removed_or_moved(self):
|
||||
path = ".gitea/workflows/image.yml"
|
||||
line = f" job_image: ubuntu:24.04@{D1}"
|
||||
@@ -565,6 +620,39 @@ class RepoTest(unittest.TestCase):
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("5 file(s)", out)
|
||||
|
||||
def test_a_renovate_self_bump_passes(self):
|
||||
self.edit(".gitea/workflows/renovate.yml", RENOVATE_OLD, RENOVATE_NEW)
|
||||
self.edit(".gitea/workflows/lint.yml", RENOVATE_OLD, RENOVATE_NEW)
|
||||
self.commit("bot")
|
||||
code, out, err = self.gate()
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("2 file(s)", out)
|
||||
|
||||
def test_an_added_renovate_image_line_is_refused(self):
|
||||
for path in (".gitea/workflows/renovate.yml", ".gitea/workflows/lint.yml"):
|
||||
self.assertIsNotNone(cbd.file_problem(path, [], [RENOVATE_NEW]), path)
|
||||
self.assertIsNotNone(
|
||||
cbd.file_problem(path, [RENOVATE_OLD], [RENOVATE_NEW, RENOVATE_NEW]),
|
||||
path,
|
||||
)
|
||||
|
||||
def assert_moved_line_refused(self, path, anchor):
|
||||
self.edit(path, f"{RENOVATE_OLD}\n", "")
|
||||
self.edit(path, anchor, f"{anchor}{RENOVATE_NEW}\n")
|
||||
self.commit("bot")
|
||||
code, _unused, err = self.gate()
|
||||
self.assertEqual(code, 1, err)
|
||||
self.assertIn(path, err)
|
||||
self.assertIn("moves or deletes a line", err)
|
||||
|
||||
def test_a_moved_renovate_image_line_is_refused(self):
|
||||
self.assert_moved_line_refused(
|
||||
".gitea/workflows/renovate.yml", " run: renovate\n"
|
||||
)
|
||||
|
||||
def test_a_moved_image_line_in_lint_yml_is_refused(self):
|
||||
self.assert_moved_line_refused(".gitea/workflows/lint.yml", "run: echo a\n")
|
||||
|
||||
def bump_apm_cli(self):
|
||||
"""The change Renovate makes for apm-cli 0.39.4, as uv 0.13.1 writes it."""
|
||||
self.edit("pyproject.toml", "apm-cli==0.39.3", "apm-cli==0.39.4")
|
||||
|
||||
Reference in new issue
Block a user