Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. project := jaeger_client
  2. projects := jaeger_client crossdock
  3. flake8 := flake8
  4. COV_DIRS := $(projects:%=--cov %)
  5. pytest_args := -s --tb short --cov-config .coveragerc $(COV_DIRS) tests
  6. pytest := py.test $(pytest_args)
  7. sources := $(shell find $(projects) tests -name '*.py' | grep -v version.py | grep -v thrift_gen)
  8. test_args := --cov-report term-missing --cov-report xml --junitxml junit.xml
  9. cover_args := --cov-report html
  10. include crossdock/rules.mk
  11. PY_PATH = $(PYTHONPATH):$(PWD)
  12. .DEFAULT_GOAL := test
  13. .PHONY: bootstrap
  14. bootstrap:
  15. [ "$$VIRTUAL_ENV" != "" ]
  16. rm -rf *.egg-info || true
  17. pip install -U 'pip>=9.0'
  18. pip install 'setuptools>=20.8.1'
  19. pip install -r requirements.txt
  20. pip install -r requirements-dev.txt
  21. pip install -r requirements-tests.txt
  22. pip install virtualenv
  23. python setup.py develop
  24. .PHONY: test
  25. test: clean
  26. $(pytest) $(test_args) --benchmark-skip
  27. .PHONY: test_ci
  28. test_ci: clean test-import test lint
  29. .PHONY: test-import
  30. test-import:
  31. virtualenv import-test
  32. import-test/bin/pip install -e .
  33. import-test/bin/python -c "import jaeger_client"
  34. rm -rf import-test
  35. .PHONY: test-perf
  36. test-perf: clean
  37. $(pytest) $(test_args) --benchmark-only
  38. # --benchmark-histogram --benchmark-min-time=0.001
  39. .PHONY: cover
  40. cover: clean
  41. $(pytest) $(cover_args) --benchmark-skip
  42. open htmlcov/index.html
  43. .PHONY: jenkins
  44. jenkins: bootstrap
  45. $(pytest) $(test_args) --benchmark-skip
  46. .PHONY: clean
  47. clean:
  48. @find $(project) "(" -name "*.pyc" -o -name "coverage.xml" -o -name "junit.xml" ")" -delete
  49. @find tests "(" -name "*.pyc" -o -name "coverage.xml" -o -name "junit.xml" -o -name __pycache__ ")" -delete
  50. @find . "(" -name "*.pyc" -o -name "coverage.xml" -o -name "junit.xml" -o -name __pycache__ ")" -delete
  51. @rm -rf jaeger_client.egg-info
  52. .PHONY: lint
  53. lint:
  54. $(flake8) $(projects) tests
  55. ./scripts/check-license.sh
  56. .PHONY: shell
  57. shell:
  58. ipython
  59. # Generate jaeger thrifts
  60. THRIFT_GEN_DIR=jaeger_client/thrift_gen
  61. THRIFT_VER=0.9.3
  62. THRIFT_IMG=thrift:$(THRIFT_VER)
  63. THRIFT_PY_ARGS=new_style,tornado
  64. THRIFT=docker run -v "${PWD}:/data" -u $(shell id -u) $(THRIFT_IMG) thrift
  65. idl-submodule:
  66. git submodule init
  67. git submodule update
  68. thrift-image:
  69. $(THRIFT) -version
  70. .PHONY: thrift
  71. thrift: idl-submodule thrift-image
  72. rm -rf $(THRIFT_GEN_DIR)
  73. mkdir $(THRIFT_GEN_DIR)
  74. ${THRIFT} -o /data --gen py:${THRIFT_PY_ARGS} -out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/jaeger.thrift
  75. ${THRIFT} -o /data --gen py:${THRIFT_PY_ARGS} -out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/zipkincore.thrift
  76. ${THRIFT} -o /data --gen py:${THRIFT_PY_ARGS} -out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/agent.thrift
  77. ${THRIFT} -o /data --gen py:${THRIFT_PY_ARGS} -out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/sampling.thrift
  78. rm -rf ${THRIFT_GEN_DIR}/*/*-remote
  79. set -e; \
  80. for f in $$(find ${THRIFT_GEN_DIR} -iname '*.py'); do \
  81. echo fixing $$f; \
  82. awk -f thrift-gen-fix.awk $$f > tmp; \
  83. mv tmp $$f; \
  84. done
  85. update-license:
  86. python scripts/updateLicense.py $(sources)