Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. bash -c "set -e; set -o pipefail; $(GOTEST) $(PACKAGES) | $(COLORIZE)"
  31. .PHONY: fmt
  32. fmt:
  33. $(GOFMT) -e -s -l -w $(ALL_SRC)
  34. ./scripts/updateLicenses.sh
  35. .PHONY: lint
  36. lint:
  37. $(GOVET) $(PACKAGES)
  38. @cat /dev/null > $(LINT_LOG)
  39. @$(foreach pkg, $(PACKAGES), $(GOLINT) $(pkg) | grep -v crossdock/thrift >> $(LINT_LOG) || true;)
  40. @[ ! -s "$(LINT_LOG)" ] || (echo "Lint Failures" | cat - $(LINT_LOG) && false)
  41. @$(GOFMT) -e -s -l $(ALL_SRC) > $(FMT_LOG)
  42. ./scripts/updateLicenses.sh >> $(FMT_LOG)
  43. @[ ! -s "$(FMT_LOG)" ] || (echo "go fmt or license check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
  44. .PHONY: install
  45. install:
  46. glide --version || go get github.com/Masterminds/glide
  47. ifeq ($(USE_DEP),true)
  48. dep ensure
  49. else
  50. glide install
  51. endif
  52. .PHONY: cover
  53. cover:
  54. ./scripts/cover.sh $(shell go list $(PACKAGES))
  55. go tool cover -html=cover.out -o cover.html
  56. # This is not part of the regular test target because we don't want to slow it
  57. # down.
  58. .PHONY: test-examples
  59. test-examples:
  60. make -C examples
  61. # TODO at the moment we're not generating tchan_*.go files
  62. thrift: idl-submodule thrift-image
  63. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/agent.thrift
  64. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/sampling.thrift
  65. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/jaeger.thrift
  66. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/zipkincore.thrift
  67. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/baggage.thrift
  68. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/crossdock/thrift/ /data/idl/thrift/crossdock/tracetest.thrift
  69. sed -i '' 's|"zipkincore"|"$(PROJECT_ROOT)/thrift-gen/zipkincore"|g' $(THRIFT_GEN_DIR)/agent/*.go
  70. sed -i '' 's|"jaeger"|"$(PROJECT_ROOT)/thrift-gen/jaeger"|g' $(THRIFT_GEN_DIR)/agent/*.go
  71. sed -i '' 's|"github.com/apache/thrift/lib/go/thrift"|"github.com/uber/jaeger-client-go/thrift"|g' \
  72. $(THRIFT_GEN_DIR)/*/*.go crossdock/thrift/tracetest/*.go
  73. rm -rf thrift-gen/*/*-remote
  74. rm -rf crossdock/thrift/*/*-remote
  75. rm -rf thrift-gen/jaeger/collector.go
  76. idl-submodule:
  77. git submodule init
  78. git submodule update
  79. thrift-image:
  80. $(THRIFT) -version
  81. .PHONY: install-dep-ci
  82. install-dep-ci:
  83. - curl -L -s https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 -o $$GOPATH/bin/dep
  84. - chmod +x $$GOPATH/bin/dep
  85. .PHONY: install-ci
  86. install-ci: install-dep-ci install
  87. go get github.com/wadey/gocovmerge
  88. go get github.com/mattn/goveralls
  89. go get golang.org/x/tools/cmd/cover
  90. go get golang.org/x/lint/golint
  91. .PHONY: test-ci
  92. test-ci:
  93. @./scripts/cover.sh $(shell go list $(PACKAGES))
  94. ifeq ($(CI_SKIP_LINT),true)
  95. echo 'skipping lint'
  96. else
  97. make lint
  98. endif