Previously, the build workflow was restricted to running only on Ubuntu 22.04, Ubuntu 24.04 and macOS, which are the only available native runners on Github Actions. However, the Ubuntu runner does allow us to run the build inside a container. Therefore, this commit adds the ability to pull a prebuilt container with all the necessary dependencies and build libx52 inside of that container. This commit also adds support scripts to build the containers and run the CI build against those prebuilt containers locally for testing, without having to rely exclusively on Github Actions. This change also adds support for testing libx52 against Alpine Linux, in order to verify the portability, given that Alpine uses musl instead of glibc. The limitation is that we need to mount the `/dev/bus/usb` device tree inside the container, otherwise libusb inside the Alpine image fails with LIBUSB_ERROR_OTHER. This is not a concern on the other distributions, but due to limitations in the Github actions environment, there is no `/dev/bus/usb` tree to export. For this reason, Alpine is not a part of the CI build, but is available for testing locally. Also, because a default bare container would need several minutes of package installation just to get to a point where we could run build-and-test.sh, this includes a prebuild workflow which generates the container images and pushes them to ghcr.io, and the build workflow pulls from there. There is also logic to ensure that we only keep the latest image, since there is no value in retaining older images. |
||
|---|---|---|
| .. | ||
| Dockerfile.archlinux | ||
| Dockerfile.fedora | ||
| Dockerfile.ubuntu22 | ||
| Dockerfile.ubuntu24 | ||
| Dockerfile.ubuntu26 | ||
| README.md | ||
| build-containers.sh | ||
| build-repo.sh | ||
| ci-setup.sh | ||
| dockerfile.alpine | ||
| install-dependencies-alpine.sh | ||
| install-dependencies-archlinux.sh | ||
| install-dependencies-fedora.sh | ||
| install-dependencies-ubuntu.sh | ||
README.md
Dockerfiles for CI builds
This repo contains a number of Dockerfiles for building libx52 against multiple distros. Github only supports Ubuntu LTS for it's Linux runners, but libx52 users run multiple distros, including Arch Linux, Gentoo and Fedora.
For this reason, it's better to get a prebuilt Docker image that builds the CI environment, pulling in all the relevant dependencies, and staging the CI build environment as a container within Github. The regular build pipeline can then run on these containers, and this will help ensure that the breakages are reduced to a minimum.
Build Instructions
In order to run the CI build on all the supported platforms, first run the
build-containers.sh script, it will find the Dockerfiles for all the
suppported platforms in the docker directory, and build the container images
for them with the necessary dependencies included.
Once the container images are built, you can build against one or all of the
container images by running build-repo.sh. If you don't specify the container
distro, which is basically the same as the extension after Dockerfile., it
will run everything. If you specify a distro that doesn't exist, or has not been
built, the script will silently exit.
Extending to a new distro
To extend the builds to a new distro, create a Dockerfile.<distro> with the
necessary instructions to build a container image for that distro. Make sure you
install the necessary dependencies for the distro. It is strongly recommended to
add a install-dependencies-<distro>.sh so that you can build against multiple
versions of that distro, eg. Ubuntu 22.04 and Ubuntu 24.04. Make sure you copy
ci-setup.sh to allow setting up the environment, since it is highly likely
that the meson dist command will fail if you do not run that script.