Simple Scan recently migrated to the new gitlab.gnome.org infrastructure. With modern infrastructure I now have the opportunity to enable Continuous Integration (CI), which is a fancy name for automatically building and testing your software when you make changes (and it can do more than that too).
I've used CI in many projects in the past, and it's a really handy tool. However, I've never had to set it up myself and when I've looked it's been non-trivial to do so. The great news is this is really easy to do in GitLab!
There's lots of good documentation on how to set it up, but to save you some time I'll show how I set it up for Simple Scan, which is a fairly typical GNOME application.
To configure CI you need to create a file called .gitlab-ci.yml in your git repository. I started with the following:
build-ubuntu:
image: ubuntu:rolling
before_script:
- apt-get update
- apt-get install -q -y --no-install-recommends meson valac gcc gettext itstool libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libwebp-dev libsane-dev
script:
- meson _build
- ninja -C _build install
The first line is the name of the job - "build_ubuntu". This is going to define how we build Simple Scan on Ubuntu.
The "image" is the name of a Docker image to build with. You can see all the available images on Docker Hub. In my case I chose an official Ubuntu image and used the "rolling" link which uses the most recently released Ubuntu version.
The "before_script" defines how to set up the system before building. Here I just install the packages I need to build simple-scan.
Finally the "script" is what is run to build Simple Scan. This is just what you'd do from the command line.
And with that, every time a change is made to the git repository Simple Scan is built on Ubuntu and tells me if that succeeded or not! To make things more visible I added the following to the top of the README.md:
[![Build Status](https://gitlab.gnome.org/GNOME/simple-scan/badges/master/build.svg)](https://gitlab.gnome.org/GNOME/simple-scan/pipelines)
This gives the following image that shows the status of the build:
I've used CI in many projects in the past, and it's a really handy tool. However, I've never had to set it up myself and when I've looked it's been non-trivial to do so. The great news is this is really easy to do in GitLab!
There's lots of good documentation on how to set it up, but to save you some time I'll show how I set it up for Simple Scan, which is a fairly typical GNOME application.
To configure CI you need to create a file called .gitlab-ci.yml in your git repository. I started with the following:
build-ubuntu:
image: ubuntu:rolling
before_script:
- apt-get update
- apt-get install -q -y --no-install-recommends meson valac gcc gettext itstool libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libwebp-dev libsane-dev
script:
- meson _build
- ninja -C _build install
The first line is the name of the job - "build_ubuntu". This is going to define how we build Simple Scan on Ubuntu.
The "image" is the name of a Docker image to build with. You can see all the available images on Docker Hub. In my case I chose an official Ubuntu image and used the "rolling" link which uses the most recently released Ubuntu version.
The "before_script" defines how to set up the system before building. Here I just install the packages I need to build simple-scan.
Finally the "script" is what is run to build Simple Scan. This is just what you'd do from the command line.
And with that, every time a change is made to the git repository Simple Scan is built on Ubuntu and tells me if that succeeded or not! To make things more visible I added the following to the top of the README.md:
[![Build Status](https://gitlab.gnome.org/GNOME/simple-scan/badges/master/build.svg)](https://gitlab.gnome.org/GNOME/simple-scan/pipelines)
This gives the following image that shows the status of the build:
And because there's many more consumers of Simple Scan that just Ubuntu, I added the following to.gitlab-ci.yml:
build-fedora:
image: fedora:latest
before_script:
- dnf install -y meson vala gettext itstool gtk3-devel libgusb-devel colord-devel PackageKit-glib-devel libwebp-devel sane-backends-devel
script:
- meson _build
- ninja -C _build install
Now it builds on both Ubuntu and Fedora with every commit!
I hope this helps you getting started with CI and gitlab.gnome.org. Happy hacking.