-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
90 lines (70 loc) · 2.52 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
81
82
83
84
85
86
87
88
89
90
.PHONE:clean venv install upgrade uninstall check dist format lint test coverage report
MIN_TEST_COVERAGE=99
MODULE_NAME=pylavi
REQUIREMENTS_FILE=requirements.txt
INFRA_REQUIREMENTS_FILE=requirements-infra.txt
SOURCES=$(MODULE_NAME)/*.py
TEST_DIR=tests
TESTS=$(TEST_DIR)/*.py
TEST_FILES=$(TEST_DIR)/*.vi $(TEST_DIR)/*.yaml
VENV_DIR=.venv
VENV_ACTIVATE_SCRIPT=$(VENV_DIR)/bin/activate
LINT_LOG=$(VENV_DIR)/lint.txt
BLACK_LOG=$(VENV_DIR)/format.txt
TEST_LOG=$(VENV_DIR)/test.txt
DIST_LOG=$(VENV_DIR)/dist.txt
COVERAGE_LOG=$(VENV_DIR)/coverage.txt
RUN_IN_VENV=. $(VENV_ACTIVATE_SCRIPT) &&
all:format lint coverage install check dist
clean:
rm -Rf build dist $(MODULE_NAME).egg-info $(VENV_DIR) htmlcov .coverage .pytest_cache
@echo Now Clean
$(VENV_ACTIVATE_SCRIPT):
@python3 -m venv $(VENV_DIR)
@$(RUN_IN_VENV) python3 -m pip install -q --upgrade pip && pip3 install -q setuptools wheel
@$(RUN_IN_VENV) pip3 install -r $(REQUIREMENTS_FILE)
@echo VENV Created
venv: $(VENV_ACTIVATE_SCRIPT)
$(BLACK_LOG): $(SOURCES) $(VENV_ACTIVATE_SCRIPT)
@$(RUN_IN_VENV) pip3 install -q -r $(INFRA_REQUIREMENTS_FILE) && black $(SOURCES) \
2> $@ || (cat $@; exit 1)
@echo Source Formatted
format: $(BLACK_LOG)
@cat $<
$(LINT_LOG): $(SOURCES) $(VENV_ACTIVATE_SCRIPT)
@$(RUN_IN_VENV) pip3 install -q -r $(INFRA_REQUIREMENTS_FILE) && pylint $(SOURCES) \
> $@ || (cat $@; exit 1)
@$(RUN_IN_VENV) pip3 install -q -r $(INFRA_REQUIREMENTS_FILE) && black --check $(SOURCES) \
2>> $@ || (cat $@; exit 1)
@echo Linting Complete
lint: $(LINT_LOG)
@cat $<
$(TEST_LOG): $(SOURCES) $(TESTS) $(TEST_FILES) $(VENV_ACTIVATE_SCRIPT)
@$(RUN_IN_VENV) pip3 install -q -r $(INFRA_REQUIREMENTS_FILE) && coverage run --source=$(MODULE_NAME) -m pytest \
> $@ || (cat $@; exit 1)
test: $(TEST_LOG)
@cat $<
$(COVERAGE_LOG): $(TEST_LOG)
@$(RUN_IN_VENV) coverage report --skip-covered --show-missing --fail-under=$(MIN_TEST_COVERAGE) \
> $@ || (cat $@; exit 1)
report: $(TEST_LOG)
@$(RUN_IN_VENV) coverage html --skip-covered
@open htmlcov/index.html
coverage: $(COVERAGE_LOG)
@cat $<
install: $(VENV_ACTIVATE_SCRIPT)
$(RUN_IN_VENV) pip3 install .
@echo $(MODULE_NAME) installed
upgrade: $(VENV_ACTIVATE_SCRIPT)
$(RUN_IN_VENV) pip install --upgrade .
@echo $(MODULE_NAME) upgraded
uninstall: $(VENV_ACTIVATE_SCRIPT)
$(RUN_IN_VENV) pip uninstall $(MODULE_NAME) -y
@echo $(MODULE_NAME) uninstalled
check:
python3 setup.py check
$(DIST_LOG): $(SOURCE) README.md LICENSE setup.py
@mkdir -p $(VENV_DIR)
@python3 setup.py sdist > $@ || (cat $@; exit 1)
dist: $(DIST_LOG)
@cat $<