Skip to content
codacy

GitHub Action

Codacy Coverage Reporter

v1.3.0 Latest version

Codacy Coverage Reporter

codacy

Codacy Coverage Reporter

Multi-language coverage reporter for Codacy

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Codacy Coverage Reporter

uses: codacy/[email protected]

Learn more about this action in codacy/codacy-coverage-reporter-action

Choose a version

Codacy Coverage Reporter GitHub Action

Codacy Badge

This GitHub Action uploads coverage reports to Codacy on all commits and pull requests, letting you track code coverage on the Codacy UI. After setting it up, you can optionally enable status checks on pull requests to avoid adding untested code or decreasing coverage.

Coverage metrics displayed on Codacy

Codacy is an automated code review tool that makes it easy to ensure your team is writing high-quality code by analyzing more than 40 programming languages such as PHP, JavaScript, Python, Java, and Ruby. Codacy allows you to define your own quality rules, code patterns and quality settings you'd like to enforce to prevent issues on your codebase.

Learn more about Codacy Coverage
Why do you need to measure code coverage?


Codacy


Uploading coverage to Codacy

Before setting up Codacy Coverage Reporter GitHub Action you must have tests and use tools to generate coverage reports for the source code files in your repository.

To upload coverage to Codacy using the GitHub Action using default settings:

  1. Set up an API token to allow the GitHub Action to authenticate on Codacy:

    ⚠️ Never write API tokens to your configuration files and keep your API tokens well protected, as they grant owner permissions to your projects on Codacy.

  2. Generate a supported code coverage report on each push to your repository.

  3. Add the following to a file .github/workflows/codacy-coverage-reporter.yaml in your repository, where PATH_TO_REPORT is the path to the coverage report:

    name: Codacy Coverage Reporter
    
    on: ["push"]
    
    jobs:
      codacy-coverage-reporter:
        runs-on: ubuntu-latest
        name: codacy-coverage-reporter
        steps:
          - uses: actions/checkout@v2
          - name: Run codacy-coverage-reporter
            uses: codacy/[email protected]
            with:
              project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
              # or
              # api-token: ${{ secrets.CODACY_API_TOKEN }}
              coverage-reports: <PATH_TO_REPORT>
              # or a comma-separated list for multiple reports
              # coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT>
  4. Optionally, to add coverage results to GitHub status checks, configure a quality gate for coverage and enable sending status checks on Codacy.

Parameters

The Codacy GitHub Action is a wrapper for running the Codacy Coverage Reporter CLI and supports the following subset of parameters available for the command report:

Parameter Description Recommended value
project-token Project API token ${{ secrets.CODACY_PROJECT_TOKEN }}
api-token Account API token, an alternative to project-token when setting up multiple repositories ${{ secrets.CODACY_API_TOKEN }}
coverage-reports Optional path or glob pattern to the coverage report relative to the repository root, or a comma-separated list for multiple reports ''
language Optionally associate a language with your coverage report(s) ''
force-coverage-parser Optionally force using a specific coverage report parser ''
coverage-reporter-version Optionally force using a specific coverage reporter version ''