From d934bbc7ccab90ac58386637baa4e72af0a1df26 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 29 Nov 2018 11:35:35 -0500 Subject: [PATCH 1/3] Fix lint and coverage Signed-off-by: Yuri Shkuro --- .gitignore | 14 +------------- .travis.yml | 23 ++++++++++++++++------- Makefile | 4 ++-- 3 files changed, 19 insertions(+), 22 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..b08f0d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,24 @@ 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 + +after_success: + - if [ "$COVERAGE" == true ]; then bash <(curl -s https://codecov.io/bash) ; else echo 'skipping coverage'; fi diff --git a/Makefile b/Makefile index d49a5c0..f7379a5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PACKAGES := . ./mocktracer/... ./ext/... +PACKAGES := . ./mocktracer/... ./ext/... ./log/... .DEFAULT_GOAL := test-and-lint @@ -8,7 +8,7 @@ test-and-lint: test lint .PHONY: test test: - go test -v -cover -race ./... + go test -v -coverprofile=coverage.txt -covermode=atomic -race ./... cover: @rm -rf cover-all.out From 7374acf0ffb32cc51622ddbdad1e97e78c6cf6ec Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 29 Nov 2018 11:42:44 -0500 Subject: [PATCH 2/3] Use separate target for cover as older Go versions cannot do multi-package coverage Signed-off-by: Yuri Shkuro --- .travis.yml | 4 +--- Makefile | 16 ++-------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index b08f0d3..9580e48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,4 @@ script: - make test - go build ./... - if [ "$LINT" == true ]; then make lint ; else echo 'skipping lint'; fi - -after_success: - - if [ "$COVERAGE" == true ]; then bash <(curl -s https://codecov.io/bash) ; else echo 'skipping coverage'; 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 f7379a5..300be0c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -PACKAGES := . ./mocktracer/... ./ext/... ./log/... - .DEFAULT_GOAL := test-and-lint .PHONE: test-and-lint @@ -8,19 +6,10 @@ test-and-lint: test lint .PHONY: test test: - go test -v -coverprofile=coverage.txt -covermode=atomic -race ./... + go test -v -cover -race ./... 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 ./... - From a7d191059cc146d4c1946b685b41a5a9b6e2ee9c Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 29 Nov 2018 11:56:22 -0500 Subject: [PATCH 3/3] fix makefile Signed-off-by: Yuri Shkuro --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 300be0c..62abb63 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ .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: go test -v -coverprofile=coverage.txt -covermode=atomic -race ./...