This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
156 lines (124 loc) · 4.48 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Originally wrote by @JrooTJunior in
# https://github.com/aiogram/aiogram/blob/dev-3.x/Makefile
.DEFAULT_GOAL := help
base_python := python3
py := poetry run
python := $(py) python
project_source_dir := src #todo: change it!
reports_dir := reports
.PHONY: help
help:
@echo "======================================================================================="
@echo " build tools "
@echo "======================================================================================="
@echo "Environment:"
@echo " help: Show this message"
@echo " install: Install development dependencies"
@echo " clean: Delete temporary files"
@echo ""
@echo "Code quality:"
@echo " isort: Run isort tool"
@echo " black: Run black tool"
@echo " flake8: Run flake8 tool"
@echo " flake8-report: Run flake8 with HTML reporting"
@echo " mypy: Run mypy tool"
@echo " mypy-report: Run mypy tool with HTML reporting"
@echo " lint: Run isort, black, flake8 and mypy tools"
@echo ""
@echo "Tests:"
@echo " test: Run tests"
@echo " test-coverage: Run tests with HTML reporting (results + coverage)"
@echo " test-coverage-report: Open coverage report in default system web browser"
@echo ""
@echo "Documentation:"
@echo " docs: Build docs"
@echo " docs-serve: Serve docs for local development"
@echo " docs-prepare-reports: Move all HTML reports to docs dir"
@echo ""
@echo "Project"
@echo " build: Run tests build package and docs"
@echo ""
# =================================================================================================
# Environment
# =================================================================================================
.PHONY: install
install:
$(base_python) -m pip install --user -U poetry
poetry install
.PHONY: clean
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -rf `find . -name .pytest_cache`
rm -rf *.egg-info
rm -f .coverage
rm -f report.html
rm -f .coverage.*
rm -rf {build,dist,site,.cache,.mypy_cache,reports}
# =================================================================================================
# Code quality
# =================================================================================================
.PHONY: isort
isort:
$(py) isort -rc $(project_source_dir)
.PHONY: black
black:
$(py) black $(project_source_dir)
.PHONY: flake8
flake8:
$(py) flake8 $(project_source_dir)
.PHONY: flake8-report
flake8-report:
mkdir -p $(reports_dir)/flake8
$(py) flake8 --format=html --htmldir=$(reports_dir)/flake8 $(project_source_dir)
.PHONY: mypy
mypy:
$(py) mypy $(project_source_dir)
.PHONY: mypy-report
mypy-report:
$(py) mypy $(project_source_dir) --html-report $(reports_dir)/typechecking
.PHONY: lint
lint: isort black flake8 mypy
# =================================================================================================
# Tests
# =================================================================================================
.PHONY: test
test:
$(py) pytest --cov=$(project_source_dir) --cov-config .coveragerc tests/
.PHONY: test-coverage
test-coverage:
mkdir -p $(reports_dir)/tests/
$(py) pytest --cov=$(project_source_dir) --cov-config .coveragerc --html=$(reports_dir)/tests/index.html tests/
.PHONY: test-coverage-report
test-coverage-report:
$(py) coverage html -d $(reports_dir)/coverage
.PHONY: test-coverage-view
test-coverage-view:
$(py) coverage html -d $(reports_dir)/coverage
python -c "import webbrowser; webbrowser.open('file://$(shell pwd)/reports/coverage/index.html')"
# =================================================================================================
# Docs
# =================================================================================================
.PHONY: docs
docs:
$(py) mkdocs build
.PHONY: docs-serve
docs-serve:
$(py) mkdocs serve
.PHONY: docs-copy-reports
docs-copy-reports:
mv $(reports_dir)/* site/reports
# =================================================================================================
# Project
# =================================================================================================
.PHONY: build
build: clean flake8-report mypy-report test-coverage docs docs-copy-reports
mkdir -p site/simple
poetry build
mv dist site/simple/$(project_source_dir)
.PHONY: bump
bump:
poetry version $(args)
$(python) scripts/bump_versions.py