Skip to content

threeal/gcovr-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Gcovr Action

Generate code coverage reports for a C++ project on GitHub Actions using gcovr.

Features

  • 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.

Usage

For more information, see action.yml and GitHub Actions guide.

Inputs

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.

Examples

name: test
on:
  push:
jobs:
  test-coverage:
    runs-on: ubuntu-22.04
    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/[email protected]

Exclude Source Files

- name: Generate a code coverage report
  uses: threeal/[email protected]
  with:
    excludes: |
      include/internal/*
      src/internal/*

Output XML Report

- name: Generate a code coverage report
  uses: threeal/gcovr-action@xml-out
  with:
    xml-out: coverage.xml

Using LLVM Clang

- 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/[email protected]
  with:
    gcov-executable: llvm-cov gcov

Send to Coveralls

- name: Generate and send a code coverage report to Coveralls
  uses: threeal/[email protected]
  with:
    coveralls-send: true
    github-token: ${{ secrets.GITHUB_TOKEN }}

License

This project is licensed under the terms of the MIT License.

Copyright © 2022-2024 Alfi Maulana