Skip to content

Code Coverage

Code Coverage #2154

Workflow file for this run

#
# Copyright 2023 Antony Peacock
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
name: Code Coverage
on:
schedule:
- cron: "0 2 * * *" # Every day at 02:00 UTC
push:
branches: [main]
pull_request:
branches: [main]
env:
BUILD_TYPE: Debug
COMPILER_VERSION: 12
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Install Latest GCC
shell: bash
run: |
sudo apt install -y g++-${{ env.COMPILER_VERSION }}
sudo rm -f /usr/bin/gcc /usr/bin/g++ /usr/bin/gcov
sudo ln -s /usr/bin/gcov-${{ env.COMPILER_VERSION }} /usr/bin/gcov
sudo ln -s /usr/bin/gcc-${{ env.COMPILER_VERSION }} /usr/bin/gcc
sudo ln -s /usr/bin/g++-${{ env.COMPILER_VERSION }} /usr/bin/g++
- name: Install Lcov
shell: bash
run: |
wget https://github.com/linux-test-project/lcov/archive/refs/tags/v2.0.tar.gz
tar -xvf v2.0.tar.gz
cd lcov-2.0 && sudo make install && cd ..
sudo perl -MCPAN -e 'install Capture::Tiny'
sudo apt-get install -y libdatetime-perl
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Cache Conan Restore
uses: ./.github/actions/conan-cache-restore
with:
os: Linux
build-type: ${{ env.BUILD_TYPE }}
conan-compiler: gcc
compiler-version: ${{ env.COMPILER_VERSION }}
stdlib: libstdc++11
- name: Setup Conan
uses: ./.github/actions/setup-conan
with:
build-type: ${{ env.BUILD_TYPE }}
compiler-type: GCC
compiler-version: ${{ env.COMPILER_VERSION }}
conan-compiler: gcc
stdlib: libstdc++11
cppstd: "20"
- name: Conan Install
shell: bash
run: |
conan install "${{ github.workspace }}" --build missing
- name: Configure CMake
shell: bash
run: |
if [ -f build/generators/conanbuild.sh ]; then
source build/generators/conanbuild.sh
fi
cmake --preset ${{ env.CONAN_CONFIGURE_PRESET }} -DENABLE_CODE_COVERAGE=1
- name: Build
shell: bash
run: |
if [ -f build/generators/conanbuild.sh ]; then
source build/generators/conanbuild.sh
fi
cmake --build --preset ${{ env.CONAN_BUILD_PRESET }}
- name: Test
shell: bash
run: |
if [ -f build/generators/conanbuild.sh ]; then
source build/generators/conanbuild.sh
fi
ctest --preset ${{ env.CONAN_BUILD_PRESET }} --rerun-failed --output-on-failure
- name: Generate Coverage Reports
shell: bash
run: |
if [ -f build/generators/conanbuild.sh ]; then
source build/generators/conanbuild.sh
fi
cmake --build --preset ${{ env.CONAN_BUILD_PRESET }} --target coverage
cmake --build --preset ${{ env.CONAN_BUILD_PRESET }} --target coverage-lcov
cmake --build --preset ${{ env.CONAN_BUILD_PRESET }} --target coverage-cobertura
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7.0.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ${{ github.workspace }}/build/${{ env.BUILD_TYPE }}/coverage/cobertura_coverage.xml
fail_ci_if_error: true
verbose: true
- name: Cache Conan Save
uses: ./.github/actions/conan-cache-save