go-coverage-summary
Action to display Go Code Coverage summary on github workflow summary.
Usage
The only input to the action is the path to the coverage profile file, generated by go test
when run with the -coverprofile
flag. The action does require that the -covermode=atomic
is also provided on the call to go test
. Below is an example of how to call the action.
name: Example
on:
push:
branches-ignore:
- main
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.5'
- name: Run tests
run: go test -cover -covermode=atomic -coverprofile=coverage.out -race ./...
- name: Call action
uses: notmiguelalves/go-coverage-summary@v0.5.0
with:
coverage-file: "coverage.out"
exclusions: "utils,wrapper" # note that this is a comma separated list
Will then create a table in the job summary output containing the coverage for each package. For example:
Package |
Coverage |
github.com/notmiguelalves/anypipe/pkg/dockerutils |
89.2% |
github.com/notmiguelalves/anypipe/pkg/anypipe |
69.8% |