Browse Source

Added coverage badge

Linking up with codecov.io to show coverage. Added the badge
in the README.
Agniva De Sarker 8 years ago
parent
commit
d1539ef689
4 changed files with 15 additions and 1 deletions
  1. 2 0
      .gitignore
  2. 3 0
      .travis.yml
  3. 9 1
      Makefile
  4. 1 0
      README.md

+ 2 - 0
.gitignore

@@ -22,3 +22,5 @@ _cgo_export.*
 _testmain.go
 
 *.exe
+
+coverage.txt

+ 3 - 0
.travis.yml

@@ -31,4 +31,7 @@ script:
 - make errcheck
 - make fmt
 
+after_success:
+  - bash <(curl -s https://codecov.io/bash)
+
 sudo: false

+ 9 - 1
Makefile

@@ -1,7 +1,15 @@
 default: fmt vet errcheck test
 
+# Taken from https://github.com/codecov/example-go#caveat-multiple-files
 test:
-	go test -v -timeout 60s -race ./...
+	echo "" > coverage.txt
+	for d in `go list ./... | grep -v vendor`; do \
+		go test -v -timeout 60s -race -coverprofile=profile.out -covermode=atomic $$d; \
+		if [ -f profile.out ]; then \
+			cat profile.out >> coverage.txt; \
+			rm profile.out; \
+		fi \
+	done
 
 vet:
 	go vet ./...

+ 1 - 0
README.md

@@ -3,6 +3,7 @@ sarama
 
 [![GoDoc](https://godoc.org/github.com/Shopify/sarama?status.png)](https://godoc.org/github.com/Shopify/sarama)
 [![Build Status](https://travis-ci.org/Shopify/sarama.svg?branch=master)](https://travis-ci.org/Shopify/sarama)
+[![Coverage](https://codecov.io/gh/Shopify/sarama/branch/master/graph/badge.svg)](https://codecov.io/gh/Shopify/sarama)
 
 Sarama is an MIT-licensed Go client library for [Apache Kafka](https://kafka.apache.org/) version 0.8 (and later).