diff --git a/.gitignore b/.gitignore index 289dfa865c..cdcab102af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env *.test +*.coverprofile diff --git a/.travis.yml b/.travis.yml index 0a9ff4053b..b095af67f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,11 @@ before_install: - go get -u github.com/stretchr/testify/require + # Install code coverage / coveralls tooling + - go get -u golang.org/x/tools/cmd/cover + - go get -u github.com/modocache/gover + - go get -u github.com/mattn/goveralls + # Unpack and start the Stripe API stub so that the test suite can talk to it - | if [ ! -d "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" ]; then @@ -35,5 +40,12 @@ matrix: script: - make + - make coverage + +after_script: + # Merge all coverage reports located in subdirectories and put them under: gover.coverprofile + - gover + # Send code coverage report to coveralls.io + - goveralls -service=travis-ci -coverprofile=gover.coverprofile sudo: false diff --git a/Makefile b/Makefile index c2cadaed60..15e3748a42 100644 --- a/Makefile +++ b/Makefile @@ -14,3 +14,11 @@ test: vet: go vet ./... + +coverage: + # go currently cannot create coverage profiles when testing multiple packages, so we test each package + # independently. This issue should be fixed in Go 1.10 (https://github.com/golang/go/issues/6909). + go list ./... | xargs -n1 -I {} -P 4 go test -covermode=count -coverprofile=../../../{}/profile.coverprofile {} + +clean: + find . -name \*.coverprofile -delete diff --git a/README.md b/README.md index fa211b783b..6be9c73429 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# Go Stripe [![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/stripe/stripe-go) [![Build Status](https://travis-ci.org/stripe/stripe-go.svg?branch=master)](https://travis-ci.org/stripe/stripe-go) +# Go Stripe + +[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/stripe/stripe-go) +[![Build Status](https://travis-ci.org/stripe/stripe-go.svg?branch=master)](https://travis-ci.org/stripe/stripe-go) +[![Coverage Status](https://coveralls.io/repos/github/stripe/stripe-go/badge.svg?branch=master)](https://coveralls.io/github/stripe/stripe-go?branch=master) ## Summary