Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

GitHub Action






Very simple action to run code coverage checking for go projects


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


- name: paloaltonetworks/cov

uses: PaloAltoNetworks/cov@2.0.0

Learn more about this action in PaloAltoNetworks/cov
Choose a version


Cov is a simple code coverage checker for Golang. It's like codacy or codecov (at least regarding features that people usually want), but not SaaS, in a few lines of code.

It has no reports other than a tree view showing which package is up to standard and which are not, the coverage and the required threshold. The idea is to block merging and let people fix locally the coverage with any tool they like.

It will report as a status check the status of the run.

Github action

This repository contains a Github action that can be used directly with your Github workflow. You need to make sure one of your steps generates a coverage file (usually using go test -coverprofile=coverage.out) then add a new step:

    name: build-go
        - master
        - uses: actions/checkout@v3
        - uses: actions/setup-go@v3
        - name: test
          run: go test -coverprofile=coverage.out ./...
        - uses: PaloAltoNetworks/cov@1.0.0


There are several parameters you can tweak:

Repository main branch

The tool needs to know which branch is your main one in order to be able to run coverage on the pull requests patch. (default: main).

uses: PaloAltoNetworks/cov@1.0.0
  main_branch: master

Coverage file

The tool needs to know where your coverage file has been generated. The path is relative to your repository root (default: coverage.go).

uses: PaloAltoNetworks/cov@1.0.0
  cov_file: unit_coverage.out

Coverage threshold

You can configure what is the minimum coverage target a patch must have in order to be considered up to standard. Note that you must give the percentage as a string. (default: 70)

uses: PaloAltoNetworks/cov@1.0.0
  cov_threshold: "80"

Cov version

This is a debugging flag that allows to force the action to use a different version of the cov tool. You should not need to touch this. (default: ${{github.action_ref}})

uses: PaloAltoNetworks/cov@1.0.0
  cov_version: master

Ignore some files

If you have some code you would like cov to ignore (for instance, autogenerated or example code), you can create a file named .covignore at the root of your repository. The syntax uses classic glob syntax.

Note that cov uses the full go package name. So you need to either write the full package, or use a **/prefix.*

Local installation

You can install cov locally:

go install

Or you can grab a release from the releases page.


Analyzes coverage

  cov cover.out... [flags]

  -b, --branch string             The branch to use to check the patch coverage against. Example: master
  -f, --filter strings            The filters to use for coverage lookup
  -h, --help                      help for cov
  -i, --ignore strings            Define patterns to ignore matching files.
  -q, --quiet                     Do not print details, just the verdict
      --send-status string        If set, send a status check. format: [repo]/[owner]@[sha]
      --send-token string         If set, use this token to send the status. If empty, $GITHUB_TOKEN will be used
  -t, --threshold int             The target of coverage in percent that is requested
  -e, --threshold-exit-code int   Set the exit code on coverage threshold miss (default 1)
      --version                   show version

When the --branch flag is used, a diff will be done between your current branch and the given branch to identify the files you changed, and only look for the coverage of that diff.

You can pass several coverage files, they all will be merged.

You can filter for a given package or any substring.

When the --threshold flag is set, cov will check if the coverage is greater or equal to that value. It will exit with the code passed as --threshold-exit-code.

You can ignore files matching some patterns using the --ignore option. If you use this parameter, the .covignore file will be ignored.


Show coverage for all coverage files:

cov *.out

Show coverage for a pull request against master:

cov --branch master coverage.out

Ignore all files in autogen/api and examples:

cov --ignore "**/autogen/api/*" --ignore "**/examples/*" coverage.out

Check for a minimum coverage, but don't exit with code 1:

cov --threshold 80 --threshold-exit-code 0 coverage.out