ci(renovate): run Renovate from a cron workflow on the Collection runner #20
No files matched your search
@@ -0,0 +1,65 @@
|
||||
name: Renovate
|
||||
|
||||
# Dependency updates for this repository (renovate.json). Runs on the Collection's own runner
|
||||
# (label kamino-docker, the untrusted side), never in the production cluster: code from this
|
||||
# repository must not run there. The only credential is the job token (secrets.GITHUB_TOKEN);
|
||||
# no org secret is referenced (only image.yml may). Unauthenticated GitHub lookups for the
|
||||
# github.com pre-commit hooks may hit rate limits: best effort, no RENOVATE_GITHUB_COM_TOKEN exists.
|
||||
#
|
||||
# Dry run: Actions > Renovate > Run workflow, dry_run=true (the default for a manual run), then
|
||||
# read the debug log. The schedule runs live.
|
||||
on: # yamllint disable-line rule:truthy
|
||||
schedule:
|
||||
# Daily, off the hour so it avoids typical molecule and image runs.
|
||||
- cron: "17 3 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: "Log what Renovate would do without branches or pull requests"
|
||||
type: choice
|
||||
options:
|
||||
- "true"
|
||||
- "false"
|
||||
default: "true"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
# Never two runs at once; a running one is not cancelled (it may be mid-push).
|
||||
concurrency:
|
||||
group: renovate
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
renovate:
|
||||
# Only in this repository (a copy elsewhere would run with its own job token).
|
||||
if: github.repository == 'mortis/kamino' || github.repository == 'Mortis/Kamino'
|
||||
runs-on: kamino-docker
|
||||
timeout-minutes: 30
|
||||
# Docker Hub image, pinned by digest like the cluster's CronJob (same version). The -full
|
||||
# flavour ships python3 for the postUpgradeTasks command. Hand-bumped: renovate.json
|
||||
# disables updates for this file.
|
||||
container:
|
||||
image: renovate/renovate:44.161.0-full@sha256:ddbf02e44b542343c9df696b88fd953f04cc3ee5f771221805ff8efb26595416
|
||||
steps:
|
||||
- name: Run Renovate
|
||||
env:
|
||||
RENOVATE_PLATFORM: gitea
|
||||
RENOVATE_ENDPOINT: ${{ github.server_url }}/api/v1/
|
||||
RENOVATE_REPOSITORIES: ${{ github.repository }}
|
||||
RENOVATE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RENOVATE_GIT_AUTHOR: "Renovate Bot <[email protected]>"
|
||||
# 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' }}
|
||||
# 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
|
||||
fi
|
||||
renovate
|
||||
@@ -59,10 +59,9 @@ protection, or create tags: those are the operator's.
|
||||
(HTTP 401, run 2237), so the push uses the org Actions secrets `PACKAGE_PUSH_USER` and
|
||||
`PACKAGE_PUSH_TOKEN`. Never print or use them anywhere else.
|
||||
|
||||
## Dependency automation (Renovate, Phase 0: configured, not active)
|
||||
## Dependency automation (Renovate)
|
||||
|
||||
`renovate.json` is inert until the operator adds Kamino to the self-hosted instance's repository
|
||||
list. Nothing below runs yet unless it says so.
|
||||
`renovate.json` is run by `.gitea/workflows/renovate.yml` (see below). Items marked unverified have not run yet.
|
||||
|
||||
- **Policy:** minor and patch bumps automerge, majors are manual. `ansible-core` minor and major
|
||||
are manual too (a new minor needs a `tests/sanity/ignore-2.NN.txt`), and `ansible-core` and
|
||||
@@ -76,10 +75,10 @@ list. Nothing below runs yet unless it says so.
|
||||
`image.yml` (`scripts/bump_image_versions.py [<base-ref>]`, 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:<version>@sha256:<digest>` pins to that digest.
|
||||
Until Phase 2/3 enables the script as a `postUpgradeTasks` command (the cluster allows no
|
||||
commands yet, and `renovate.json` must not list any), the bump in PR 1 is a hand edit, and
|
||||
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).
|
||||
`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
|
||||
head ref starting `renovate/` may only change version lines in `requirements-dev.txt`, `rev:`
|
||||
lines in `.pre-commit-config.yaml`, FROM tags/digests and the `uv==` pin in `images/*/Dockerfile`,
|
||||
@@ -94,13 +93,39 @@ list. Nothing below runs yet unless it says so.
|
||||
a changelog fragment and a new `galaxy.yml` version, and only the operator tags.
|
||||
- **No production images:** `check_image_versions.py pins` fails when anything under
|
||||
`.gitea/workflows` mentions `git.rkdr.net/defame1297/`.
|
||||
- **Not enabled yet:** the Renovate run itself, `postUpgradeTasks`, credentials for the
|
||||
`git.rkdr.net` registry (`hostRules`), pin-follow, and a validated `renovate.json` on the
|
||||
instance's Renovate version. The `pre-commit` manager is beta; the hooks come from github.com, so it
|
||||
needs `GITHUB_COM_TOKEN` on the Renovate instance. 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`).
|
||||
- **Where Renovate runs:** `.gitea/workflows/renovate.yml`, a daily cron (03:17 UTC) plus
|
||||
`workflow_dispatch`, on the `kamino-runner` (`kamino-docker`): the untrusted side, so code from this
|
||||
repository never runs in the production cluster (ADR 0004). It authenticates with the workflow's own
|
||||
job token (`secrets.GITHUB_TOKEN`): no new account, no secret, and no org secret (only `image.yml` may
|
||||
reference those). The job container is `renovate/renovate:<version>-full@sha256:...` from Docker Hub
|
||||
(the `-full` flavour for `python3`), same version as the cluster's CronJob, hand-bumped (renovate.json
|
||||
disables updates for the workflow file). Lookups of the github.com pre-commit hooks are
|
||||
unauthenticated (no `RENOVATE_GITHUB_COM_TOKEN` exists) and may hit rate limits: best effort.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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
|
||||
|
||||
+7
-3
@@ -33,9 +33,13 @@
|
||||
- These files are in `galaxy.yml` `build_ignore`: such bumps do not change the Collection or its
|
||||
version. A change consumers can see needs a changelog fragment, and only the maintainer
|
||||
bumps the version and tags.
|
||||
- `renovate.json` configures dependency bumps (minor and patch automerge, majors by hand). It is
|
||||
not active yet: Renovate does not run against this repository, and until it does the bumps above
|
||||
are made by hand. Pull requests from `renovate/` branches must pass
|
||||
- `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. 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.
|
||||
|
||||
+25
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"description": "INERT until Kamino is added to the self-hosted Renovate instance's repository list (the operator's step, Phase 3 of the Renovate plan). 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. postUpgradeTasks are NOT configured: the cluster allows no commands yet (Phase 2/3).",
|
||||
"description": "Run by .gitea/workflows/renovate.yml on the kamino-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. The image-input rule runs scripts/bump_image_versions.py as a postUpgradeTasks command (allowed by RENOVATE_ALLOWED_COMMANDS of .gitea/workflows/renovate.yml, where Renovate runs).",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":enablePreCommit"
|
||||
@@ -45,7 +45,7 @@
|
||||
"customManagers": [
|
||||
{
|
||||
"customType": "regex",
|
||||
"description": "The uv pin that installs the build-stage Python interpreters of the ci image (images/ci/Dockerfile). It is an image input: the version bump comes from scripts/bump_image_versions.py via postUpgradeTasks (to be enabled in Phase 2/3).",
|
||||
"description": "The uv pin that installs the build-stage Python interpreters of the ci image (images/ci/Dockerfile). It is an image input: the version bump comes from scripts/bump_image_versions.py via postUpgradeTasks (rule below).",
|
||||
"managerFilePatterns": [
|
||||
"/^images/ci/Dockerfile$/"
|
||||
],
|
||||
@@ -70,12 +70,34 @@
|
||||
],
|
||||
"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 image version bump in image.yml (scripts/bump_image_versions.py via postUpgradeTasks) is not enabled yet; until then the pull request fails the version check and a human adds it.",
|
||||
"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 image version bump in image.yml comes from scripts/bump_image_versions.py via postUpgradeTasks (rule below).",
|
||||
"matchManagers": [
|
||||
"dockerfile"
|
||||
],
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"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": [
|
||||
"python3 scripts/bump_image_versions.py origin/main"
|
||||
],
|
||||
"fileFilters": [
|
||||
".gitea/workflows/image.yml"
|
||||
],
|
||||
"executionMode": "branch"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "The Renovate job container of renovate.yml runs with the job token: hand-bumped, never by the bot (the bot-diff gate would refuse a change to that file anyway).",
|
||||
"matchFileNames": [
|
||||
".gitea/workflows/renovate.yml"
|
||||
],
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"description": "Majors are reviewed by hand.",
|
||||
"matchUpdateTypes": [
|
||||
|
||||
@@ -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).
|
||||
|
||||
|
||||
Reference in new issue
Block a user