Running continuous integration locally
Motivation
There are situations where you'll want to run the continuous integration workflow on a development machine. These include:
- You want to check whether your code will pass continuous integration without committing your work.
- You want to work on the continuous integration workflow.
Setup
Install Forgejo Runner
Setting up Forgejo Runner for local, manual use is simpler than setting it up for remote, automated use.
On OpenSUSE Tumbleweed, you can install the forgejo-runner
package by calling
sudo zypper install forgejo-runner
On other systems, you may need to install manually.
-
Download these files from the release page:
- The binary
forgejo-runner-#.#.#-linux-amd64
. - (Recommended) The signature
forgejo-runner-#.#.#-linux-amd64.asc
.
- The binary
-
(Recommended) Verify the binary's authenticity by checking its signature.
- Import Forgejo's public signing key by calling
If that doesn't work, you can download the key manually:gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710
- Search in OpenPGP keyserver web interface for the fingerprint listed after
--recv
above. - Download the key and call
gpg --import
on it.
- Search in OpenPGP keyserver web interface for the fingerprint listed after
- Check the signature by calling
gpg --verify forgejo-runner-#.#.#-linux-amd64.asc forgejo-runner-#.#.#-linux-amd64
- Import Forgejo's public signing key by calling
-
Give the binary permission to be executed by the user who owns it.
-
(Optional) For convenience, put the binary in your command search path. I like to do this by placing two symbolic links in
~/.local/bin
, which is already on my search path:- A link called
forgejo-runner-#.#.#
that points to the location of the binaryforgejo-runner-#.#.#-linux-amd64
. - A link called
forgejo-runner
that points toforgejo-runner-#.#.#
.
Now I can launch a specific version of the runner by calling
forgejo-runner-#.#.#
, and I can launch my chosen default version by callingforgejo-runner
. - A link called
(Optional) Install Docker and build the continuous integration container image
If you want to run the continuous integration workflow in a Docker container, like the remote CI system does, you'll need to install Docker and build the container image.
- Install Docker
- On Ubuntu 22.04, I used the
docker-compose
package, althoughdocker.io
might be enough.
- On Ubuntu 22.04, I used the
- Go to the
tools/ci-image
folder in the dyna3 repository and run thebuild
script. The script tells Docker to build the image described by the neighboringDockerfile
and place it in Docker's image store with the tagdyna3:ci
.
If you rebuild the Docker image with changes, the old version will still be sitting around in Docker's image store. Here's how to remove it.
- If you only ever ran the old version through Forgejo Runner, all the containers that referred to it should've been cleaned up automatically, so
docker image prune
should remove it.- ⚠️ This will also remove any other unreferenced images you might have in the image store.
- If you ever ran the old version some other way, there may still be a container referring to it. In this case, get the old image's ID by finding it in the list displayed by
docker images
. Callingdocker image rm
on that ID should lead to an error that mentions which containers refer to the old image. Usedocker ps -a
to examine those containers and confirm that they're not needed anymore. Then usedocker rm
to remove the containers that refer to the old image.
Execution
Running directly on your development system
- Go into the top level of the dyna3 repository and call
forgejo-runner exec --image -self-hosted
This will only work if your build system is set up in the way the continuous integration workflow expects. For example, it assumes that you can call Cargo with the command cargo
.
Running in a Docker container
- Go into the top level of the dyna3 repository and call
forgejo-runner exec
This will only work if you've done the Docker section of the setup procedure.
Running one particular job
The continuous integration workflow includes several jobs. If you only want to run one of them:
- Look up the name of the job you want to run. Job names can be found in two places that I know of:
- Listed under
jobs
in the workflow description,.forgejo/workflows/continuous-integration.yaml
. - In the
[continuous-integration.yaml/JOB_NAME]
annotations in the workflow's console output.
- Listed under
- Call one of the execution commands above with the extra option
--job JOB_NAME
.