Skip to content

Warning

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

go-test-coverage

Actions
go-test-coverage is a tool designed to report issues when test coverage falls below a specified threshold
v2.4.0
Star (121)

go-test-coverage

test action-test lint coverage Go Report Card Release

go-test-coverage is tool which reports issues when test coverage is below set threshold.

Usage

name: Go test coverage check
runs-on: ubuntu-latest
steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-go@v3
  
  - name: generate test coverage
    run: go test ./... -coverprofile=./cover.out

  - name: check test coverage
    uses: vladopajic/go-test-coverage@v2
    with:
      # Configure action using config file (option 1)
      config: ./.testcoverage.yml
      
      # Configure action by specifying input parameters individually (option 2)
      profile: cover.out
      local-prefix: github.com/org/project
      threshold-file: 80
      threshold-package: 80
      threshold-total: 95

Config

Example of .testcoverage.yml config file:

# (mandatory) 
# Path to coverprofile file (output of `go test -coverprofile` command)
profile: cover.out

# (optional) 
# When specified reported file paths will not contain local prefix in the output
local-prefix: "github.com/org/project"

# Holds coverage thresholds percentages, values should be in range [0-100]
threshold:
  # (optional; default 0) 
  # The minimum coverage that each file should have
  file: 80

  # (optional; default 0) 
  # The minimum coverage that each package should have
  package: 80

  # (optional; default 0) 
  # The minimum total coverage project should have
  total: 95

Coverage Badge

Repositories which use go-test-coverage action in their workflows could easily create beautiful coverage badge and embed them in markdown files (eg. coverage).

Read instructions on creating coverage badge here.

Contribution

All contributions are useful, whether it is a simple typo, a more complex change, or just pointing out an issue. We welcome any contribution so feel free to open PR or issue.

go-test-coverage is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

go-test-coverage is a tool designed to report issues when test coverage falls below a specified threshold
v2.4.0

go-test-coverage is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.