diff --git a/.gitea/workflows/renovate.yml b/.gitea/workflows/renovate.yml index 4a7011f..7cab213 100644 --- a/.gitea/workflows/renovate.yml +++ b/.gitea/workflows/renovate.yml @@ -51,12 +51,13 @@ jobs: RENOVATE_REPOSITORIES: ${{ github.repository }} RENOVATE_TOKEN: ${{ secrets.GITHUB_TOKEN }} RENOVATE_GIT_AUTHOR: "Renovate Bot " - RENOVATE_BINARY_SOURCE: install # postUpgradeTasks may run exactly this one command (anchored, no wildcard); the JSON # string holds a regex, hence the doubled backslash. RENOVATE_ALLOWED_COMMANDS: '["^python3 scripts/bump_image_versions\\.py origin/main$"]' LOG_LEVEL: ${{ github.event_name == 'workflow_dispatch' && 'debug' || 'info' }} - DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || 'false' }} + # Fail safe: only the schedule is 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 a dry run). + DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run != 'false' && 'true' || 'false' }} run: | if [ "$DRY_RUN" = "true" ]; then export RENOVATE_DRY_RUN=full diff --git a/CLAUDE.md b/CLAUDE.md index 3207c2a..6cdcbe4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -75,8 +75,8 @@ protection, or create tags: those are the operator's. `image.yml` (`scripts/bump_image_versions.py []`, idempotent, edits only the version line; `check_image_versions.py bump` then passes). The merge builds the image on `main`. PR 2 moves the consumers' `image:@sha256:` pins to that digest. - `renovate.json` runs the script as a `postUpgradeTasks` command (branch mode, file filter - `image.yml`; allowed by the one anchored regex in `RENOVATE_ALLOWED_COMMANDS` of `renovate.yml`), + `renovate.json` runs the script as a `postUpgradeTasks` command of a catch-all rule (matches every package, since + only the first upgrade of a branch counts; branch mode, file filter `image.yml`; allowed by the one anchored regex in `RENOVATE_ALLOWED_COMMANDS` of `renovate.yml`), so PR 1 carries the bump. PR 2 stays a hand edit until Phase 4 (pin-follow for `git.rkdr.net/mortis/*` is `enabled: false`; it needs a dry run against the registry first). - **Bot-diff gate:** the `lint` workflow runs `scripts/check_bot_pr_diff.py` on pull requests. A @@ -104,20 +104,28 @@ protection, or create tags: those are the operator's. - **Dry run:** Actions > Renovate > Run workflow with `dry_run=true` (the default for a manual run; sets `RENOVATE_DRY_RUN=full`, `LOG_LEVEL=debug`). Read the debug log: no branch or PR is created. The schedule runs live. -- **Unverified (settle with the first dry run and first live run):** that the job token can run Renovate on - Gitea (user lookup, branch push, PR creation); that `origin/main` exists and the clone is deep enough - for the merge-base in Renovate's checkout (the script fails with its one-line error otherwise); that - `python3` is in the image; that the `permissions:` block is enforced on this Gitea. Also unverified: - that PRs opened with the job token trigger the PR workflows. Gitea, like GitHub, may not start - workflows for events created by the job token, in which case the required `Lint` and `Build` checks - never run and automerge cannot work. -- **Open decision (do not pick without the operator):** if job-token PRs do not trigger CI, either - (a) push the PR with a user token held as a repo secret from a Kamino-only user, or (b) have - `renovate.yml` dispatch lint against the branch. Until decided, bot PRs need a manual run. +- **Open item: the first live run (do not enable automerge for bot PRs until one has shown it gets Lint and + Build).** The dry run proves the READS (lookups, config, branch plan) and, from the Renovate 44.161.0 + source (confirm by the log line for the post-upgrade task), also runs `postUpgradeTasks`. Only the first + LIVE run proves the writes: (1) that the job token can push a branch and open a PR. Renovate puts the + token in the clone URL, while `lint.yml` uses an http extraheader, so basic auth with the job token is + unproven; a fallback is to set `GIT_CONFIG_COUNT`/`GIT_CONFIG_KEY_0`/`GIT_CONFIG_VALUE_0` for the same + extraheader. (2) That PRs opened with the job token trigger the PR workflows: Gitea, like GitHub, may not + start workflows for events created by the job token, in which case the required `Lint` and `Build` + checks never run and automerge cannot work. If so, the decision is the operator's: either push the PR + with a user token held as a repo secret from a Kamino-only user, or have `renovate.yml` dispatch lint + against the branch; until then bot PRs need a manual run. (3) That bot PRs are held by `main`'s required + status checks (check the branch protection). Also confirm in the log: Renovate clones blobless with full + history, so `origin/main` exists for the script (source-based); `python3` is in the image; the + `permissions:` block is enforced on this Gitea; `github.head_ref` is populated (the gate fails closed + on an empty one, via `EVENT_NAME`). Safety net: a failing or disallowed post-upgrade command opens the + PR WITHOUT the bump plus a red `renovate/artifacts` status, and `check_image_versions.py bump` then + fails lint. +- **The workflow holds the runner's slot:** the `kamino-runner` host has a single slot (the label is + `kamino-docker`), and the Renovate job may run up to 30 minutes (`timeout-minutes`) from 03:17 UTC, so + Lint, Build and Molecule checks queue behind it. - **Not enabled yet:** credentials for the `git.rkdr.net` registry (`hostRules`) and pin-follow. The - `pre-commit` manager is beta. Unverified: that bot PRs are held by `main`'s required status checks - (check the branch protection before enabling automerge), and that `github.head_ref` is populated on - this Gitea (the gate fails closed on an empty one, via `EVENT_NAME`). + `pre-commit` manager is beta. - **Hand edits on a bot branch:** a commit pushed by hand to a `renovate/` branch makes Renovate treat the branch as modified: it stops rebasing it, so merge that pull request by hand. - **The guard runs from `main`:** the lint step extracts `scripts/` from `origin/main` and runs the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3b700b..9c37362 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,9 +36,10 @@ - `renovate.json` configures dependency bumps (minor and patch automerge, majors by hand). Renovate runs for this repository in `.gitea/workflows/renovate.yml` (daily cron on the Collection's own runner, with the workflow's job token; no cluster code involved). To dry-run after changing the - config: Actions > Renovate > Run workflow with `dry_run=true`, then read the debug log. Whether - pull requests opened with the job token start the PR workflows is unverified; if not, they need a - manual lint run (open decision, see CLAUDE.md). Pull requests from `renovate/` branches must pass + config: Actions > Renovate > Run workflow with `dry_run=true`, then read the debug log. The dry run + proves reads (and runs the post-upgrade task); whether the job token can push and open a pull + request, and whether such pull requests start the PR workflows, only the first live run shows + (open item, see CLAUDE.md); until then they may need a manual lint run. Pull requests from `renovate/` branches must pass `scripts/check_bot_pr_diff.py`, which only allows version, tag, digest and pin lines. - Workflows must not mention `git.rkdr.net/defame1297/` (the production image set); the `Check image pins` step fails if they do. diff --git a/renovate.json b/renovate.json index a16993d..0efaf2c 100644 --- a/renovate.json +++ b/renovate.json @@ -77,11 +77,9 @@ "automerge": true }, { - "description": "Image inputs (the ci and molecule-ubuntu2404 images): the PR also carries the PATCH bump of the image version in image.yml, made by scripts/bump_image_versions.py against origin/main (the base ref and clone depth in Renovate's checkout are verified by the first dry run). The command must match RENOVATE_ALLOWED_COMMANDS in renovate.yml exactly.", - "matchFileNames": [ - "requirements-dev.txt", - ".pre-commit-config.yaml", - "images/**" + "description": "Every update runs scripts/bump_image_versions.py against origin/main as a postUpgradeTasks command (the base ref and clone depth in Renovate's checkout are verified by the first dry run). The rule matches every package (matchPackageNames *, which strict validation requires as a selector) on purpose: with executionMode branch only the FIRST upgrade's postUpgradeTasks of a branch counts and a branch can carry several upgrades; the script is a no-op when no image input (requirements-dev.txt, .pre-commit-config.yaml, images/**) changed and otherwise makes the PATCH bump of the image version in image.yml. The command must match RENOVATE_ALLOWED_COMMANDS in renovate.yml exactly.", + "matchPackageNames": [ + "*" ], "postUpgradeTasks": { "commands": [ diff --git a/scripts/bump_image_versions.py b/scripts/bump_image_versions.py index 2d178ff..4df7b94 100644 --- a/scripts/bump_image_versions.py +++ b/scripts/bump_image_versions.py @@ -16,9 +16,11 @@ order; an entry that cannot be parsed unambiguously is an error); comments, quot the rest of the file are kept. Untracked files count as inputs unless git ignores them, so a cache under images/ must be in .gitignore. -It is meant to run later as a Renovate `postUpgradeTasks` command (Phase 2/3 of the -Renovate plan; renovate.json does not enable it yet), so a dependency bump that changes an -image input carries its version bump and passes the `bump` check without a human edit. +It runs as a Renovate `postUpgradeTasks` command: renovate.json sets it on a catch-all +packageRule (matches every package, executionMode branch, fileFilters limited to .gitea/workflows/image.yml), +allowed by RENOVATE_ALLOWED_COMMANDS of .gitea/workflows/renovate.yml. It is a no-op when no image +input changed, so a dependency bump that changes an image input carries its version bump and +passes the `bump` check without a human edit. Moving the consumers' pins to the digest the build produces stays a separate, later pull request (build on main, then the pin follow-up).