Check test coverage and generate reports for C/C++ projects using gcovr on GitHub Actions.
- Check test coverage for C/C++ projects compiled with GCC and LLVM Clang.
- Generate test coverage reports in HTML, Cobertura, and Coveralls formats.
- Support file exclusion and fail if coverage is below a specific threshold.
- Support sending reports directly to Coveralls.
- Automatically install and cache the gcovr program on GitHub Actions.
The following table lists all available inputs supported by this action. Please note that these inputs are optional.
| Name | Value Type | Description | 
|---|---|---|
| root | Path | Root directory of your source files. Defaults to the current directory. File names are reported relative to this directory. | 
| gcov-executable | Executable name with optional arguments | Use a specific gcov executable. It must match the compiler you are using, e.g., llvm-cov gcovfor LLVM Clang. | 
| excludes | One or more regular expression patterns | Exclude source files that match these filters. | 
| filter | One or more regular expression patterns | Filter source files that match these filters. | 
| fail-under-line | 0 - 100 | Fail if the total line coverage is less than this value. | 
| fail-under-branch | 0 - 100 | Fail if the total branch coverage is less than this value. | 
| fail-under-function | 0 - 100 | Fail if the total function coverage is less than this value. | 
| fail-under-decision | 0 - 100 | Fail if the total decision coverage is less than this value. | 
| html-out | Path | Output file for the generated HTML report. | 
| html-details | trueorfalse | Enable to add annotated source code reports to the HTML report. Defaults to false. | 
| html-theme | String | Override the default color theme for the HTML report. | 
| html-title | String | Override the default title for the HTML report. | 
| xml-out | Path | Output file for the generated Cobertura report. | 
| coveralls-out | Path | Output file for the generated Coveralls report. | 
| coveralls-send | trueorfalse | Send the generated Coveralls report to its endpoint. Defaults to false. | 
| decisions | trueorfalse | Report the decision coverage in HTML, JSON, and summary reports. Defaults to false. | 
| calls | trueorfalse | Report the calls coverage in HTML and summary reports. Defaults to false. | 
| jobs | true,false, or number | Set the number of threads to use in parallel. When set to truewithout a number, uses all available processors. Defaults tofalse. | 
| print-summary | trueorfalse | Print a small report to stdout showing line, function, branch percentage coverage with optional decision & call coverage. This is in addition to other reports. Defaults to false. | 
| github-token | Token | GitHub token for your project. Defaults to github.token. Required for successfully sending the Coveralls report to its endpoint. | 
| working-directory | Path | The working directory where gcovr should be executed. | 
| cobertura-out | Path | Generate a Cobertura XML report. | 
| cobertura-pretty | trueorfalse | Pretty-print the Cobertura XML report. Defaults to false. | 
| jacoco-out | Path | Output file for the generated JaCoCo report. | 
| json-out | Path | Generate a JSON report. | 
| json-pretty | trueorfalse | Pretty-print the JSON report. Defaults to false. | 
| json-summary-out | Path | Generate a JSON summary report. | 
| json-summary-pretty | trueorfalse | Pretty-print the JSON SUMMARY report. Defaults to false. | 
| lcov-out | Path | Generate LCOV coverage report. | 
| sonarqube-out | Path | Generate sonarqube generic coverage report. | 
| txt-out | Path | Output file for the generated text report. | 
This example demonstrates how to use this action to check test coverage of a C/C++ project on GitHub Actions. By default, if no other inputs are given, this action will print the test coverage report to the log.
name: test
on:
  push:
jobs:
  test-project:
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout Project
        uses: actions/[email protected]
      - name: Build Project
        uses: threeal/[email protected]
      - name: Test Project
        uses: threeal/[email protected]
      - name: Check Test Coverage
        uses: threeal/[email protected]To specify the minimum required test coverage threshold, set the fail-under-line, fail-under-branch, and/or fail-under-function inputs with a number ranging from 0-100 indicating the percentage of the threshold. For example, the following will check and assert if the test line coverage is above 80%:
- name: Check Test Coverage
  uses: threeal/[email protected]
  with:
    fail-under-line: 80Specify the html-out input to generate the test coverage report in HTML format:
- name: Generate HTML Report
  uses: threeal/[email protected]
  with:
    html-out: coverage.htmlOther options are also available to customize the generated HTML output:
- name: Generate HTML Report
  uses: threeal/[email protected]
  with:
    html-out: coverage.html
    html-details: true
    html-title: My Project Test Coverage Report
    html-theme: github.greenSpecify the xml-out input to generate the test coverage report in Cobertura format:
- name: Generate Cobertura Report
  uses: threeal/[email protected]
  with:
    xml-out: cobertura.xmlSpecify the coveralls-out input to generate the test coverage report in Coveralls format:
- name: Generate Coveralls Report
  uses: threeal/[email protected]
  with:
    coveralls-out: coveralls.jsonRather than outputting the report as a file, it can also be directly sent to Coveralls by setting the coveralls-send input to true:
- name: Send Coveralls Report
  uses: threeal/[email protected]
  with:
    coveralls-send: trueBy default, gcovr works well with projects compiled using GCC. However, for projects compiled using LLVM Clang, the gcov-executable input must correctly specify the gcov program that works with that compiler. See this for more details.
- name: Check Test Coverage
  uses: threeal/[email protected]
  with:
    gcov-executable: llvm-cov gcovThis project is licensed under the terms of the MIT License.
Copyright © 2022-2025 Alfi Maulana