diff --git a/.gitea/workflows/renovate.yaml b/.gitea/workflows/renovate.yaml new file mode 100644 index 0000000..50be26b --- /dev/null +++ b/.gitea/workflows/renovate.yaml @@ -0,0 +1,71 @@ +# ============================================================================= +# renovate.yaml — weekly dependency-update PRs, opened against this repo. +# +# Renovate stands in for Dependabot, which does not exist outside GitHub. What +# it updates is configured in /renovate.json5; this file is only how it runs. +# +# HOW IT RUNS +# The same host-mode act_runner as deploy.yaml, so (as there) nothing but +# git and docker is assumed on the host: Renovate runs from its own image. +# --network host lets the container reach Gitea on localhost:3000, the port +# the runner itself registers against, so this keeps working while nginx or +# the tunnel is down. RENOVATE_GIT_URL=endpoint matters for the same reason: +# without it Renovate clones from the URL Gitea advertises, which is +# ROOT_URL — the public https://…/gitea/ path. +# +# WHAT HAPPENS AFTER +# Each update is pushed as a renovate/* branch, which triggers deploy.yaml's +# `test` job like any other push (and never its `deploy` job, which is +# main-only). Nothing is merged automatically: merging is deploying. +# Renovate also keeps a "Dependency Dashboard" issue open listing everything +# pending; ticking a box there is picked up on the next run, so run this +# workflow by hand (workflow_dispatch) to act on it sooner. +# +# THE TOKEN +# RENOVATE_TOKEN is a repo Actions secret: a Gitea access token for the +# account the PRs come from (a dedicated `renovate` user with write access +# to this repo, ideally), scopes read:user, read:organization, +# write:repository, write:issue. +# RENOVATE_GITHUB_COM_TOKEN is optional: any github.com token with no +# scopes. Without it Renovate is rate-limited by GitHub and leaves release +# notes out of the PRs. (Gitea refuses secret names starting GITHUB_, hence +# the prefix.) Both reach the container as `-e NAME` with no value, so they +# are copied from this step's env and never appear in the process list. +# +# The renovate/renovate:44 tag floats within the major (--pull always picks +# up the newest 44.x each week); Renovate itself proposes the next major via +# the regex manager in renovate.json5. +# ============================================================================= +name: Renovate + +on: + schedule: + # 04:00 UTC Monday: clear of the Sunday 05:00 maintenance rebuild, and + # done before the working week so the PRs are waiting. + - cron: "0 4 * * 1" + workflow_dispatch: + +jobs: + renovate: + runs-on: self-hosted + steps: + - name: Run Renovate + shell: bash + env: + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_COM_TOKEN }} + run: | + set -eu + if [ -z "$RENOVATE_TOKEN" ]; then + echo "The RENOVATE_TOKEN Actions secret is not set (repo Settings -> Actions -> Secrets)." + exit 1 + fi + docker run --rm --pull always --network host \ + -e RENOVATE_PLATFORM=gitea \ + -e RENOVATE_ENDPOINT=http://localhost:3000/api/v1 \ + -e RENOVATE_GIT_URL=endpoint \ + -e RENOVATE_REPOSITORIES=adamf/web_server \ + -e RENOVATE_TOKEN \ + -e GITHUB_COM_TOKEN \ + -e LOG_LEVEL=info \ + renovate/renovate:44 diff --git a/CLAUDE.md b/CLAUDE.md index 3faa313..1063830 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co make check ``` -Runs `go vet` + `go test` (backend), pytest in a venv built from `python/requirements-dev.txt` (kept in `/.venv/`), a Vite build, and `docker compose config` for both compose files. Each part is also its own target (`check-backend`, `check-python`, `check-vue`, `check-compose`); `make help` lists them. The Gitea deploy workflow runs the backend and Python checks in containers on every push, and `main` only deploys if they pass — so run `make check` before pushing. +Runs `go vet` + `go test` (backend), pytest in a venv built from `python/requirements-dev.txt` (kept in `/.venv/`), a Vite build, and `docker compose config` for both compose files. Each part is also its own target (`check-backend`, `check-python`, `check-vue`, `check-compose`); `make help` lists them. The Gitea deploy workflow runs the backend and Python checks in containers on every push, and `main` only deploys if they pass — so run `make check` before pushing. Dependency-update PRs come from Renovate (`renovate.json5`, run weekly by `.gitea/workflows/renovate.yaml`), since Dependabot is GitHub-only; that `test` job skips the Vue build, so run `make check-vue` on an npm PR before merging it. ### Full stack (dev mode, HTTP only) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 4b568bc..1eff180 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -631,6 +631,18 @@ against this stack, so it cannot be a container in it. Registration is one-shot `.runner` is the lasting credential; re-registering needs that file deleted _and_ a fresh token. +**Dependency updates (Renovate).** Dependabot is GitHub-only, so +`.gitea/workflows/renovate.yaml` runs Renovate on the same runner every Monday +at 04:00 UTC (or by hand from the Actions tab), configured by +`renovate.json5`. It opens PRs from `renovate/*` branches, which get the +normal `test` job; nothing automerges, because merging to `main` deploys. It +needs a `RENOVATE_TOKEN` repo Actions secret: create a `renovate` Gitea user, +add it to this repo as a collaborator with write access, and mint a token for +it with `read:user`, `read:organization`, `write:repository` and +`write:issue`. `RENOVATE_GITHUB_COM_TOKEN` (any github.com token, no scopes) +is optional and lifts GitHub's rate limit on release-note lookups. The first +run opens a "Dependency Dashboard" issue listing everything pending. + **Go live on the radio:** point a broadcasting client (e.g. butt) at the host's Tailscale name (not the domain, which resolves to Cloudflare) on `${LIQUIDSOAP_HARBOR_PORT}` with mount `${LIQUIDSOAP_HARBOR_MOUNT}` and the diff --git a/renovate.json5 b/renovate.json5 new file mode 100644 index 0000000..8f0c2fb --- /dev/null +++ b/renovate.json5 @@ -0,0 +1,115 @@ +// ============================================================================= +// renovate.json5 — dependency-update PRs (this repo's Dependabot). +// +// WHY RENOVATE AND NOT DEPENDABOT +// Dependabot only runs on GitHub, and this repo lives on the self-hosted +// Gitea. Renovate does the same job against Gitea's API. It is run by +// .gitea/workflows/renovate.yaml on the stack's own runner, which is where +// the platform, endpoint and token are set; this file is only *what* to +// update. +// +// WHAT IT WATCHES +// gomod backend/go.mod (go.sum and `go mod tidy` come along) +// npm vue/package.json + package-lock.json +// pip_requirements python/requirements.txt, requirements-dev.txt +// dockerfile every */Dockerfile FROM line +// docker-compose every image: in docker-compose*.yml +// custom (below) the images deploy.yaml and renovate.yaml `docker run` +// +// NOTHING IS AUTOMERGED, on purpose: a merge to main IS a deploy. Each +// Renovate branch is pushed to Gitea, so deploy.yaml's `test` job runs on it +// (go vet/test and pytest) — but that job skips the Vue build, so an npm PR is +// only proven by `make check-vue` locally or by the deploy itself (where a +// failed build stops before any container is replaced). +// ============================================================================= +{ + $schema: "https://docs.renovatebot.com/renovate-schema.json", + extends: ["config:recommended"], + timezone: "Europe/London", + + // Replaces config:recommended's list rather than adding to it. .deprecated/ + // holds parked services whose manifests are not built any more. + ignorePaths: ["**/node_modules/**", ".deprecated/**"], + + // A release has to have been out this long before a PR proposes it, so a + // compromised or quickly-yanked version never reaches a branch. + minimumReleaseAge: "3 days", + + postUpdateOptions: ["gomodTidy"], + + customManagers: [ + { + // deploy.yaml runs the tests in `docker run golang:… / python:…`, which + // no built-in manager reads. They must match backend/Dockerfile and + // python/Dockerfile (see deploy.yaml's header), so they share those + // images' groups below and land in the same PR. Also matches the + // Renovate image in renovate.yaml, and the copies in comments, which + // keeps those accurate. + customType: "regex", + managerFilePatterns: ["/^\\.gitea/workflows/[^/]+\\.ya?ml$/"], + matchStrings: ["(?golang|python|renovate/renovate):(?[0-9][\\w.-]*)"], + datasourceTemplate: "docker", + }, + ], + + packageRules: [ + // The job tracker, usaco and activity-tracker images are built by their + // own repos and roll themselves out on `:latest`; there is nothing here + // to bump. + { + matchDatasources: ["docker"], + matchPackageNames: ["adam-french.co.uk/**"], + enabled: false, + }, + + // A Postgres major needs a dump and restore of the dbdata volume (the new + // server refuses the old data directory), so it is done by hand, never + // from a PR. + { + matchDatasources: ["docker"], + matchPackageNames: ["postgres"], + matchUpdateTypes: ["major"], + enabled: false, + }, + + // Non-major updates batched per ecosystem, so the runner tests one branch + // a week per language instead of one per package. Majors stay separate. + // These come before the named groups below because a later matching rule + // wins: gqlgen and the go directive must not be swept in here. + { + matchManagers: ["gomod"], + matchUpdateTypes: ["minor", "patch", "digest"], + groupName: "Go modules (non-major)", + }, + { + matchManagers: ["npm"], + matchUpdateTypes: ["minor", "patch"], + groupName: "npm (non-major)", + }, + { + matchManagers: ["pip_requirements"], + matchUpdateTypes: ["minor", "patch"], + groupName: "Python packages (non-major)", + }, + + // One PR per toolchain: the Dockerfile base, the CI test image and (for + // Go) the go.mod `go` directive move together. + { + matchPackageNames: ["golang", "go"], + groupName: "Go toolchain", + }, + { + matchDatasources: ["docker"], + matchPackageNames: ["python"], + groupName: "Python image", + }, + + // gqlgen's runtime and gqlparser are versioned together. If a bump breaks + // the build, regenerate (`go run github.com/99designs/gqlgen generate`) + // on the branch. + { + matchPackageNames: ["github.com/99designs/gqlgen", "github.com/vektah/gqlparser/**"], + groupName: "gqlgen", + }, + ], +}