Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / go.opencensus.io / Makefile
1 # TODO: Fix this on windows.
2 ALL_SRC := $(shell find . -name '*.go' \
3                                                                 -not -path './vendor/*' \
4                                                                 -not -path '*/gen-go/*' \
5                                                                 -type f | sort)
6 ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))
7
8 GOTEST_OPT?=-v -race -timeout 30s
9 GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
10 GOTEST=go test
11 GOFMT=gofmt
12 GOLINT=golint
13 GOVET=go vet
14 EMBEDMD=embedmd
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"
18
19 .DEFAULT_GOAL := fmt-lint-vet-embedmd-test
20
21 .PHONY: fmt-lint-vet-embedmd-test
22 fmt-lint-vet-embedmd-test: fmt lint vet embedmd test
23
24 # TODO enable test-with-coverage in tavis
25 .PHONY: travis-ci
26 travis-ci: fmt lint vet embedmd test test-386
27
28 all-pkgs:
29         @echo $(ALL_PKGS) | tr ' ' '\n' | sort
30
31 all-srcs:
32         @echo $(ALL_SRC) | tr ' ' '\n' | sort
33
34 .PHONY: test
35 test:
36         $(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)
37
38 .PHONY: test-386
39 test-386:
40         GOARCH=386 $(GOTEST) -v -timeout 30s $(ALL_PKGS)
41
42 .PHONY: test-with-coverage
43 test-with-coverage:
44         $(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS)
45
46 .PHONY: fmt
47 fmt:
48         @FMTOUT=`$(GOFMT) -s -l $(ALL_SRC) 2>&1`; \
49         if [ "$$FMTOUT" ]; then \
50                 echo "$(GOFMT) FAILED => gofmt the following files:\n"; \
51                 echo "$$FMTOUT\n"; \
52                 exit 1; \
53         else \
54             echo "Fmt finished successfully"; \
55         fi
56
57 .PHONY: lint
58 lint:
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"; \
62                 echo "$$LINTOUT\n"; \
63                 exit 1; \
64         else \
65             echo "Lint finished successfully"; \
66         fi
67
68 .PHONY: vet
69 vet:
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"; \
74                 echo "$$VETOUT\n"; \
75                 exit 1; \
76         else \
77             echo "Vet finished successfully"; \
78         fi
79         
80 .PHONY: embedmd
81 embedmd:
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"; \
86                 exit 1; \
87         else \
88             echo "Embedmd finished successfully"; \
89         fi
90
91 .PHONY: install-tools
92 install-tools:
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