Skip to content

CI: create a separate docker Image based on the gr4 build image #314

CI: create a separate docker Image based on the gr4 build image

CI: create a separate docker Image based on the gr4 build image #314

Workflow file for this run

name: CMake
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
buildAndPublishDocker:
name: "Update the docker container if it is modified"
runs-on: "ubuntu-latest"
outputs:
container: ${{ steps.docker-label.outputs.label }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
if: github.event_name == 'push'
with:
fetch-depth: 0
- name: Check if dockerfile was modified
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
docker:
- 'docker/Dockerfile'
#TODO: check if the underlying docker container is newer than the current one
- name: Set up Docker Label
id: docker-label
run: |
if [ ${{ steps.changes.outputs.docker == 'true' && github.event_name != 'push' }} = "true" ]; then
echo "label=ghcr.io/fair-acc/gr-digitizers-build-container:${GITHUB_HEAD_REF/\//-}" >> "$GITHUB_OUTPUT"
else
echo "label=ghcr.io/fair-acc/gr-digitizers-build-container:latest" >> "$GITHUB_OUTPUT"
fi
- name: Set up Docker Buildx
if: steps.changes.outputs.docker == 'true'
uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: steps.changes.outputs.docker == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
if: steps.changes.outputs.docker == 'true'
with:
context: "{{defaultContext}}:docker"
push: true
tags: ${{ steps.docker-label.outputs.label }}
build:
name: "${{ matrix.compiler.cc }} | ${{ matrix.cmake-build-type }}"
needs: buildAndPublishDocker
runs-on: "ubuntu-latest"
container:
image: "${{ needs.buildAndPublishDocker.outputs.container }}"
strategy:
fail-fast: false
matrix:
compiler:
- cc: gcc-14
cxx: g++-14
- cc: clang-18
cxx: clang++-18
cmake_flags: "-DCMAKE_LINKER=/usr/bin/clang-18"
- cmake_wrapper: emcmake
cc: emcc
cmake_flags: " -DENABLE_PICOSCOPE=FALSE -DENABLE_TIMING=FALSE -DENABLE_COVERAGE=OFF -DCMAKE_CROSSCOMPILING_EMULATOR=${SYSTEM_NODE}"
cmake-build-type: [ Release, Debug ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@v4
env:
cache-name: cache-fetchContent-cache
with:
path: "/__w/gr-digitizers/build/_deps"
key: "${{ matrix.compiler.cc }}-${{ matrix.cmake-build-type }}-${{ hashFiles('CMakeLists.txt') }}"
- name: Configure
if: matrix.compiler.cmake_wrapper == null
shell: bash
env:
CC: "${{ matrix.compiler.cc }}"
CXX: "${{ matrix.compiler.cxx }}"
CMAKE_EXPORT_COMPILE_COMMANDS: "ON"
run: |
cmake -S . -B ../build -DDISABLE_EXTERNAL_DEPS_WARNINGS=ON -DENABLE_PICOSCOPE=TRUE -DENABLE_TIMING=TRUE -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DENABLE_COVERAGE=${{ matrix.compiler.cc == 'gcc-14' && matrix.cmake-build-type == 'Debug'}} ${{ matrix.compiler.cmake_flags }}
- name: Configure CMake Emscripten
if: matrix.compiler.cmake_wrapper == 'emcmake'
shell: bash
run: |
export SYSTEM_NODE=`which node` # use system node instead of old version distributed with emsdk for threading support
$EMSDK_HOME/emsdk activate $EMSDK_VERSION
source $EMSDK_HOME/emsdk_env.sh
${{ matrix.compiler.cmake_wrapper }} cmake -S . -B ../build -DDISABLE_EXTERNAL_DEPS_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} ${{ matrix.compiler.cmake_flags }}
- name: Build
if: matrix.compiler.cmake_wrapper == null
shell: bash
run: |
cmake --build ../build
- name: Build
if: matrix.compiler.cmake_wrapper == 'emcmake'
shell: bash
run: |
source $EMSDK_HOME/emsdk_env.sh
cmake --build ../build
- name: execute tests
if: matrix.compiler.cc != 'gcc-14' || matrix.cmake-build-type != 'Debug'
shell: bash
run: |
cd ../build
ctest --output-on-failure
- name: execute tests with coverage
if: matrix.compiler.cc == 'gcc-14' && matrix.cmake-build-type == 'Debug'
env:
DISABLE_SENSITIVE_TESTS: 1 # disables tests which are sensitive to execution speed and will not run with instrumented code
shell: bash
run: |
cd ../build
cmake --build . --target coverage
- name: Run sonar-scanner
if: matrix.compiler.cc == 'gcc-14' && matrix.cmake-build-type == 'Debug'
shell: bash
env:
SONAR_HOST_URL: https://sonarcloud.io
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sonar-scanner