-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
110 lines (88 loc) · 2.92 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
.DEFAULT_GOAL := help
SHELL := zsh
.PHONY : check clean docker docs finalize info init tests update help
.SILENT: check clean docker docs finalize info init tests update _create_env _update_env
python_meant=$(cat .python-version)
python_used=$(which python)
python_version=$(python --version)
project_version=$(grep 'version = ' pyproject.toml | sed 's/version = //' | sed 's/"//' | sed 's/"//')
# Show info about current project.
info:
echo "Project:"
echo "========"
echo "version: $(value project_version)"
echo ""
echo 'Python:'
echo '======='
echo "used python: $(value python_used)"
echo "version: $(value python_version)"
echo ""
echo "Info about current environment:"
echo '==============================='
poetry show
# Clean the working directory from temporary files and caches.
clean:
rm -rf htmlcov; \
rm -rf *.egg-info; \
rm -rf dist; \
rm -rf **/__pycache__; \
rm -rf docs/_build; \
rm -rf .pytest_cache; \
rm -rf .coverage; \
rm -rf log; \
rm -rf pip-wheel-metadata
_create_env:
poetry install
_update_env:
poetry update
_coverage_badge:
coverage-badge -f -o docs/_static/coverage.svg
_lock_it:
poetry lock
dephell deps convert --to requirements.txt
cp requirements.txt docs/doc_requirements.txt
_makefile_doc:
make help > docs/makefile_help.txt
_extract_docstrings:
sphinx-apidoc -o docs/api --force --implicit-namespaces --module-first fastapi_serviceutils
_html_documentation:
PYTHONPATH=. sphinx-build -b html docs docs/_build
_servicetools_doc:
poetry run create_service --help > docs/create_service_help.txt && \
# Run tests using pytest.
tests:
docker-compose down; docker-compose up -d; sleep 2; pytest tests; docker-compose down
# Finalize the main env.
finalize: tests _lock_it
# Create sphinx documentation for the project.
docs: tests _coverage_badge _makefile_doc _servicetools_doc _extract_docstrings _html_documentation _lock_it
doc: _makefile_doc _servicetools_doc _extract_docstrings _html_documentation
# Initialize project
init: _create_env _lock_it
# Update environments based on pyproject.toml definitions.
update: _update_env _lock_it
# Run all checks defined in .pre-commit-config.yaml.
check:
pre-commit run --all-files
# Show the help prompt.
help:
@ echo 'Helpers for development of fastapi_serviceutils.'
@ echo
@ echo ' Usage:'
@ echo ''
@ echo ' make <target> [flags...]'
@ echo ''
@ echo ' Targets:'
@ echo ''
@ awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | sort
@ echo ''
@ echo ' Flags:'
@ echo ''
@ awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?\?=/{ print " ", $$1, $$2, comment }' $(MAKEFILE_LIST) | column -t -s '?=' | sort
@ echo ''
@ echo ''
@ echo ' Note:'
@ echo ' This workflow requires the following programs / tools to be installed:'
@ echo ' - poetry'
@ echo ' - dephell'
@ echo ' - pyenv'