Skip to content

Builds

SourceLab runs a project's builds itself, from manifests in its repository, written as for builds.sr.ht. A manifest that ran on builds.sr.ht runs here unchanged, except where it clones other repositories from sr.ht.

Note

The builds are a plugin of SourceLab. If a project has no Builds tab, your instance doesn't run them: see Installing the builds.

Manifests

A manifest is a YAML file: an image, packages to install, repositories to clone, environment variables, and tasks, which are shell scripts run in order as the build user, who may use sudo.

image: ubuntu/24.04
packages:
  - python3-pytest
tasks:
  - test: |
      cd myproject
      pytest

A project's manifests are .build.yml at the root of its repository or, if there is none, the files of .builds/ ending in .yml, at most four, taken in order of name. Each manifest is a job of its own, and the jobs of a push make up a build.

Not supported yet: artifacts, oauth, shell, webhook triggers, and the in_reply_to of email triggers. A manifest that has them is accepted, and each job says what it ignored among its warnings.

A job may run for 45 minutes, unless your instance sets another limit.

When a project builds

Each push to a branch builds the manifests of its new commit. Deleting a branch builds nothing, and neither does pushing a tag.

Two push options, as on git.sr.ht, change what a push builds:

git push -o skip-ci                       # builds nothing
git push -o submit='.builds/test-*.yml'   # builds only the manifests matching this pattern

The jobs of a push belong to the person who pushed. They see the commit pushed: in each manifest's sources, the entry naming the project's repository is replaced by the forge's URL at that commit, and when no entry names it, it is added first. So the job finds the project in a directory named after it, as on builds.sr.ht.

Besides the manifest's own variables, a job has JOB_ID, JOB_URL, CI_NAME (builder), BUILD_SUBMITTER (sourcelab) and GIT_REF, the branch pushed, such as refs/heads/main.

A job of a private project clones it with a token of its own, which can fetch that project and nothing else, and is deleted when the job ends. The manifest needs no secret for that.

Following a build

The project's Builds tab lists its builds, newest first, each with its commit, its branch and its state. A build's page lists its jobs, and shows the logs of one: its setup, then each task. It reloads itself until the build ends.

Each job also flags its commit: pending while it runs, then success, failure, error (it reached its time limit) or canceled. The flag is named after the manifest, such as ubuntu for .builds/ubuntu.yml, and links to the job's logs. See Flags.

The builds of a project are seen by those who may see the project.

Email triggers

A manifest can ask for mail when its job ends, as on builds.sr.ht:

triggers:
  - action: email
    condition: failure
    to: jane@example.org, team@example.org

The condition says when: failure when the job fails or reaches its time limit, success when it succeeds, always whenever it ends, even cancelled. to and cc list the recipients, separated by commas. The mail comes from the forge: its subject names the project, the manifest, how the job ended and the branch, and it links to the job's page and lists its tasks with their states.

Only the jobs of a project's builds, pushed or started by hand, send it.

Badges

A project's badge shows how the last build of its default branch ended, as an image for its README:

[![builds](https://forge.example.org/myproject/builds/badge.svg)](https://forge.example.org/myproject/builds)

Add ?branch=<name> to the image's URL for another branch. The badge says passing, failing, timed out, cancelled, running, or unknown for a branch never built. A private project's badge is only shown to those who may see the project, so it can't appear on a page elsewhere.

Starting a build by hand

The project's committers can start a build without pushing: on the Builds tab, Start a build, then choose a branch, the manifests to build, and, if you like, a note saying why. The build is yours, of the branch's last commit, and its page says it was started rather than pushed.

Secrets

A job may need a key that the repository mustn't hold: an SSH key to clone another private repository, or to deploy. Those are secrets, which the manifest names by their UUID:

image: alpine/latest
secrets:
  - b88a4c2c-1fb5-4e5b-9c47-9b5e2a6c4d1e
sources:
  - git@git.example.org:me/private-dependency
tasks:
  - deploy: ssh deploy@example.org ./release.sh

Secrets are SSH private keys. Each one the job names is written to ~/.ssh/<uuid>, and the first also to ~/.ssh/id_rsa, which ssh and git use by default. Both are readable only by the build user. The secrets are written before the repositories are cloned, so the job can clone over SSH with them.

A job only gets the secrets of its owner: the person who pushed, or who started the build. If the manifest names a secret its owner doesn't have, the job fails before it runs, and its page says which secret was missing. A project's other committers can't use your secrets, and their pushes fail on a manifest that names them.

For now, an administrator of your instance adds your secrets, with the UUID you choose, such as the one a secret had on builds.sr.ht, so that your manifests stay as they are. Give them the private key by a safe way, never by email or in an issue.

A job runs whatever its commit holds. When you push commits that others wrote, their tasks run with your secrets: read what you push to a project whose manifests name them.

Warning

A job's logs are seen by everyone who can see its project. A secret that a task prints, such as with set -x around a command that holds it, ends up in the logs. The keys themselves are written to files, not shown.

Images

The images that an instance offers depend on its runners. On the Docker runners:

  • alpine/latest and alpine/edge;
  • debian/bookworm and debian/trixie;
  • rockylinux/latest (Rocky Linux 10);
  • ubuntu/22.04, ubuntu/24.04 (also as ubuntu/latest, ubuntu/lts and ubuntu/noble) and ubuntu/26.04.

Not nixos/latest yet. A push leaves out a manifest that names another image, as one that isn't valid: the build has no job for it, and for now only the forge's log says why.

A job runs in a fresh machine, gone after it: a container that behaves like builds.sr.ht's virtual machines, where the job may install packages, start services and run Docker, or buildah and podman, as root or as build.