builds.sr.ht is our build automation platform. We're going to walk through the process of running jobs on builds.sr.ht and a look at a few useful features.
Unlike platforms like Jenkins, builds.sr.ht does not allow you to pre-configure jobs. And unlike platforms like Travis, jobs are not inherently tied to a git repository. Each job on builds.sr.ht is described ad-hoc with a build manifest, which can be submitted to builds.sr.ht for processing.
Let's start with a basic manifest:
image: alpine/edge tasks: - example: | echo "hello world"
This is a build manifest, written in YAML. When we submit this to builds.sr.ht, it will boot up an Alpine Linux virtual machine using the edge release of Alpine Linux. Then it will execute each of our build tasks — in this case, saying "hello world".
builds.sr.ht has a web submission form, where you can paste a build manifest and submit the job without any additional configuration. This is a useful way of testing build manifests before giving them a permanent home, or running one-off tasks. Visit the job submission form and paste in the example manifest. Add a note, perhaps "my first job", and click "submit" to run the job.
You'll be redirected to the job detail page. In a moment, one of our job runners will pick up the task and start processing it. Within a few seconds, you should see "hello world" shown under the "example" task.
Let's try a new build manifest. This one is going to compile and test the scdoc project.
image: alpine/edge sources: - https://git.sr.ht/~sircmpwn/scdoc tasks: - build: | cd scdoc make - test: | cd scdoc make check
Before starting your tasks, builds.sr.ht will clone each repository listed in "sources" to the build environment. You can have as many or as few (including zero) git repositories as you like.
image: alpine/edge packages: - meson sources: - https://git.sr.ht/~emersion/mrsh tasks: - configure: | cd mrsh meson build - build: | cd mrsh ninja -C build - test: | cd mrsh ninja -C build test
This time, builds.sr.ht will install Alpine Linux's meson
starting your build. This uses Alpine's native
apk package manager — other
images use different package managers.
Portability is important — so let's try running the same manifest on another operating system.
image: freebsd/latest packages: - meson sources: - https://git.sr.ht/~emersion/mrsh tasks: - configure: | cd mrsh meson build - build: | cd mrsh ninja -C build - test: | cd mrsh ninja -C build test
This one happens to work without any changes, but note that some images have different names for packages, different distributions of coreutils, and so on.
If you put a build manifest in
.build.yml at the top of your repo, a build job
will be created each time you push new commits. You can also create multiple
manifests, for example to test multiple platforms, by putting several build
commit b345d3de11bc0e7dbf344de75c30cf7e3620fa7b Author: Conrad Hoffmann <email@example.com> Date: 2022-05-12T10:04:02+02:00 Add link to package installation instructions Besides being a bit more convenient, it also adds a little emphasis to this specific bullet point :)