-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
109 lines (77 loc) · 1.96 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
VENV=.venv
ifeq (${OS},Windows_NT)
BIN=${VENV}/Scripts
else
BIN=${VENV}/bin
endif
export PATH := $(BIN):$(PATH)
FLAKE=flake8
PYLINT=pylint
ISORT=isort
BLACK=black
PYTEST=pytest
COVERAGE=coverage
SOURCES=ambrosia
TESTS=tests
REPORTS=reports
# Installation
reports:
@mkdir ${REPORTS}
.venv:
@echo "Creating virtualenv...\t\t"
poetry install --no-root
poetry install --all-extras
@echo "[Installed]"
install: .venv reports
# Linters
.isort:
@echo "Running isort checks..."
@${ISORT} --check ${SOURCES} ${TESTS}
@echo "[Isort checks finished]"
.black:
@echo "Running black checks..."
@${BLACK} --check --diff ${SOURCES} ${TESTS} ${BENCHMARK}
@echo "[Black checks finished]"
.pylint: reports
@echo "Running pylint checks..."
@${PYLINT} ${SOURCES} ${TESTS} --exit-zero
@${PYLINT} ${SOURCES} ${TESTS} --exit-zero > ${REPORTS}/pylint.txt
@echo "[Pylint checks finished]"
.flake8:
@echo "Running flake8 checks...\t"
@${FLAKE} ${SOURCES} ${TESTS} --exit-zero
@echo "[Flake8 checks finished]"
# Fixers & formatters
.isort_fix:
@echo "Fixing isort..."
@${ISORT} ${SOURCES} ${TESTS}
@echo "[Isort fixed]"
.black_fix:
@echo "Formatting with black..."
@${BLACK} -q ${SOURCES} ${TESTS}
@echo "[Black fixed]"
# Tests
.pytest:
@echo "Running pytest checks...\t"
@PYTHONPATH=. ${PYTEST} --cov=${SOURCES} --cov-report=xml:${REPORTS}/coverage.xml
coverage: .venv reports
@echo "Running coverage..."
${COVERAGE} run --source ${SOURCES} --module pytest
${COVERAGE} report
${COVERAGE} html -d ${REPORTS}/coverage_html
${COVERAGE} xml -o ${REPORTS}/coverage.xml -i
# Generalization
.autoformat: .isort_fix .black_fix
autoformat: .venv .autoformat
.lint: .isort .black .pylint .flake8
lint: .venv .lint
.test: .pytest
test: .venv .test
# Cleaning
clean:
@rm -rf build dist .eggs *.egg-info
@rm -rf ${VENV}
@rm -rf ${REPORTS}
@find . -type d -name '.mypy_cache' -exec rm -rf {} +
@find . -type d -name '*pytest_cache*' -exec rm -rf {} +
reinstall: clean install