-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
80 lines (62 loc) · 2.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
PYTHON_MODULE_DIR=./
PYTHON_MODULE=sap
PYTHON_BINARIES=bin/sapcli
PYTHON_MODULE_FILES=$(shell find $(PYTHON_MODULE) -type f -name '*.py')
TESTS_DIR=test
TESTS_UNIT_DIR=$(TESTS_DIR)/unit
TESTS_UNIT_FILES=$(shell find $(TESTS_UNIT_DIR) -type f -name '*.py')
PYTHON_BIN=python3
COVERAGE_BIN=coverage
COVERAGE_CMD_RUN=$(COVERAGE_BIN) run
COVERAGE_CMD_REPORT=$(COVERAGE_BIN) report
COVERAGE_REPORT_ARGS=--skip-covered
COVERAGE_CMD_HTML=$(COVERAGE_BIN) html
COVERAGE_HTML_DIR=.htmlcov
COVERAGE_HTML_ARGS=$(COVERAGE_REPORT_ARGS) -d $(COVERAGE_HTML_DIR)
COVERAGE_REPORT_FILES=$(PYTHON_BINARIES) $(PYTHON_MODULE_FILES)
PYTEST_MODULE=unittest
PYTEST_PARAMS=discover -b -v -s $(TESTS_UNIT_DIR)
PYLINT_BIN ?= pylint
PYLINT_RC_FILE=.pylintrc
PYLINT_PARAMS=--output-format=parseable --reports=no
FLAKE8_BIN ?= flake8
FLAKE8_CONFIG_FILE=.flake8
FLAKE8_PARAMS=
MYPY_BIN ?= mypy
MYPY_CONFIG_FILE=mypy.ini
MYPY_PARAMS=
.PHONY: run_pylint
run_pylint:
$(PYLINT_BIN) --rcfile=$(PYLINT_RC_FILE) $(PYLINT_PARAMS) $(PYTHON_MODULE)
PYTHONPATH=$(PYTHON_MODULE_DIR):$$PYTHONPATH $(PYLINT_BIN) --rcfile=$(PYLINT_RC_FILE) $(PYLINT_PARAMS) $(PYTHON_BINARIES)
.PHONY: run_flake8
run_flake8:
$(FLAKE8_BIN) --config=$(FLAKE8_CONFIG_FILE) $(FLAKE8_PARAMS) $(PYTHON_MODULE)
PYTHONPATH=$(PYTHON_MODULE_DIR):$$PYTHONPATH $(FLAKE8_BIN) --config=$(FLAKE8_CONFIG_FILE) $(FLAKE8_PARAMS) $(PYTHON_BINARIES)
.PHONY: run_mypy
run_mypy:
PYTHONPATH=$(PYTHON_MODULE_DIR):$$PYTHONPATH $(MYPY_BIN) --config-file=$(MYPY_CONFIG_FILE) $(MYPY_PARAMS) $(PYTHON_BINARIES) $(PYTHON_MODULE_FILES)
.PHONY: lint
lint: run_pylint run_flake8 run_mypy
@ echo "*** Linters done ***"
.PHONY: test
test:
$(PYTHON_BIN) -m $(PYTEST_MODULE) $(PYTEST_PARAMS)
.coverage: $(COVERAGE_REPORT_FILES) $(TESTS_UNIT_FILES)
$(MAKE) test PYTHON_BIN="$(COVERAGE_CMD_RUN)"
.PHONY: report-coverage
report-coverage: .coverage
@ $(COVERAGE_CMD_REPORT) $(COVERAGE_REPORT_ARGS) $(COVERAGE_REPORT_FILES)
.PHONY: report-coverage-html
report-coverage-html: .coverage
@ echo "Generating HTML code coverage report ..."
@ $(COVERAGE_CMD_HTML) $(COVERAGE_HTML_ARGS) $(COVERAGE_REPORT_FILES)
@ echo "Report: file://$$(pwd)/$(COVERAGE_HTML_DIR)/index.html"
.PHONY: system-test
system-test:
export PATH=$$(pwd):$$PATH; cd test/system && ./run.sh
.PHONY: check
check: lint report-coverage
.PHONY: clean
clean:
rm -rf .coverage $(COVERAGE_HTML_DIR)