Skip to content

A GitHub Action to report code coverage from LCOV files

License

Notifications You must be signed in to change notification settings

pavelsaman/github-actions-report-lcov

 
 

Repository files navigation

Report code coverage

This GitHub Action reports code coverage from LCOV files. This action includes:

  • failing if a minimum coverage is not met
  • commenting on a pull request
  • commenting on the summary page
  • generating an HTML report as an artifact

Test and Build

Usage

Inputs

  • coverage-files (required): Coverage files to scan (e.g. coverage/lcov.*.info).
  • artifact-name (optional): Name of generated coverage report artifact. Default is no artifact created.
  • minimum-line-coverage (optional): Minimum % coverage to pass check. Default 0.
  • minimum-branch-coverage (optional): Minimum % coverage to pass check. Default 0.
  • minimum-function-coverage (optional): Minimum % coverage to pass check. Default 0.
  • github-token (optional): GitHub token to comment on PR.
  • update-comment (optional): Whether to update existing comment. Default false.
  • install-lcov (optional): Whether lcov should be installed by this action. Default true.
  • comment-on-pr (optional): Whether to create a comment in PR. Default true.

Outputs

  • total-line-coverage: Total line coverage.
  • total-branch-coverage: Total branch coverage.
  • total-function-coverage: Total function coverage.
  • merged-lcov-file: Path to merged LCOV file.
  • html-report-file: Path to generated HTML report.
  • html-report-dir: Path to dir with HTML report.

Example usage

jobs:
  coverage_report:
    name: Generate coverage report
    needs: test-job
    # Linux and macOS runners are supported
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # if running on Windows, please install `lcov` here
      # tar may need to be installed on Windows as well
      #   tar is needed when generating an html report

      - name: Report code coverage
        uses: pavelsaman/github-actions-report-lcov@v5
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          coverage-files: coverage/lcov.*.info
          minimum-line-coverage: 90
          minimum-branch-coverage: 90
          minimum-function-coverage: 90
          update-comment: 'true'

Limitations

The action works out of the box with Linux and macOS runners. If you want to use it on Windows runners, please install lcov before running this action in a workflow.

Contributing

Initial setup:

nvm use
make install

After source code changes, format, lint, and build the project with:

make build

Then push to remote. Then create a new tag or move the latest tag. You can use Create new version workflow for creating a new version.

About

A GitHub Action to report code coverage from LCOV files

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 97.2%
  • Makefile 2.0%
  • Shell 0.8%