-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (73 loc) · 2.71 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
.PHONY: clean clean-test clean-pyc clean-build docs
## remove all build, test, coverage and Python artifacts
clean: clean-build clean-pyc clean-test docs-clean
## remove build artifacts
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg' -exec rm -f {} +
## remove Python file artifacts
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
rm -rf .mypy_cache/
rm -rf .ruff_cache
## remove test and coverage artifacts
clean-test:
rm -fr .tox/
rm -f .coverage*
rm -fr htmlcov/
rm -rf mypy_report/
rm -rf *.html
rm -fr .cache/
rm -fr .pytest_cache
rm -f coverage.xml
## fix with ruff
format:
poetry run ruff --select I . --fix
poetry run ruff format .
## check style with ruff, mypy
lint:
poetry run ruff . --exit-zero --fix
poetry run mypy .
## run tests with the default Python
test:
poetry run pytest
## run tests with coverage
coverage:
poetry run coverage run -m pytest
poetry run coverage combine
poetry run coverage report
## check code coverage and test report with the default Python
test-reports:
poetry run coverage run -m pytest --html=test_report.html --self-contained-html
poetry run coverage combine
poetry run coverage html
poetry run mypy --html-report=mypy_report --install-types --non-interactive src tests
@echo "Open reports htmlcov/index.html, test_report.html, mypy_report/index.html in your browser"
## run typer-cli to build the cli markdown docs
cli-docs:
poetry run typer aoc.cli utils docs --name aoc > docs/docs/CLI.md
## generate Mkdocs HTML documentation
docs: docs-clean cli-docs
cd docs/; poetry run mkdocs build
## serve docs
serve-docs: docs-clean cli-docs
cd docs/; poetry run mkdocs serve --watch ../src/aoc
## remove previously build docs
docs-clean:
cd docs/; rm -rf site/;
## builds source and wheel package
dist: clean
poetry build
##############################################################################
# Self Documenting Commands #
##############################################################################
.DEFAULT_GOAL := show-help
# See <https://gist.github.com/klmr/575726c7e05d8780505a> for explanation.
.PHONY: show-help
show-help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)";echo;sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## //;td" -e"s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST}|LC_ALL='C' sort -f|awk -F --- -v n=$$(tput cols) -v i=19 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n";}'