Skip to content

Commit

Permalink
build: add 'make coveralls' to upload code coverage to Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
d4l3k committed Jul 20, 2016
1 parent 040e3b9 commit 4af4f72
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions GLOCKFILE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmd github.com/axw/gocov/gocov
cmd github.com/client9/misspell/cmd/misspell
cmd github.com/cockroachdb/c-protobuf/cmd/protoc
cmd github.com/cockroachdb/cockroach/cmd/protoc-gen-gogoroach
Expand All @@ -8,6 +9,7 @@ cmd github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
cmd github.com/jteeuwen/go-bindata/go-bindata
cmd github.com/kisielk/errcheck
cmd github.com/kkaneda/returncheck
cmd github.com/mattn/goveralls
cmd github.com/mibk/dupl
cmd github.com/opennota/check/cmd/varcheck
cmd github.com/robfig/glock
Expand All @@ -19,6 +21,7 @@ cmd honnef.co/go/unused/cmd/unused
github.com/Sirupsen/logrus f3cfb454f4c209e6668c95216c4744b8fddb2356
github.com/VividCortex/ewma 8b9f1311551e712ea8a06b494238b8a2351e1c33
github.com/agtorre/gocolorize f42b554bf7f006936130c9bb4f971afd2d87f671
github.com/axw/gocov 54b98cfcac0c63fb3f9bd8e7ad241b724d4e985b
github.com/biogo/store 913427a1d5e89604e50ea1db0f28f34966d61602
github.com/chzyer/readline 683bf8ff7cd77265a852553c3c3e37a464339049
github.com/client9/misspell 940f19ff686fdd0ee8395209994d4e243cb81e37
Expand Down Expand Up @@ -58,6 +61,7 @@ github.com/lib/pq 4dd446efc17690bc53e154025146f73203b18309
github.com/lightstep/lightstep-tracer-go 42c31c53ad6e190563d3a733155a43f10f0691f8
github.com/mattn/go-isatty 56b76bdf51f7708750eac80fa38b952bb9f32639
github.com/mattn/go-runewidth d6bea18f789704b5f83375793155289da36a3c7f
github.com/mattn/goveralls f4d273b02ce1b4e48acf3662b717aa987bfc4118
github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c
github.com/mibk/dupl 415e882ea21ca7012cc49906cb338f34d2d4b4d6
github.com/montanaflynn/stats 60dcacf48f43d6dd654d0ed94120ff5806c5ca5c
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ $(GLOCK):
@unset GIT_WORK_TREE; $(GLOCK) sync github.com/cockroachdb/cockroach
touch $@

.PHONY: coveralls
coveralls:
@build/coveralls.sh

include .bootstrap

endif
35 changes: 35 additions & 0 deletions build/coveralls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
if [ -n "${CIRCLE_ARTIFACTS-}" ]; then
outdir="${CIRCLE_ARTIFACTS}"
elif [ -n "${TMPDIR-}" ]; then
outdir="${TMPDIR}"
else
outdir="/tmp"
fi

coverage_dir="${outdir}/coverage"
coverage_profile="${coverage_dir}/coverage.out"
coverage_mode=set

rm -rf "$coverage_dir"
mkdir -p "$coverage_dir"

# Run "make coverage" on each package.
for pkg in $(go list ./...); do
f="${coverage_dir}/$(echo $pkg | tr / -).cover"
touch $f
time ${builder} make coverage \
PKG="$pkg" \
TESTFLAGS="-v -coverprofile=$f -covermode=$coverage_mode" | \
tee "${outdir}/coverage.log"
done

# Merge coverage profiles.
echo "mode: $coverage_mode" > "$coverage_profile"
grep -h -v "^mode:" "$coverage_dir"/*.cover >> "$coverage_profile"

# Upload profiles to Coveralls.
goveralls \
-coverprofile="$coverage_profile" \
-ignore='*/*.pb.go,*/*/*.pb.go' \
-service=teamcity \
-repotoken=$COVERALLS_TOKEN

0 comments on commit 4af4f72

Please sign in to comment.