Forgejo Actions runner
The verify workflow (.forgejo/workflows/verify.yml) runs bin/a-verify on
every push and pull request. It needs a registered Forgejo Actions runner.
Until one is registered the workflow is inert, and the git pre-push hook
(make install-hooks) is the only live gate.
Where to run it
Run the runner somewhere other than the machine hosting the forge. CI executes whatever is in the repository, so it should not share a host with the forge’s own data. Any spare machine will do; the job is short and idle most of the time, so this is usually a matter of using capacity you already have rather than buying more.
Whichever host you pick, assume the runner can read anything its user can read.
Give it a dedicated account, keep that account out of sudo, and check that
nothing sensitive on the machine is world-readable.
Why the job runs on the host, not in a container
Forgejo runners can execute each job inside a container. That does not work
here. The last step of a-verify builds the membership API image, runs it with
a published port, and then makes HTTP requests to that port. If the job itself
runs in a container that talks to a shared container socket, the API starts on
the host’s network rather than inside the job’s, and the requests never arrive.
So the runner is registered for host execution and isolation comes from the unprivileged account instead of from a container boundary. The job still builds and runs containers; it just does so directly, as that user, through rootless podman.
Host prerequisites
The workflow installs uv itself. Everything else has to be present already:
podman, for the API smoke container. Rootless is correct here; the old advice to use a rootful socket no longer applies.gitandgit-lfs. The repository keeps large reference data in LFS.node, whichactions/checkoutneeds in order to run at all.make, exercised by the deploy hardening tests.lycheeandjq, used by the documentation link checker.lycheeis usually not packaged, so install the release binary.python3.
A missing tool tends to surface as an opaque failure rather than a clear one.
The link checker exits 127, and the make check raises FileNotFoundError.
Create the runner account
Make an unprivileged user, confirm it is in no other groups, and enable lingering so its services start at boot without a login session:
sudo useradd -m -s /bin/bash ci
groups ci # should list only 'ci'
sudo loginctl enable-linger ci
useradd allocates the subordinate UID and GID ranges that rootless podman
needs. Do not add a second range by hand. Overlapping ranges make newuidmap
fail with Invalid argument, and podman will refuse to start any container.
Check that rootless podman works for that user before going further:
sudo -u ci -H env XDG_RUNTIME_DIR=/run/user/$(id -u ci) \
bash -c 'cd ~ && podman run --rm alpine echo ok'
Install the runner
Take the binary from the Forgejo runner releases, verify the checksum, and pin the version rather than tracking a moving tag:
V=13.1.0
B=forgejo-runner-$V-linux-amd64
curl -sSfLO https://code.forgejo.org/forgejo/runner/releases/download/v$V/$B
curl -sSfLO https://code.forgejo.org/forgejo/runner/releases/download/v$V/$B.sha256
sha256sum -c $B.sha256
sudo install -m 0755 $B /usr/local/bin/forgejo-runner
Register
Generate a registration token, either from Site Administration -> Actions ->
Runners -> Create new runner in the web UI, or from the forge host with
forgejo actions generate-runner-token. Pipe it straight into the register
command so it never lands in a shell history or a terminal log.
Register as the runner user, from a working directory that will hold its configuration:
cd ~/runner
forgejo-runner generate-config > config.yml
forgejo-runner register --no-interactive \
--instance https://code.almnck.com \
--token "$TOKEN" \
--name <a name for this runner> \
--labels docker:host
chmod 600 .runner config.yml
The label mapping is the part that matters. docker:host declares a label
called docker, matching runs-on: docker in the workflow, but runs it
directly on the host. The name is cosmetic and only appears in the Forgejo UI.
.runner holds the runner’s credential, so it should not be world-readable.
Run it under systemd
As the runner user, write ~/.config/systemd/user/forgejo-runner.service:
[Unit]
Description=Forgejo Actions runner
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=%h/runner
ExecStart=/usr/local/bin/forgejo-runner daemon --config %h/runner/config.yml
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
Then systemctl --user daemon-reload && systemctl --user enable --now
forgejo-runner.service. With lingering enabled this comes back after a reboot.
The journal should show the runner declaring itself and launching its poller.
Cache LFS objects between runs
The repository carries several gigabytes of media in Git LFS. A fresh checkout
fetches all of it, which dominates the run: on one measured host the checkout
took 332 seconds while everything a-verify actually does took about twenty.
Point the runner account’s git config at a persistent object store, so the objects survive the workspace being discarded:
mkdir -p ~/lfs-store
git config --global lfs.storage ~/lfs-store
git lfs env | grep LfsStorageDir # confirm it took
That is the whole change. It works because actions/checkout copies the
account’s ~/.gitconfig into its temporary HOME before cloning, so the setting
is in effect during the fetch. With the store warm, the same clone took 20
seconds instead of 332, and a whole run went from 343 seconds to 39.
Caching content here is safer than caching a resolved dependency tree: LFS objects are addressed by their SHA256, so a cached object either hashes correctly or is rejected, and a new object is fetched on demand. It cannot quietly serve the wrong bytes.
Two things to know. The store only grows, and git lfs prune works against a
single repository rather than a shared store, so pruning is manual: look at its
size occasionally and delete the whole directory if it gets out of hand, since
the next run will refill what it needs. And this assumes one job at a time. If
you raise the runner’s capacity above 1, concurrent jobs will write the same
store.
Prefer this to narrowing the checkout to the few objects the tests read. A CI specific include list is a second, quieter definition of what the repository contains, and it drifts from the real one.
Protect the deployment branch
In the repository settings, add a branch-protection rule on main requiring
the verify status check to pass before merge. This is what makes the gate
binding rather than advisory.
Verifying
Push a throwaway branch and confirm verify goes green in the Actions tab.
Delete the branch afterwards. With the LFS store warm a full run is well under
a minute; on a cold store expect several minutes, nearly all of it the LFS
fetch rather than the build.
If the run fails, the job log in the Actions tab is the thing to read. The runner’s own journal only shows that it collected the task.
Notes for a new host
Three failures are specific to moving CI onto a machine that is not a developer’s laptop. All three are fixed in the repository, and are recorded here because they will look like broken infrastructure the next time.
Large reference data lives in Git LFS, and actions/checkout does not fetch
LFS objects unless asked. Without lfs: true the checkout produces pointer
files, and anything reading them fails with a complaint about an unexpected
file header rather than about LFS.
The API smoke test cannot assume the service is listening a fixed number of seconds after the container starts. A slower or busier host takes longer, and a rootless port forwarder accepts the connection before anything is behind it, so the symptom is a connection reset rather than a refusal. The test polls the health endpoint until it answers.
Address the published port as 127.0.0.1, never as localhost. On most Linux
hosts localhost resolves to ::1 first, while a rootless published port is
IPv4 only. The two spellings disagree, and the failure reads as a dead service.
Curling all three of 127.0.0.1, localhost and [::1] will show it.