Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. PROJECT_ROOT=github.com/uber/jaeger-client-go
  2. PACKAGES := $(shell glide novendor | grep -v -e ./thrift-gen/... -e ./thrift/...)
  3. # all .go files that don't exist in hidden directories
  4. ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor -e thrift-gen -e ./thrift/ \
  5. -e ".*/\..*" \
  6. -e ".*/_.*" \
  7. -e ".*/mocks.*")
  8. -include crossdock/rules.mk
  9. export GO15VENDOREXPERIMENT=1
  10. RACE=-race
  11. GOTEST=go test -v $(RACE)
  12. GOLINT=golint
  13. GOVET=go vet
  14. GOFMT=gofmt
  15. FMT_LOG=fmt.log
  16. LINT_LOG=lint.log
  17. THRIFT_VER=0.9.3
  18. THRIFT_IMG=thrift:$(THRIFT_VER)
  19. THRIFT=docker run -v "${PWD}:/data" $(THRIFT_IMG) thrift
  20. THRIFT_GO_ARGS=thrift_import="github.com/apache/thrift/lib/go/thrift"
  21. THRIFT_GEN_DIR=thrift-gen
  22. PASS=$(shell printf "\033[32mPASS\033[0m")
  23. FAIL=$(shell printf "\033[31mFAIL\033[0m")
  24. COLORIZE=sed ''/PASS/s//$(PASS)/'' | sed ''/FAIL/s//$(FAIL)/''
  25. .DEFAULT_GOAL := test-and-lint
  26. .PHONY: test-and-lint
  27. test-and-lint: test fmt lint
  28. .PHONY: test
  29. test:
  30. ifeq ($(USE_DEP),true)
  31. dep check
  32. endif
  33. bash -c "set -e; set -o pipefail; $(GOTEST) $(PACKAGES) | $(COLORIZE)"
  34. .PHONY: fmt
  35. fmt:
  36. $(GOFMT) -e -s -l -w $(ALL_SRC)
  37. ./scripts/updateLicenses.sh
  38. .PHONY: lint
  39. lint:
  40. $(GOVET) $(PACKAGES)
  41. @cat /dev/null > $(LINT_LOG)
  42. @$(foreach pkg, $(PACKAGES), $(GOLINT) $(pkg) | grep -v crossdock/thrift >> $(LINT_LOG) || true;)
  43. @[ ! -s "$(LINT_LOG)" ] || (echo "Lint Failures" | cat - $(LINT_LOG) && false)
  44. @$(GOFMT) -e -s -l $(ALL_SRC) > $(FMT_LOG)
  45. ./scripts/updateLicenses.sh >> $(FMT_LOG)
  46. @[ ! -s "$(FMT_LOG)" ] || (echo "go fmt or license check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
  47. .PHONY: install
  48. install:
  49. glide --version || go get github.com/Masterminds/glide
  50. ifeq ($(USE_DEP),true)
  51. dep ensure
  52. else
  53. glide install
  54. endif
  55. .PHONY: cover
  56. cover:
  57. ./scripts/cover.sh $(shell go list $(PACKAGES))
  58. go tool cover -html=cover.out -o cover.html
  59. # This is not part of the regular test target because we don't want to slow it
  60. # down.
  61. .PHONY: test-examples
  62. test-examples:
  63. make -C examples
  64. # TODO at the moment we're not generating tchan_*.go files
  65. thrift: idl-submodule thrift-image
  66. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/agent.thrift
  67. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/sampling.thrift
  68. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/jaeger.thrift
  69. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/zipkincore.thrift
  70. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/baggage.thrift
  71. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/crossdock/thrift/ /data/idl/thrift/crossdock/tracetest.thrift
  72. sed -i '' 's|"zipkincore"|"$(PROJECT_ROOT)/thrift-gen/zipkincore"|g' $(THRIFT_GEN_DIR)/agent/*.go
  73. sed -i '' 's|"jaeger"|"$(PROJECT_ROOT)/thrift-gen/jaeger"|g' $(THRIFT_GEN_DIR)/agent/*.go
  74. sed -i '' 's|"github.com/apache/thrift/lib/go/thrift"|"github.com/uber/jaeger-client-go/thrift"|g' \
  75. $(THRIFT_GEN_DIR)/*/*.go crossdock/thrift/tracetest/*.go
  76. rm -rf thrift-gen/*/*-remote
  77. rm -rf crossdock/thrift/*/*-remote
  78. rm -rf thrift-gen/jaeger/collector.go
  79. idl-submodule:
  80. git submodule init
  81. git submodule update
  82. thrift-image:
  83. $(THRIFT) -version
  84. .PHONY: install-dep-ci
  85. install-dep-ci:
  86. - curl -L -s https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 -o $$GOPATH/bin/dep
  87. - chmod +x $$GOPATH/bin/dep
  88. .PHONY: install-ci
  89. install-ci: install-dep-ci install
  90. go get github.com/wadey/gocovmerge
  91. go get github.com/mattn/goveralls
  92. go get golang.org/x/tools/cmd/cover
  93. go get golang.org/x/lint/golint
  94. .PHONY: test-ci
  95. test-ci:
  96. @./scripts/cover.sh $(shell go list $(PACKAGES))
  97. ifeq ($(CI_SKIP_LINT),true)
  98. echo 'skipping lint'
  99. else
  100. make lint
  101. endif