Skip to content

Latest commit

 

History

History

ci

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

CI: Makefile/Docker testing

To test the build on various distro, I'm using docker containers and a Makefile for orchestration.

pros:

  • You are independent of third party CI runner VM images (e.g. github actions/virtual-environments).
  • You can run it locally on any host having a linux docker image support.
  • Most CI provide runner with docker and Makefile installed.

cons:

  • Only GNU/Linux distro supported.
  • Could take few GiB (~30 GiB for all distro and all languages)
    • ~500MiB OS + C++/CMake tools,

Usage

To get the help simply type:

make

note: you can also use from top directory

make --directory=ci

Example

For example to test inside an Alpine container:

make alpine_test

Docker layers

Dockerfile is splitted in several stages.

docker

Run arm64v8 image on amd64 machine

You can build and run arm64v8 (i.e. aarch64) docker container on a amd64 host (x86_64) by enabling qemu support:

docker run --pull always --rm --privileged multiarch/qemu-user-static --reset -p yes

ref: https://github.com/multiarch/qemu-user-static#getting-started

Then you should be able to run them, e.g.:

docker run --rm -it arm64v8/ubuntu

ref: https://github.com/docker-library/official-images#architectures-other-than-amd64

Docker buildx

ref: https://docs.docker.com/buildx/working-with-buildx/

On you enable qemu support (see above), you can list available platform using:

docker buildx ls

Then you can build a docker image using one of the available platform

docker buildx build --platform linux/arm64 ...

Custom CMake install

To control the version of CMake, instead of using the version provided by the distro package manager, you can:

  • Install the prebuilt binaries (recommanded)
  • Build it from source (slower)
  • Install it using the pypi package cmake (need a python stack)

Install prebuilt

The recommended and faster way is to use the prebuilt version:

# Install CMake 3.25.2
RUN wget "https://cmake.org/files/v3.25/cmake-3.25.2-linux-x86_64.sh" \
&& chmod a+x cmake-3.25.2-linux-x86_64.sh \
&& ./cmake-3.25.2-linux-x86_64.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.25.2-linux-x86_64.sh

warning: Since CMake 3.20 Kitware use a lowercase linux instead of Linux (e.g. CMake 3.19).

Build from source

To build from source you can use the following snippet:

# Install CMake 3.25.2
RUN wget "https://cmake.org/files/v3.25/cmake-3.25.2.tar.gz" \
&& tar xzf cmake-3.25.2.tar.gz \
&& rm cmake-3.25.2.tar.gz \
&& cd cmake-3.25.2 \
&& ./bootstrap --prefix=/usr/local/ \
&& make \
&& make install \
&& cd .. \
&& rm -rf cmake-3.25.2