blob: ee7b21268ad4c2b5ef793149fb575a764641c144 [file] [log] [blame]
Girish Kumar46d7c3a2020-05-18 12:06:33 +00001PROJECT_ROOT=github.com/uber/jaeger-client-go
khenaidoo26721882021-08-11 17:42:52 -04002export GO111MODULE=off
3PACKAGES := . $(shell GO111MODULE=off go list ./... | awk -F/ 'NR>1 {print "./"$$4"/..."}' | grep -v -e ./thrift-gen/... -e ./thrift/... | sort -u)
Girish Kumar46d7c3a2020-05-18 12:06:33 +00004# all .go files that don't exist in hidden directories
5ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor -e thrift-gen -e ./thrift/ \
6 -e ".*/\..*" \
7 -e ".*/_.*" \
8 -e ".*/mocks.*")
9
10USE_DEP := true
11
12-include crossdock/rules.mk
13
14RACE=-race
15GOTEST=go test -v $(RACE)
16GOLINT=golint
17GOVET=go vet
18GOFMT=gofmt
19FMT_LOG=fmt.log
20LINT_LOG=lint.log
21
khenaidoo26721882021-08-11 17:42:52 -040022THRIFT_VER=0.14
23THRIFT_IMG=jaegertracing/thrift:$(THRIFT_VER)
Abhay Kumar40252eb2025-10-13 13:25:53 +000024THRIFT=docker run -v "${PWD}:/data" -u ${shell id -u}:${shell id -g} $(THRIFT_IMG) thrift
Girish Kumar46d7c3a2020-05-18 12:06:33 +000025
26PASS=$(shell printf "\033[32mPASS\033[0m")
27FAIL=$(shell printf "\033[31mFAIL\033[0m")
28COLORIZE=sed ''/PASS/s//$(PASS)/'' | sed ''/FAIL/s//$(FAIL)/''
29
30.DEFAULT_GOAL := test-and-lint
31
32.PHONY: test-and-lint
33test-and-lint: test fmt lint
34
35.PHONY: test
36test:
37ifeq ($(USE_DEP),true)
38 dep check
39endif
40 bash -c "set -e; set -o pipefail; $(GOTEST) $(PACKAGES) | $(COLORIZE)"
41
42.PHONY: fmt
43fmt:
44 $(GOFMT) -e -s -l -w $(ALL_SRC)
45 ./scripts/updateLicenses.sh
46
47.PHONY: lint
khenaidoo26721882021-08-11 17:42:52 -040048lint: vet golint lint-fmt lint-thrift-testing
49
50.PHONY: vet
51vet:
Girish Kumar46d7c3a2020-05-18 12:06:33 +000052 $(GOVET) $(PACKAGES)
khenaidoo26721882021-08-11 17:42:52 -040053
54.PHONY: golint
55golint:
Girish Kumar46d7c3a2020-05-18 12:06:33 +000056 @cat /dev/null > $(LINT_LOG)
57 @$(foreach pkg, $(PACKAGES), $(GOLINT) $(pkg) | grep -v crossdock/thrift >> $(LINT_LOG) || true;)
58 @[ ! -s "$(LINT_LOG)" ] || (echo "Lint Failures" | cat - $(LINT_LOG) && false)
khenaidoo26721882021-08-11 17:42:52 -040059
60.PHONY: lint-fmt
61lint-fmt:
Girish Kumar46d7c3a2020-05-18 12:06:33 +000062 @$(GOFMT) -e -s -l $(ALL_SRC) > $(FMT_LOG)
63 ./scripts/updateLicenses.sh >> $(FMT_LOG)
64 @[ ! -s "$(FMT_LOG)" ] || (echo "go fmt or license check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
65
khenaidoo26721882021-08-11 17:42:52 -040066# make sure thrift/ module does not import "testing"
67.PHONY: lint-thrift-testing
68lint-thrift-testing:
69 @cat /dev/null > $(LINT_LOG)
70 @(grep -rn '"testing"' thrift | grep -v README.md > $(LINT_LOG)) || true
71 @[ ! -s "$(LINT_LOG)" ] || (echo '"thrift" module must not import "testing", see issue #585' | cat - $(LINT_LOG) && false)
Girish Kumar46d7c3a2020-05-18 12:06:33 +000072
73.PHONY: install
74install:
75 @echo install: USE_DEP=$(USE_DEP) USE_GLIDE=$(USE_GLIDE)
76ifeq ($(USE_DEP),true)
77 dep version || make install-dep
khenaidoo26721882021-08-11 17:42:52 -040078 dep ensure -vendor-only -v
Girish Kumar46d7c3a2020-05-18 12:06:33 +000079endif
80ifeq ($(USE_GLIDE),true)
81 glide --version || go get github.com/Masterminds/glide
82 glide install
83endif
84
85
86.PHONY: cover
87cover:
88 $(GOTEST) -cover -coverprofile cover.out $(PACKAGES)
89
90.PHONY: cover-html
91cover-html: cover
92 go tool cover -html=cover.out -o cover.html
93
94# This is not part of the regular test target because we don't want to slow it
95# down.
96.PHONY: test-examples
97test-examples:
98 make -C examples
99
100.PHONY: thrift
101thrift: idl-submodule thrift-compile
102
103# TODO at the moment we're not generating tchan_*.go files
104.PHONY: thrift-compile
105thrift-compile: thrift-image
Abhay Kumar40252eb2025-10-13 13:25:53 +0000106 docker run -v "${PWD}:/data" -u ${shell id -u}:${shell id -g} $(THRIFT_IMG) /data/scripts/gen-thrift.sh
Girish Kumar46d7c3a2020-05-18 12:06:33 +0000107
108.PHONY: idl-submodule
109idl-submodule:
110 git submodule init
111 git submodule update
112
113.PHONY: thrift-image
114thrift-image:
115 $(THRIFT) -version
116
117.PHONY: install-dep
118install-dep:
119 - curl -L -s https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 -o $$GOPATH/bin/dep
120 - chmod +x $$GOPATH/bin/dep
121
122.PHONY: install-ci
123install-ci: install
124 go get github.com/wadey/gocovmerge
125 go get github.com/mattn/goveralls
126 go get golang.org/x/tools/cmd/cover
127 go get golang.org/x/lint/golint
128
129.PHONY: test-ci
130test-ci: cover
131ifeq ($(CI_SKIP_LINT),true)
132 echo 'skipping lint'
133else
134 make lint
135endif