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. |
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. Should be set to secrets.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-latest
steps:
- name: Check out this repository
uses: actions/[email protected]
- 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@latest
Note: You can replace
@latest
with any version you like. See this.
- name: Generate a code coverage report
uses: threeal/gcovr-action@latest
with:
excludes: |
include/internal/*
src/internal/*
- 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@latest
with:
gcov-executable: llvm-cov gcov
- name: Generate and send a code coverage report to Coveralls
uses: threeal/gcovr-action@latest
with:
coveralls-send: true
github-token: ${{ secrets.GITHUB_TOKEN }}
This project is licensed under the terms of the MIT License.
Copyright © 2022-2023 Alfi Maulana