Generate code coverage reports for a C++ project on GitHub Actions using gcovr.
- Generate code coverage reports using gcovr.
- Generate and send reports in Coveralls API format.
- Auto detect and install required dependencies.
- Support coverage report on GCC and LLVM Clang.
- Support files exclusion and fail if coverage is below a specific thresold.
For more information, see action.yml and GitHub Actions guide.
Name | Value Type | Description |
---|---|---|
root |
Path | Root directory of your source files. Defaults to current directory. File names are reported relative to this directory. |
gcov-executable |
Executable name with optional arguments | Use a particular gcov executable. Must match the compiler you are using, e.g. llvm-cov gcov for LLVM Clang. See this. |
excludes |
One or more regular expression | Exclude source files that match these filters. |
fail-under-line |
0 - 100 | Fail if the total line coverage is less than this value. |
xml-out |
Path | Output file of the generated XML coverage report. |
coveralls-out |
Path | Output file of the generated Coveralls API coverage report. |
coveralls-send |
true or false |
Send the generated Coveralls API coverage report to it's endpoint. Defaults to false . |
github-token |
Token | GitHub token of your project. Defaults to github.token . Required for sending Coveralls API coverage report successfully. |
Note: All inputs are optional.
name: test
on:
push:
jobs:
test-coverage:
runs-on: ubuntu-22.04
steps:
- name: Check out this repository
uses: actions/checkout@v4.1.7
- name: Build and test this project
run: |
cmake . -B build
cmake --build build
ctest --test-dir build
- name: Generate a code coverage report
uses: threeal/gcovr-action@v1.0.0
- name: Generate a code coverage report
uses: threeal/gcovr-action@v1.0.0
with:
excludes: |
include/internal/*
src/internal/*
- name: Generate a code coverage report
uses: threeal/gcovr-action@xml-out
with:
xml-out: coverage.xml
- name: Build and test this project
run: |
cmake . -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake --build build
ctest --test-dir build
- name: Generate a code coverage report
uses: threeal/gcovr-action@v1.0.0
with:
gcov-executable: llvm-cov gcov
- name: Generate and send a code coverage report to Coveralls
uses: threeal/gcovr-action@v1.0.0
with:
coveralls-send: true
github-token: ${{ secrets.GITHUB_TOKEN }}
This project is licensed under the terms of the MIT License.
Copyright © 2022-2024 Alfi Maulana