Coder Social home page Coder Social logo

threeal / gcovr-action Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 5.0 19.05 MB

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

Home Page: https://github.com/marketplace/actions/gcovr-action

License: MIT License

TypeScript 95.66% JavaScript 4.34%
actions coverage coverage-report cpp gcc gcov ci code-quality test-coverage testing

gcovr-action's Introduction

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

gcovr-action's People

Contributors

dependabot[bot] avatar threeal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gcovr-action's Issues

Modify Workflow to Test Coveralls Send Only on Ubuntu

This issue highlights a problem where apparently the solution in #144 is not sufficient to address the problem raised in #143. To resolve this, the test for Coveralls send should not run on a matrix OS, as each matrix OS will send the report individually, which Coveralls will treat as only one report. Consequently, it is suggested to modify the Coveralls send test to only run on the Ubuntu runner.

Colorized Output

Colorized output, e.g.:

  • Error or failed is using red color.
  • Warning is using yellow color.
  • Done or success if using green color.

We can use chalk package to achieve this.

Separate `tsconfig.json` For ESLint

Add a separate tsconfig.json named tsconfig.eslint.json to be used by ESLint.
This could fix the problem that requires us to ended up mocked ansi-styles package.
See this for the config example.

Use Pipx Install Action to Install Gcovr

This issue suggests utilizing the Pipx Install Action to install gcovr using pipx on GitHub Actions. This change will replace the @actions-kit/pip package that was previously utilized for installing gcovr using pip.

To utilize the Pipx Install Action before that package is released, we can use the dist branch of that repository, which contains the compiled source. This way, it can be directly included using the GitHub URL.

Modify Workflow to Test Coveralls Send Once

This issue highlights a problem in the latest workflow run, where the Coveralls send test is failing. It appears that sending a report to Coveralls more than once is currently prohibited, as evident in this run.

To address this, we can modify the job for testing the Coveralls send to only submit the report once.

add `exclude` input option

Add exclude input option, as specified in the gcovr's help

$ gcovr --help
...
  -e EXCLUDE, --exclude EXCLUDE
                        Exclude source files that match this filter. Can be
                        specified multiple times.
...

Add `fail-under-line` Input Option

Add fail-under-line input option, as specified in the gcovr's help

$ gcovr --help
...
  --fail-under-line MIN
                        Exit with a status of 2 if the total line coverage is
                        less than MIN. Can be ORed with exit status of '--
                        fail-under-branch' option.
...

Audit `package.json` File

This issue suggests auditing the package.json file of this project to follow the convention used in the Action Starter template as seen here.

Other output formats

One deal-breaker for using this action is that it does not support outputting to other formats. Could either add input options for this, or support passing arbitrary args

Remove `latest` Branch

This issue proposes to remove the latest branch, making the main branch the designated latest branch.

Remove Testing

This issue suggests removing testing in this project because currently there's nothing to test when running the test command. We can reintroduce testing later after we have refactored most of the code in this project. This change will close #169.

Better Failed Message

Better message if a run is failed.

E.g.:

image

It's better to catch that error and then log Code coverage is under 70% instead of just telling if python exited with status code 2.

Set Git Attribute for Yarn Lock File

This issue suggests setting the Git attribute for the yarn.lock file. This change should be part of #189, in which the Git attribute of the package-lock.json file should be replaced for the yarn.lock file.

Use `@actions-kit/io`

Use @actions-kit/io, replacing the io directory in this project's source code.
Since the @actions-kit/io is still in development, let's use GitPkg to include it as a Git's sub directory dependency.

Remove Workflow Dependencies

This issue suggests removing dependencies between workflows, especially for sharing step results between workflows by uploading and downloading artifacts.

Remove Distribute Job in Test Workflow

This issue suggests removing the distribute job in the test.yaml workflow in favor of checking out the repository and installing dependencies on each job. This change will speed up the workflow time because the other jobs will no longer depend on the distribute job.

More than one exclude issue.

It there an option to exclude more than one pattern? In the native "gcovr" you can set "exclude" parameter multiple times. It this possible here?

Add Git Attribute

This issue suggests adding a .gitattribute file for setting the attribute of the distribution script and the package lockfile. This change is suggested to follow the convention used in the Action Starter template as seen here.

convention: Moving `v1` tag

A common convention is to have a vX tag that is constantly updated after each minor/patch release. When I looked initially there was no action to do it automatically, but there was an action to parse tag release.

Use Yarn

This issue suggests adopting Yarn as the default package manager, replacing the existing npm. See threeal/nodejs-starter#14 for more information and the rationale behind this suggestion.

Only Run Workflows on Ubuntu

This issue suggests running workflows only on the Ubuntu runner, except if it's obvious that a workflow behavior is not cross-platform and needs to be tested on other platforms.

Add `coveralls-out` Input Option

Add coveralls-out input option to generate code coverage in Coveralls format as specified in the gcovr's help

$ gcovr --help
...
  --coveralls [OUTPUT]  Generate Coveralls API coverage report in this file
                        name. OUTPUT is optional and defaults to --output.
...

Add `xml-out` Input

This issue suggests adding an xml-out input to this action to specify the output path of the coverage report in XML format.

Add `root` input option

Add root input option, as specified in the gcovr's help

$ gcovr --help
...
  -r ROOT, --root ROOT  The root directory of your source files. Defaults to
                        '.', the current directory. File names are reported
                        relative to this root. The --root is the default
                        --filter.
...

Unuse @actions-kit/dev

This issue proposes to remove @actions-kit/dev from the dependencies and directly configure TypeScript, Prettier, ESLint, and Jest from within this project. This will make the project's build and development process more streamlined and less reliant on external packages.

Use @actions-kit/pip

Use @actions-kit/pip, replacing some functions in the pip directory in this project's source code.
Since the @actions-kit/pip is still in development, we can use GitPkg to include it as a Git's sub directory dependency.

Add `gcov-executable` Input Option

Add gcov-executable input option, as specified in the gcovr's help

$ gcovr --help
...
  --gcov-executable GCOV_CMD
                        Use a particular gcov executable. Must match the
                        compiler you are using, e.g. 'llvm-cov gcov' for
                        Clang. Can include additional arguments. Defaults to
                        the GCOV environment variable, or 'gcov': 'gcov'.
...

Separate Workflows for Build and Test

This issue proposes separating the workflow for building and testing the project. This changes mainly is proposed to follow the standard used in the Action Starter template in which there are separate workflows for building and testing the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.