-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (53 loc) · 1.88 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
export PYTHONPATH=$(shell pwd)/src/
export PYTHONDONTWRITEBYTECODE=1
.PHONY=help
help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
clean: ## Remove cache files
@find . -name "*.pyc" | xargs rm -rf
@find . -name "*.pyo" | xargs rm -rf
@find . -name "__pycache__" -type d | xargs rm -rf
@find . -name ".pytest_cache" -type d | xargs rm -rf
@find . -name ".coverage" | xargs rm -rf
@find . -name "coverage.xml" | xargs rm -rf
### Dependencies section ###
_base_pip:
@pip install -U pip poetry wheel
dev-dependencies: _base_pip ## Install development dependencies
@poetry install
dependencies: _base_pip ## Install dependencies
@poetry install --no-dev
outdated: ## Show outdated packages
@poetry show --outdated
### Lint section ###
_flake8:
@flake8 --show-source src/ tests/
_isort:
@isort --check-only src/ tests/
_black:
@black --diff --check src/ tests/
_isort-fix:
@isort src/ tests/
_black_fix:
@black src/ tests/
_mypy:
@mypy src/ tests/
lint: _flake8 _isort _black _mypy ## Check code lint
format-code: _isort-fix _black_fix ## Format code
### Tests section ###
test: clean ## Run tests
@pytest tests/
test-coverage: clean ## Run tests with coverage output
@pytest tests/ --cov src/ --cov-report term-missing --cov-report xml
test-matching: clean ## Run tests by match ex: make test-matching k=name_of_test
@pytest -k $(k) tests/
### Migrations DB section ###
migrations: ## Create named migrations file. Ex: make migrations name=<migration_name>
@python -m alembic revision --autogenerate --message $(name)
migrate: ## Apply migrations
@python -m alembic upgrade head
### Run section ###
run: ## Run server with default settings
@uvicorn --factory src.entrypoints.fastapi_app.main:create_app --reload
init: dev-dependencies ## Initialize project
@cp -n .env.sample .env