NOTE: Codacy now supports Golang coverage reports directly. This tool is therefore no longer required to submit coverage reports.
godacov is a command-line tool to publish test coverage reports generated with go test -coverprofile=<filename>
to Codacy.
Install godacov using go get
$ go get github.com/schrej/godacov
Retrieve a project token from codacy from Your Project > Settings > Integrations > Project API
.
Run your tests and generate the coverage report.
go test -coverprofile=coverage.out
Finally publish the results to Codacy using
godacov -t <project token> -r ./coverage.out -c <current commit id>
If you are using Travis CI you should add your project token as a secret environment variable, then run the following command in your script. Remember that you have to append -coverprofile=coverage.out
to your test command.
godacov -t $CODACY_TOKEN -r ./coverage.out -c $TRAVIS_COMMIT
Usage:
godacov [flags]
Flags:
-i, --allow-insecure Allow insecure connection to base URL
-a, --api-base string The base URL of the codacy API server to use (default "https://api.codacy.com")
-c, --commit string The hash of the commit to provide coverage for
-h, --help help for godacov
-r, --report string coverage report file generated by 'go test'
-t, --token string Codacy project token