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