Skip to content

Add Github action workflow #29

Add Github action workflow

Add Github action workflow #29

Workflow file for this run

# This file is part of CMake-codecov.
#
# Copyright (c)
# 2015-2020 RWTH Aachen University, Federal Republic of Germany
#
# See the LICENSE file in the package base directory for details
#
# Written by Alexander Haase, alexander.haase@rwth-aachen.de
#
name: CMake-codecov CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
cmake_version: [4.0.1, 3.31.7, 3.28.6, 3.26.6, 3.21.7, 3.20.6, 3.16.9, 3.12.4, 3.10.3]
os: [ubuntu-24.04]
compiler: [gcc, clang]
generator: [Ninja, Unix Makefiles]
# CMake-Codecov relies on compiling with absolute paths, but CMake uses absolute paths
# with Ninja only starting with 3.21, so exclude older (non-supported) versions
exclude:
- cmake_version: 3.20.6
generator: Ninja
- cmake_version: 3.16.9
generator: Ninja
- cmake_version: 3.12.4
generator: Ninja
- cmake_version: 3.10.3
generator: Ninja
# Additionally test Ubuntu and macOS with default packages
include:
- os: ubuntu-22.04
cmake_version: default
generator: Unix Makefiles
compiler: gcc
- os: ubuntu-22.04
cmake_version: default
generator: Unix Makefiles
compiler: clang
- os: ubuntu-22.04
cmake_version: default
generator: Ninja
compiler: gcc
- os: ubuntu-22.04
cmake_version: default
generator: Ninja
compiler: clang
- os: macos-latest
compiler: clang
cmake_version: default
generator: Unix Makefiles
- os: macos-latest
compiler: clang
cmake_version: default
generator: Ninja
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install lcov, compilers on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y lcov gfortran ${{ matrix.compiler }}
- name: Install default CMake
if: runner.os == 'Linux' && matrix.cmake_version == 'default'
run: |
sudo apt-get update
sudo apt-get install -y cmake
- name: Install specific CMake version
if: runner.os == 'Linux' && matrix.cmake_version != 'default'
run: |
sudo apt-get update
sudo apt-get install -y wget
wget https://github.com/Kitware/CMake/releases/download/v${{ matrix.cmake_version }}/cmake-${{ matrix.cmake_version }}-linux-x86_64.tar.gz
tar -xzf cmake-${{ matrix.cmake_version }}-linux-x86_64.tar.gz --strip-components=1 -C cmake
sudo cp -r cmake/* /usr/local/
- name: Install CMake, lcov on macOS
if: runner.os == 'macOS'
run: |
brew update
brew install cmake lcov
- name: Print CMake version
run: cmake --version
- name: Configure and build
run: |
mkdir build && cd build
cmake .. -DCMAKE_C_COMPILER="${{ matrix.compiler }}" -G "${{ matrix.generator }}" -DENABLE_COVERAGE=On
cmake --build .
cmake --build . --target test
cmake --build . --target gcov
cmake --build . --target lcov
# - name: Codecov upload
# uses: codecov/codecov-action@v5
# with:
# name: codecov-coverage
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true