From 951429fe67cf4f099bd8660ea846767c2c28b754 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 13 Aug 2016 14:00:57 -0700 Subject: [PATCH] Add code coverage and cleanup CI configs. (#1795) --- .gitignore | 1 + .travis.yml | 15 +++++++-------- Makefile | 5 ++++- appveyor.yml | 25 +++++++------------------ buildscripts/go-coverage.sh | 12 ++++++++++++ 5 files changed, 31 insertions(+), 27 deletions(-) create mode 100755 buildscripts/go-coverage.sh diff --git a/.gitignore b/.gitignore index 607c3b2d..d9856f59 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ cover.out *.test release experimental +coverage.txt \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8e6f85fa..cd1fc832 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,24 @@ sudo: false language: go -script: -- make test GOFLAGS="-race" - os: - linux +- osx + +osx_image: xcode7.2 env: - ARCH=x86_64 - ARCH=i686 go: -- 1.6 +- 1.6.2 script: -- make test - make test GOFLAGS="-race" +- make coverage - diff -au <(gofmt -d *.go) <(printf "") - diff -au <(gofmt -d pkg) <(printf "") -notifications: - slack: - secure: McinxQ4R/Yu2r/U8lVsdAIQ195Rf+3/Ku6DViWyqLHsTt5fTnVrSfbIKs8vy0t2A0bRLO6zv2xOSMWjfiimZLPMgMbMqLtTFEzUzB8RZyx2n2xgmL8q3gjXcLA3vkBreaRYCzJzX6DjvrxRfhyOg+BQHpLpACWik3FS/7VIdDCI= +after_success: +- bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 96f4b4c4..cef027c7 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,6 @@ deadcode: @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/deadcode build: getdeps verifiers - @echo "Installing mc:" test: getdeps verifiers @echo "Running all testing:" @@ -59,9 +58,13 @@ test: getdeps verifiers @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/mc/pkg... gomake-all: build + @echo "Installing mc:" @GO15VENDOREXPERIMENT=1 go build --ldflags "$(LDFLAGS)" -o $(GOPATH)/bin/mc @mkdir -p $(HOME)/.mc +coverage: getdeps verifiers + @echo "Running all coverage:" + @GO15VENDOREXPERIMENT=1 ./buildscripts/go-coverage.sh pkg-validate-arg-%: ; ifndef PKG diff --git a/appveyor.yml b/appveyor.yml index c13ca155..570b7239 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,33 +14,22 @@ environment: # scripts that run after cloning repository install: - set PATH=%GOPATH%\bin;c:\go\bin;%PATH% - - rd C:\Go /s /q - - appveyor DownloadFile https://storage.googleapis.com/golang/go1.6.windows-amd64.zip - - 7z x go1.6.windows-amd64.zip -oC:\ >nul - go version - go env - - go get -u github.com/golang/lint/golint - - go get -u github.com/fzipp/gocyclo - - go get -u github.com/remyoudompheng/go-misc/deadcode - - go get -u github.com/client9/misspell/cmd/misspell # to run your custom scripts instead of automatic MSBuild build_script: - - go tool vet -all ./pkg - - go tool vet -shadow=true ./pkg - - gofmt -s -l pkg - - golint . - - golint github.com/minio/mc/pkg... - - misspell . - - gocyclo -over 40 pkg - - deadcode - - go test -race . + - go test -race github.com/minio/mc/command... - go test -race github.com/minio/mc/pkg... + - go test -coverprofile=coverage.txt -covermode=atomic - go run buildscripts/gen-ldflags.go > temp.txt - - set /p LDFLAGS= coverage.txt + +for d in $(go list ./... | grep -v vendor); do + go test -coverprofile=profile.out -covermode=atomic $d + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done