Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. PROJECT_ROOT=github.com/uber/jaeger-client-go
  2. PACKAGES := $(shell glide novendor | grep -v ./thrift-gen/...)
  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 \
  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. @[ ! -s "$(FMT_LOG)" ] || (echo "Go Fmt Failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
  43. .PHONY: install
  44. install:
  45. glide --version || go get github.com/Masterminds/glide
  46. glide install
  47. .PHONY: cover
  48. cover:
  49. ./scripts/cover.sh $(shell go list $(PACKAGES))
  50. go tool cover -html=cover.out -o cover.html
  51. # This is not part of the regular test target because we don't want to slow it
  52. # down.
  53. .PHONY: test-examples
  54. test-examples:
  55. make -C examples
  56. # TODO at the moment we're not generating tchan_*.go files
  57. thrift: idl-submodule thrift-image
  58. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/agent.thrift
  59. sed -i '' 's|"zipkincore"|"$(PROJECT_ROOT)/thrift-gen/zipkincore"|g' $(THRIFT_GEN_DIR)/agent/*.go
  60. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/sampling.thrift
  61. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/jaeger.thrift
  62. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/zipkincore.thrift
  63. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/baggage.thrift
  64. rm -rf thrift-gen/*/*-remote
  65. $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/crossdock/thrift/ /data/idl/thrift/crossdock/tracetest.thrift
  66. rm -rf crossdock/thrift/*/*-remote
  67. idl-submodule:
  68. git submodule init
  69. git submodule update
  70. thrift-image:
  71. $(THRIFT) -version
  72. .PHONY: install_ci
  73. install_ci: install
  74. go get github.com/wadey/gocovmerge
  75. go get github.com/mattn/goveralls
  76. go get golang.org/x/tools/cmd/cover
  77. go get github.com/golang/lint/golint
  78. .PHONY: test_ci
  79. test_ci:
  80. @./scripts/cover.sh $(shell go list $(PACKAGES))
  81. make lint