1 # TODO: Fix this on windows.
2 ALL_SRC := $(shell find . -name '*.go' \
3 -not -path './vendor/*' \
4 -not -path '*/gen-go/*' \
6 ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))
8 GOTEST_OPT?=-v -race -timeout 30s
9 GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
15 # TODO decide if we need to change these names.
16 TRACE_ID_LINT_EXCEPTION="type name will be used as trace.TraceID by other packages"
17 TRACE_OPTION_LINT_EXCEPTION="type name will be used as trace.TraceOptions by other packages"
19 .DEFAULT_GOAL := fmt-lint-vet-embedmd-test
21 .PHONY: fmt-lint-vet-embedmd-test
22 fmt-lint-vet-embedmd-test: fmt lint vet embedmd test
24 # TODO enable test-with-coverage in tavis
26 travis-ci: fmt lint vet embedmd test test-386
29 @echo $(ALL_PKGS) | tr ' ' '\n' | sort
32 @echo $(ALL_SRC) | tr ' ' '\n' | sort
36 $(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)
40 GOARCH=386 $(GOTEST) -v -timeout 30s $(ALL_PKGS)
42 .PHONY: test-with-coverage
44 $(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS)
48 @FMTOUT=`$(GOFMT) -s -l $(ALL_SRC) 2>&1`; \
49 if [ "$$FMTOUT" ]; then \
50 echo "$(GOFMT) FAILED => gofmt the following files:\n"; \
54 echo "Fmt finished successfully"; \
59 @LINTOUT=`$(GOLINT) $(ALL_PKGS) | grep -v $(TRACE_ID_LINT_EXCEPTION) | grep -v $(TRACE_OPTION_LINT_EXCEPTION) 2>&1`; \
60 if [ "$$LINTOUT" ]; then \
61 echo "$(GOLINT) FAILED => clean the following lint errors:\n"; \
65 echo "Lint finished successfully"; \
70 # TODO: Understand why go vet downloads "github.com/google/go-cmp v0.2.0"
71 @VETOUT=`$(GOVET) ./... | grep -v "go: downloading" 2>&1`; \
72 if [ "$$VETOUT" ]; then \
73 echo "$(GOVET) FAILED => go vet the following files:\n"; \
77 echo "Vet finished successfully"; \
82 @EMBEDMDOUT=`$(EMBEDMD) -d README.md 2>&1`; \
83 if [ "$$EMBEDMDOUT" ]; then \
84 echo "$(EMBEDMD) FAILED => embedmd the following files:\n"; \
85 echo "$$EMBEDMDOUT\n"; \
88 echo "Embedmd finished successfully"; \
93 go get -u golang.org/x/tools/cmd/cover
94 go get -u golang.org/x/lint/golint
95 go get -u github.com/rakyll/embedmd