From f6bb0d0069d8d2525187fefef15b38c212ae8d9a Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 29 Nov 2018 12:07:12 -0500 Subject: [PATCH] Fix lint and coverage (#202) * Fix lint and coverage Signed-off-by: Yuri Shkuro * Use separate target for cover as older Go versions cannot do multi-package coverage Signed-off-by: Yuri Shkuro * fix makefile Signed-off-by: Yuri Shkuro --- .gitignore | 14 +------------- .travis.yml | 21 ++++++++++++++------- Makefile | 18 +++--------------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 565f0f7..c57100a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1 @@ -# IntelliJ project files -.idea/ -opentracing-go.iml -opentracing-go.ipr -opentracing-go.iws - -# Test results -*.cov -*.html -test.log - -# Build dir -build/ +coverage.txt diff --git a/.travis.yml b/.travis.yml index f5cc0bd..9580e48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,22 @@ language: go -go: - - 1.7.x - - 1.8.x - - 1.9.x - - tip +matrix: + include: + - go: "1.7.x" + - go: "1.8.x" + - go: "1.9.x" + - go: "tip" + env: + - LINT=true + - COVERAGE=true install: - - go get -u golang.org/x/lint/golint/... + - if [ "$LINT" == true ]; then go get -u golang.org/x/lint/golint/... ; else echo 'skipping lint'; fi - go get -u github.com/stretchr/testify/... - go get -u golang.org/x/net/context + script: - - make test lint + - make test - go build ./... + - if [ "$LINT" == true ]; then make lint ; else echo 'skipping lint'; fi + - if [ "$COVERAGE" == true ]; then make cover && bash <(curl -s https://codecov.io/bash) ; else echo 'skipping coverage'; fi diff --git a/Makefile b/Makefile index d49a5c0..62abb63 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,15 @@ -PACKAGES := . ./mocktracer/... ./ext/... - .DEFAULT_GOAL := test-and-lint -.PHONE: test-and-lint - +.PHONY: test-and-lint test-and-lint: test lint .PHONY: test test: go test -v -cover -race ./... +.PHONY: cover cover: - @rm -rf cover-all.out - $(foreach pkg, $(PACKAGES), $(MAKE) cover-pkg PKG=$(pkg) || true;) - @grep mode: cover.out > coverage.out - @cat cover-all.out >> coverage.out - go tool cover -html=coverage.out -o cover.html - @rm -rf cover.out cover-all.out coverage.out - -cover-pkg: - go test -coverprofile cover.out $(PKG) - @grep -v mode: cover.out >> cover-all.out + go test -v -coverprofile=coverage.txt -covermode=atomic -race ./... .PHONY: lint lint: @@ -29,4 +18,3 @@ lint: @# Run again with magic to exit non-zero if golint outputs anything. @! (golint ./... | read dummy) go vet ./... -