Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Record coverage profiles in Travis builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Nov 2, 2016
1 parent a143757 commit 9a01ce2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ go:
go_import_path: github.com/coreos/kube-aws
script:
- make test
after_success:
- bash <(curl -s https://codecov.io/bash)
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ format:

.PHONY: test
test: build
test -z "$$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)"
go test -v $$(go list ./... | grep -v '/vendor/')
go vet $$(go list ./... | grep -v '/vendor/')
./test

.PHONY: test-with-cover
test-with-cover: build
./test with-cover
24 changes: 23 additions & 1 deletion test
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#!/bin/bash
set -euo pipefail

go test $(go list ./... | grep -v '/vendor/')
default() {
test -z "$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)"
go test -v $(go list ./... | grep -v '/vendor/')
go vet $(go list ./... | grep -v '/vendor/')
}

with-cover() {
test -z "$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)"
for d in $(go list ./... | grep -v '/vendor/'); do
go test -v --race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
go vet $(go list ./... | grep -v '/vendor/')
}

if [ -z ${1+x} ]; then
default
else
"$@"
fi

0 comments on commit 9a01ce2

Please sign in to comment.