Skip to content

ci: fix coverage generation #960

ci: fix coverage generation

ci: fix coverage generation #960

Workflow file for this run

name: Coverage
on:
pull_request:
push:
branches:
- master
jobs:
build:
name: Code Coverage
runs-on: ubuntu-24.04
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Mount vcpkg cache
uses: actions/cache@v4
with:
path: "~/.cache/vcpkg/archives"
key: vcpkg-${{ runner.os }}
- name: Install vcpkg dependencies
run: vcpkg install benchmark civetweb curl[core] gtest zlib
- name: Generate German locale on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get remove -y --purge man-db # avoid time-consuming trigger
sudo apt-get update
sudo apt-get install -y locales
sudo locale-gen de_DE.UTF-8 # used by SerializerTest
- name: Install ninja on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get install -y ninja-build
- name: Install lcov
if: runner.os == 'Linux'
run: |
sudo apt-get install -y lcov
- name: Install lcov 2.3 (which fixes function coverage calculation, https://bugs.launchpad.net/ubuntu/+source/lcov/+bug/2052354)
if: runner.os == 'Linux'
run: |
echo -e "Package: *\nPin: release n=plucky\nPin-Priority: 100" | sudo tee /etc/apt/preferences.d/99-plucky
echo "deb http://azure.archive.ubuntu.com/ubuntu/ plucky main universe" | sudo tee /etc/apt/sources.list.d/ubuntu-plucky.list
sudo apt-get update
sudo apt-get install -y -t plucky lcov
apt-cache policy lcov
- name: "CMake Configure for Unix with vcpkg dependencies"
env:
CFLAGS: "--coverage"
CXXFLAGS: "--coverage"
LDFLAGS: "--coverage"
run: cmake -DUSE_THIRDPARTY_LIBRARIES=OFF "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -GNinja -S ${{ github.workspace }} -B ${{ github.workspace }}/_build
- name: Build
run: cmake --build ${{ github.workspace }}/_build
- name: Test
run: ctest -V -LE Benchmark
working-directory: "${{ github.workspace }}/_build"
- name: Run lcov
run: lcov --capture --directory "${{ github.workspace }}" --output-file coverage.info --no-external --exclude '*/tests/*'
- name: Dump lcov
run: lcov --list coverage.info
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: coverage.info