1- ALL_SRC := $(shell find . -type f -name '* .go' -not -path "./vendor/* ")
1+ # More exclusions can be added similar with: -not -path './vendor/*'
2+ ALL_SRC := $(shell find . -name '* .go' \
3+ -not -path './vendor/* ' \
4+ -type f | sort)
5+
6+ # ALL_PKGS is used with 'go cover'
7+ ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC ) ) ) )
28
39GOTEST_OPT? =-v -race -timeout 30s
410GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT ) -coverprofile=coverage.txt -covermode=atomic
511GOTEST =go test
612GOFMT =gofmt
713GOLINT =golint
14+ GOVET =go vet
815GOOS =$(shell go env GOOS)
916
1017GIT_SHA =$(shell git rev-parse --short HEAD)
@@ -15,18 +22,32 @@ BUILD_X2=-X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION)
1522endif
1623BUILD_INFO =-ldflags "${BUILD_X1} ${BUILD_X2}"
1724
18- .DEFAULT_GOAL := default_goal
25+ all_pkgs :
26+ @echo $(ALL_PKGS ) | tr ' ' ' \n' | sort
27+
28+ all_srcs :
29+ @echo $(ALL_SRC ) | tr ' ' ' \n' | sort
1930
20- .PHONY : default_goal
21- default_goal : fmt lint test
31+ .DEFAULT_GOAL := fmt-vet-lint-test
32+
33+ .PHONY : fmt-vet-lint-test
34+ fmt-vet-lint-test : fmt vet lint test
2235
2336.PHONY : test
2437test :
25- $(GOTEST ) $(GOTEST_OPT ) ./...
38+ $(GOTEST ) $(GOTEST_OPT ) $(ALL_PKGS )
39+
40+ .PHONY : travis-ci
41+ travis-ci : fmt vet lint test-with-cover
2642
27- .PHONY : test-with-coverage
28- test-with-coverage :
29- $(GOTEST ) $(GOTEST_OPT_WITH_COVERAGE ) ./...
43+ .PHONY : test-with-cover
44+ test-with-cover :
45+ @echo Verifying that all packages have test files to count in coverage
46+ @scripts/check-test-files.sh $(subst github.com/census-instrumentation/opencensus-service/,./,$(ALL_PKGS ) )
47+ @echo pre-compiling tests
48+ @time go test -i $(ALL_PKGS )
49+ $(GOTEST ) $(GOTEST_OPT_WITH_COVERAGE ) $(ALL_PKGS )
50+ go tool cover -html=coverage.txt -o coverage.html
3051
3152.PHONY : fmt
3253fmt :
3556 echo " $( GOFMT) FAILED => gofmt the following files:\n" ; \
3657 echo " $$ FMTOUT\n" ; \
3758 exit 1; \
59+ else \
60+ echo " Fmt finished successfully" ; \
3861 fi
3962
4063.PHONY : lint
4164lint :
42- @LINTOUT=` $( GOLINT) ./... 2>&1 ` ; \
65+ @LINTOUT=` $( GOLINT) $( ALL_PKGS ) 2>&1 ` ; \
4366 if [ " $$ LINTOUT" ]; then \
4467 echo " $( GOLINT) FAILED => clean the following lint errors:\n" ; \
4568 echo " $$ LINTOUT\n" ; \
4669 exit 1; \
70+ else \
71+ echo " Lint finished successfully" ; \
72+ fi
73+
74+ .PHONY : vet
75+ vet :
76+ @VETOUT=` $( GOVET) ./... 2>&1 ` ; \
77+ if [ " $$ VETOUT" ]; then \
78+ echo " $( GOVET) FAILED => clean the following vet errors:\n" ; \
79+ echo " $$ VETOUT\n" ; \
80+ exit 1; \
81+ else \
82+ echo " Vet finished successfully" ; \
4783 fi
4884
4985.PHONY : install-tools
0 commit comments