Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. PROJECT_ROOT=github.com/uber/jaeger-lib
  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. export GO15VENDOREXPERIMENT=1
  9. GOTEST=go test -v $(RACE)
  10. GOLINT=golint
  11. GOVET=go vet
  12. GOFMT=gofmt
  13. FMT_LOG=fmt.log
  14. LINT_LOG=lint.log
  15. THRIFT_VER=0.9.3
  16. THRIFT_IMG=thrift:$(THRIFT_VER)
  17. THRIFT=docker run -v "${PWD}:/data" $(THRIFT_IMG) thrift
  18. THRIFT_GO_ARGS=thrift_import="github.com/apache/thrift/lib/go/thrift"
  19. THRIFT_GEN_DIR=thrift-gen
  20. PASS=$(shell printf "\033[32mPASS\033[0m")
  21. FAIL=$(shell printf "\033[31mFAIL\033[0m")
  22. COLORIZE=sed ''/PASS/s//$(PASS)/'' | sed ''/FAIL/s//$(FAIL)/''
  23. .DEFAULT_GOAL := test-and-lint
  24. .PHONY: test-and-lint
  25. test-and-lint: test fmt lint
  26. .PHONY: test
  27. test:
  28. $(GOTEST) $(PACKAGES) | $(COLORIZE)
  29. .PHONY: fmt
  30. fmt:
  31. $(GOFMT) -e -s -l -w $(ALL_SRC)
  32. ./scripts/updateLicenses.sh
  33. .PHONY: lint
  34. lint:
  35. $(GOVET) $(PACKAGES)
  36. @cat /dev/null > $(LINT_LOG)
  37. @$(foreach pkg, $(PACKAGES), $(GOLINT) $(pkg) | grep -v crossdock/thrift >> $(LINT_LOG) || true;)
  38. @[ ! -s "$(LINT_LOG)" ] || (echo "Lint Failures" | cat - $(LINT_LOG) && false)
  39. @$(GOFMT) -e -s -l $(ALL_SRC) > $(FMT_LOG)
  40. @./scripts/updateLicenses.sh >> $(FMT_LOG)
  41. @[ ! -s "$(FMT_LOG)" ] || (echo "go fmt or license check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
  42. .PHONY: install
  43. install:
  44. glide --version || go get github.com/Masterminds/glide
  45. ifeq ($(USE_DEP),true)
  46. dep ensure
  47. dep status
  48. else
  49. glide install
  50. endif
  51. .PHONY: cover
  52. cover:
  53. ./scripts/cover.sh $(shell go list $(PACKAGES))
  54. go tool cover -html=cover.out -o cover.html
  55. idl-submodule:
  56. git submodule init
  57. git submodule update
  58. thrift-image:
  59. $(THRIFT) -version
  60. .PHONY: install-dep-ci
  61. install-dep-ci:
  62. - curl -L -s https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 -o $$GOPATH/bin/dep
  63. - chmod +x $$GOPATH/bin/dep
  64. .PHONY: install-ci
  65. install-ci: install
  66. go get github.com/wadey/gocovmerge
  67. go get github.com/mattn/goveralls
  68. go get golang.org/x/tools/cmd/cover
  69. go get github.com/golang/lint/golint
  70. .PHONY: test-ci
  71. test-ci:
  72. ./scripts/cover.sh $(shell go list $(PACKAGES))
  73. make lint
  74. .PHONY: test-only-ci
  75. test-only-ci:
  76. go test -cover $(PACKAGES)
  77. make lint