GitHub Action: go-test-summary
Concept inspired heavily by gotestsum
and GitHub blog on step summaries
This is a GitHub action to run go test
using the json formatted output from the test operation, then parsing
and rendering the output to provide a nice summary. Injecting that into the $GITHUB_STEP_SUMMARY file (which exists as
an environment variable in GitHub runners).
If the test errors, the action will return the same exit code (and the output)
Input |
Default |
Description |
hideUntestedPackages |
false |
Whether to minimise output for packages with no tests |
workingDirectory |
'.' |
Directory where your go.mod file is located |
testDirectories |
'.' |
If you need, you can run tests on newline separated sub-paths |
Usage
In GitHub actions
You should be able to hot-swap your existing go test
step with usage of this GHA like so:
name: on-push-test-and-build-app
on: push
jobs:
test-and-build-app:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout Repo
- name: Setup Go 1.21.0
uses: actions/setup-go@v4
with:
go-version: '^1.21.0'
- - name: Run Go Test
- run: go test ./...
+ - name: Go Test -> Summary
+ uses: dmatryx/go-test-summary@v1.1
- name: Build
run: CGO_ENABLED=0 GOOS=linux go build -o my-app-name .
Output
Across these two images you can see how the collapseable sections will show/hide details - by default everything starts
non-expanded but can toggle at a click.
If you do not specify to hide untested packages, you will have yellow summary sections indicating packages without tests
If you have failing tests, you can dig into the tests and output to see easily what has failed

If you have no problems at all, and have passing tests, and specify to hide untested packages you'll get a more succinct
output like this:

Again, all sections can be toggled. Non-test output, tests, subtests, test output, and anything else that can be hidden
will all be hidden in an expandable section waiting for you to show what you want to see.
If you want to run this locally for some reason
Not really designed to be run locally, but you can grab and compile the binary itself.
The program only requires one environment variable, and that's $GITHUB_STEP_SUMMARY
- This is where the markdown file
will be output to.
It's also worth noting that the Markdown generated is GitHub Flavour Markdown, which may or may not be supported by
whatever you are trying to view it through.
Development
Contributions
I'm all ears, but don't be a douche and declare into the void that the project is abandoned if you don't get a response
to your issue immediately.
Future ideas
- Probably add some tests (oh the irony)
- Provide the coverage output as a file in the repo's wiki
- Maybe re-use the feature from
go-coverage-report
below for coverage buttons
Releases
Releases are generated by a local build, then pushing the binary to the releases
branch. From there, standard Github
release procedure.
Random other references