diff --git a/.travis.yml b/.travis.yml index a97eb7743c..266bbf8692 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ language: go - go: - 1.6.3 go_import_path: k8s.io/minikube - -# We shouldn't need to install anything because we use vendoring. install: -- echo "Don't run anything." - -# Run unit tests and linters. -script: make test + - echo "Don't run anything." +script: + - make test +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index f4c2b06c23..47e3904e82 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Minikube [![Build Status](https://travis-ci.org/kubernetes/minikube.svg?branch=master)](https://travis-ci.org/kubernetes/minikube) +[![codecov](https://codecov.io/gh/aaron-prindle/minikube/branch/master/graph/badge.svg)](https://codecov.io/gh/aaron-prindle/minikube) ## What is Minikube? diff --git a/test.sh b/test.sh index dd6cf5f10a..24c0b9f44e 100755 --- a/test.sh +++ b/test.sh @@ -25,11 +25,22 @@ else PYTHON="docker run --rm -it -v $(pwd):/minikube -w /minikube python python" fi -# Run "go test" on packages that have test files. + +COV_FILE=coverage.txt +COV_TMP_FILE=coverage_tmp.txt + +# Run "go test" on packages that have test files. Also create coverage profile echo "Running go tests..." cd ${GOPATH}/src/${REPO_PATH} -TESTS=$(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...) -go test -v ${TESTS} +rm -f out/$COV_FILE +echo "mode: count" > out/$COV_FILE +for pkg in $(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...); do + go test -v $pkg -covermode=count -coverprofile=out/$COV_TMP_FILE + # tail -n +2 skips the first line of the file + # for coverprofile the first line is the `mode: count` line which we only want once in our file + tail -n +2 out/$COV_TMP_FILE >> out/$COV_FILE || (echo "Unable to append coverage for $pkg" && exit 1) +done +rm out/$COV_TMP_FILE # Ignore these paths in the following tests. ignore="vendor\|\_gopath\|assets.go"