From fec63adf5f55be89b788a1cfb90ab2746516eb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 12 Jun 2024 17:50:07 +0200 Subject: [PATCH 1/2] Add CI runners on emulated hardware Use a GitHub action to install Alpine Linux for different, less common architectures that are emulated with qemu (apart from x86). Additionally, Alpine Linux is one of those distributions that are based on musl (instead of glibc). This increases coverage for different configurations in CI. --- .github/workflows/emulated.yml | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/emulated.yml diff --git a/.github/workflows/emulated.yml b/.github/workflows/emulated.yml new file mode 100644 index 0000000..1d8dc08 --- /dev/null +++ b/.github/workflows/emulated.yml @@ -0,0 +1,68 @@ +name: arch-emu +on: + workflow_dispatch: + push: + pull_request: + +concurrency: ci-arch-emu-${{ github.ref }} + +jobs: + + alpine: + runs-on: ubuntu-latest + + defaults: + run: + # Use emulated shell as default + shell: alpine.sh {0} + + strategy: + # Allow other runners in the matrix to continue if some fail + fail-fast: false + + matrix: + # For available CPU architectures, see: + # https://github.com/marketplace/actions/setup-alpine-linux-environment + arch: [x86, aarch64, armv7, ppc64le, riscv64, s390x] + + name: alpine (${{ matrix.arch }}) + + steps: + - name: checkout repository + uses: actions/checkout@v4 + + - name: install dependencies + uses: jirutka/setup-alpine@v1 + with: + arch: ${{ matrix.arch }} + packages: > + bash + build-base + cmake + gfortran + eigen-dev + lapack-dev + + - name: configure + run: | + echo "gcc --version" + gcc --version + echo "gcc -dumpmachine" + gcc -dumpmachine + mkdir -p ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build + cmake \ + -DEXAMPLES=ON \ + -DMPI=OFF \ + -DICB=ON \ + -DEIGEN=ON \ + .. + + - name: build + run: | + cd ${GITHUB_WORKSPACE}/build + cmake --build . + + - name: test + run: | + cd ${GITHUB_WORKSPACE}/build + ctest . || ctest . --rerun-failed --output-on-failure From 416011c701e39d425e98e0d2f20341d639b66cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 12 Jun 2024 19:09:47 +0200 Subject: [PATCH 2/2] CI (Alpine Linux): Use ccache The compilation (especially of the C++ objects) is pretty slow with qemu. Use ccache to speed up build time on subsequent runs. --- .github/workflows/emulated.yml | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/emulated.yml b/.github/workflows/emulated.yml index 1d8dc08..ff29917 100644 --- a/.github/workflows/emulated.yml +++ b/.github/workflows/emulated.yml @@ -38,23 +38,56 @@ jobs: packages: > bash build-base + ccache cmake gfortran eigen-dev lapack-dev + - name: prepare ccache + # create key with human readable timestamp + # used in action/cache/restore and action/cache/save steps + id: ccache-prepare + run: | + echo "key=ccache:alpine:${{ matrix.arch }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT + + - name: restore ccache + # setup the GitHub cache used to maintain the ccache from one job to the next + uses: actions/cache/restore@v4 + with: + # location of the ccache of the chroot in the root file system + path: /home/runner/rootfs/alpine-latest-${{ matrix.arch }}/home/runner/.ccache + key: ${{ steps.ccache-prepare.outputs.key }} + # Prefer caches from the same branch. Fall back to caches from the default branch. + restore-keys: | + ccache:alpine:${{ matrix.arch }}:${{ github.ref }} + ccache:alpine:${{ matrix.arch }} + + - name: configure ccache + env: + CCACHE_MAX: ${{ matrix.ccache-max }} + run: | + test -d ~/.ccache || mkdir ~/.ccache + echo "max_size = 20M" >> ~/.ccache/ccache.conf + echo "compression = true" >> ~/.ccache/ccache.conf + ccache -s + which ccache + - name: configure run: | echo "gcc --version" gcc --version echo "gcc -dumpmachine" gcc -dumpmachine + echo " " mkdir -p ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build cmake \ -DEXAMPLES=ON \ -DMPI=OFF \ -DICB=ON \ -DEIGEN=ON \ + -DCMAKE_C_COMPILER_LAUNCHER="ccache" \ + -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ .. - name: build @@ -62,6 +95,18 @@ jobs: cd ${GITHUB_WORKSPACE}/build cmake --build . + - name: ccache status + continue-on-error: true + run: ccache -s + + - name: save ccache + # Save the cache after we are done (successfully) building + # This helps to retain the ccache even if the subsequent steps are failing. + uses: actions/cache/save@v4 + with: + path: /home/runner/rootfs/alpine-latest-${{ matrix.arch }}/home/runner/.ccache + key: ${{ steps.ccache-prepare.outputs.key }} + - name: test run: | cd ${GITHUB_WORKSPACE}/build