Skip to content

CI: Extend msvc pipeline runs #1306

CI: Extend msvc pipeline runs

CI: Extend msvc pipeline runs #1306

Workflow file for this run

# Copyright Dominic (DNKpp) Koepke 2024 - 2025.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)
name: coverage
env:
COBERTURA_REPORT: cobertura.xml
COVERALLS_REPORT: coveralls.json
JSON_REPORT: report.json
JSON_SUMMARY: summary.json
HTML_REPORT_DIR: html/
COVERAGE_ARTIFACT_NAME: coverage-report
on:
push:
branches: [ main, development ]
paths-ignore:
- 'README.md'
- 'docs/**'
pull_request:
branches: [ main, development ]
paths-ignore:
- 'README.md'
- 'docs/**'
jobs:
create-coverage-report:
runs-on: ubuntu-latest
container:
image: "ghcr.io/dnkpp/gcc:15"
steps:
- uses: actions/checkout@v4
- name: Install gcovr
run: |
python -m pip install gcovr==8.3
- name: Print versions
run: |
cmake --version
gcc --version
g++ --version
gcov --version
gcovr --version
- name: Configure
shell: bash
env:
COMPILER_FLAGS: "--coverage;-fno-inline;-fprofile-abs-path;-fkeep-inline-functions;-fkeep-static-functions"
LINKER_FLAGS: "--coverage"
run: |
cmake -S . \
-B build \
--log-level=DEBUG \
-D CMAKE_VERBOSE_MAKEFILE=YES \
-D CMAKE_BUILD_TYPE="Debug" \
-D MIMICPP_TEST_ADDITIONAL_COMPILER_FLAGS=${COMPILER_FLAGS} \
-D MIMICPP_TEST_ADDITIONAL_LINKER_FLAGS=${LINKER_FLAGS} \
-D MIMICPP_ENABLE_ADAPTER_TESTS=YES \
-D MIMICPP_ENABLE_STACKTRACE_TESTS=YES \
-D MIMICPP_CONFIG_EXPERIMENTAL_CATCH2_MATCHER_INTEGRATION=YES \
-D MIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER=YES \
-D MIMICPP_ENABLE_UNICODE_STR_MATCHER_TESTS=YES \
-D MIMICPP_CONFIG_EXPERIMENTAL_PRETTY_TYPES=YES \
-D MIMICPP_CONFIG_EXPERIMENTAL_STACKTRACE=cpptrace \
-D MIMICPP_CONFIG_EXPERIMENTAL_IMPORT_CPPTRACE=OFF
- name: Build
run: |
cmake --build build -j5
- name: Run tests
shell: bash
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
ctest --test-dir build \
-C Debug \
-j4
- name: Run gcovr
run: |
# circumvent "fatal: detected dubious ownership in repository" error
git config --global --add safe.directory ${GITHUB_WORKSPACE}
cd build
gcovr --root .. \
--verbose \
--include "${GITHUB_WORKSPACE}/include/mimic++(_ext)?" \
--filter "${GITHUB_WORKSPACE}/include/mimic++(_ext)?" \
--exclude-lines-by-pattern "\s*(MIMICPP_ASSERT|assert|util::unreachable)\(" \
--exclude-unreachable-branches \
--exclude-function-lines \
--exclude-noncode-lines \
--exclude-throw-branches \
--decisions \
--calls \
--keep \
--txt \
--cobertura ${{env.COBERTURA_REPORT}} --cobertura-pretty \
--html-nested ${{env.HTML_REPORT_DIR}} --html-title "mimic++ Coverage Report" \
--json-summary ${{env.JSON_SUMMARY}} --json-summary-pretty \
--json ${{env.JSON_REPORT}} --json-pretty
mv ${{env.COBERTURA_REPORT}} ..
mv ${{env.HTML_REPORT_DIR}} ..
mv ${{env.JSON_SUMMARY}} ..
mv ${{env.JSON_REPORT}} ..
# Gathering the coveralls.json in one go with all the other reports results in inconsistent reports.
# see: https://github.com/gcovr/gcovr/issues/1074
- name: Create coveralls report
run: |
cd build
gcovr --root .. \
--verbose \
--include "${GITHUB_WORKSPACE}/include/mimic++(_ext)?" \
--filter "${GITHUB_WORKSPACE}/include/mimic++(_ext)?" \
--add-tracefile ../${{env.JSON_REPORT}} \
--coveralls ${{env.COVERALLS_REPORT}} --coveralls-pretty
mv ${{env.COVERALLS_REPORT}} ..
- name: Find gcov-files
shell: bash
run: find . -type f -name "*.gcov"
- name: Upload gcov coverage report artifacts
uses: actions/upload-artifact@v4
with:
name: gcov-files
path: "**/*.gcov"
if-no-files-found: error
- name: Upload generated report artifacts
uses: actions/upload-artifact@v4
with:
name: ${{env.COVERAGE_ARTIFACT_NAME}}
path: |
${{env.COBERTURA_REPORT}}
${{env.COVERALLS_REPORT}}
${{env.JSON_REPORT}}
${{env.JSON_SUMMARY}}
${{env.HTML_REPORT_DIR}}
if-no-files-found: error
codacy-report:
needs: create-coverage-report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{env.COVERAGE_ARTIFACT_NAME}}
- name: Upload coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{secrets.CODACY_PROJECT_TOKEN}}
coverage-reports: ${{env.COBERTURA_REPORT}}
codecov-report:
needs: create-coverage-report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{env.COVERAGE_ARTIFACT_NAME}}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
name: $GITHUB_REPOSITORY
token: ${{secrets.CODECOV_TOKEN}}
files: ${{env.COBERTURA_REPORT}}
fail_ci_if_error: true
verbose: true
coveralls-report:
needs: create-coverage-report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{env.COVERAGE_ARTIFACT_NAME}}
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
file: ${{env.COVERALLS_REPORT}}
# can not use ${{ github.workspace }} here
# see: https://github.com/actions/checkout/issues/785
base-path: "/__w/mimicpp/mimicpp/include"
format: coveralls
debug: true
fail-on-error: true