-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
84 lines (73 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
VENV = venv
PYTHON = $(VENV)/bin/python3
REPORTS = reports
# Setup python virtual environment
.PHONNY: setup
setup:
python3 -m venv $(VENV)
# Compile pinned dependency files (requirements.txt and requirements-dev.txt) from project and dev
# dependency specified by requirements.in and pyproject.toml respectively
.PHONNY: compile-dependency
compile-dependency:
$(VENV)/bin/pip-compile --output-file=requirements.txt pyproject.toml
$(VENV)/bin/pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
# Install project dependency
.PHONNY: install
install: requirements.txt
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install -r requirements.txt
# Install project and dev dependency
.PHONNY: install-dev
install-dev: requirements-dev.txt
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install -r requirements-dev.txt
$(PYTHON) -m pip install pip-tools
# Execute project main module
.PHONNY: run
run:
$(PYTHON) -m src.hello_world
# Run unit and feature tests
.PHONNY: test
test:
$(PYTHON) -m pytest -v
$(PYTHON) -m behave -v
# Run unit and feature tests with test (junit) and coverage (cobertura) report
.PHONNY: test-ci
test-ci:
$(PYTHON) -m coverage run --data-file $(REPORTS)/unit_tests/coverage.dat \
-m pytest -v --junitxml=$(REPORTS)/unit_tests/junit.xml
$(PYTHON) -m coverage run --data-file $(REPORTS)/feature_tests/coverage.dat \
-m behave -v --junit --junit-directory=$(REPORTS)/feature_tests
$(PYTHON) -m coverage combine $(REPORTS)/*/*.dat
$(PYTHON) -m coverage xml
$(PYTHON) -m coverage report > $(REPORTS)/coverage_report.txt
# Run isort, ruff, and reformat-gherkin formatter
.PHONNY: format
format:
$(PYTHON) -m isort .
$(PYTHON) -m ruff format .
$(VENV)/bin/reformat-gherkin tests/features
# Run ruff and reformat-gherkin format checker. In addition, run mypy
.PHONNY: lint
lint:
$(PYTHON) -m ruff check .
$(VENV)/bin/reformat-gherkin --check tests/features
$(PYTHON) -m mypy .
# Run make lint with more verbose messages
.PHONNY: lint-ci
lint-ci:
$(PYTHON) -m mypy -v --any-exprs-report $(REPORTS)/mypy/ --lineprecision-report $(REPORTS)/mypy/ .
$(PYTHON) -m ruff check -v .
$(VENV)/bin/reformat-gherkin --check tests/features
# Clean project
.PHONNY: clean
clean:
rm -fr $(VENV)
rm -fr $(REPORTS)
rm -fr .mypy_cache .pytest_cache .ruff_cache
rm -f .coverage coverage.xml
find . -name "*.egg" -exec rm -fr {} +
find . -name "*.egg-info" -exec rm -fr {} +
find . -name "__pycache__" -exec rm -fr {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +