Codecov Go Example
This repository serves as an example on how to use Codecov Global for Go.
Note: use
-covermode=atomicor-covermode=countto show how many times a statement was executed.
Add to your .travis.yml file.
language: go
go:
- 1.8.x
- tip
before_install:
- go get -t -v ./...
script:
- go test -race -coverprofile=coverage.txt -covermode=atomic
after_success:
- bash <(curl -s https://codecov.io/bash)
- All other CI you can simply run
bash <(curl -s https://codecov.io/bash).-raceis a suggestion, not required. Learn more at https://blog.golang.org/race-detector
Set
CODECOV_TOKENin your environment variables.
Add to your .travis.yml file.
after_success:
- bash <(curl -s https://codecov.io/bash) -t uuid-repo-tokenOr you can set the environment variable
CODECOV_TOKEN=uuid-repo-tokenand remove the-tflag
If you see this
cannot use test profile flag with multiple packagesthen use this shell template to execute your tests and store coverage output
#!/usr/bin/env bash
set -e
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
doneThen run this file as your test (ex. ./test.sh)
View source and learn more about Codecov Global Uploader
Need help? Contact support https://github.com/codecov/support