Skip to content

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

License

Notifications You must be signed in to change notification settings

umitbuyukulcay/gcovr-action

 
 

Repository files navigation

Gcovr Action

latest version license test status

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

Examples

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.

Exclude Source Files

- name: Generate a code coverage report
  uses: threeal/gcovr-action@latest
  with:
    excludes: |
      include/internal/*
      src/internal/*

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/gcovr-action@latest
  with:
    gcov-executable: llvm-cov gcov

Send to Coveralls

- name: Generate and send a code coverage report to Coveralls
  uses: threeal/gcovr-action@latest
  with:
    coveralls-send: true
    github-token: ${{ secrets.GITHUB_TOKEN }}

License

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

Copyright © 2022-2023 Alfi Maulana

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.2%
  • JavaScript 0.8%