-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
130 lines (98 loc) · 3.54 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
DOCKER_COMPOSE=docker compose
DOCKER_ENVIRONMENT=docker-compose.yml
PRE_RUN_API_COMMAND=${DOCKER_COMPOSE} -f ${DOCKER_ENVIRONMENT} run --rm appname-app
PACKAGE_NAME=appname
VENV_FOLDER=.venv
LAUNCH_IN_VENV=source ${VENV_FOLDER}/bin/activate &&
PYTHON_VERSION=python3.11
PYTHON=./.venv/bin/python
PHONY = help install install-dev test format lint type-check secure migrations migrate
# target: help - Display callable targets.
help:
@echo "---------------HELP-----------------"
@egrep "^# target:" [Mm]akefile
@echo "------------------------------------"
# target: install - Install the project locally
install:
${PYTHON} -m flit install --env --deps=develop
# target: install-dev - Install the project for development locally
install-dev:
${PYTHON} -m flit install --env --deps=develop --symlink
# target: Test commands
# target: test - Run tests
test:
${PRE_RUN_API_COMMAND} test
# target: test-last-failed - Run last failed tests
test-last-failed:
${PRE_RUN_API_COMMAND} test-last-failed
# target: test-current-v - Run tests with pytest mark current
test-current:
${PRE_RUN_API_COMMAND} test-current
# target: test-current - Run tests with pytest mark current -verbose
test-current-v:
${PRE_RUN_API_COMMAND} test-current-v
# target: test-domain - Run tests with in domain folder
test-domain:
${PRE_RUN_API_COMMAND} test-domain
# target: test-int - Run tests with in integrations folder
test-int:
${PRE_RUN_API_COMMAND} test-int
# target: test-repos - Run tests with in repositories folder
test-repos:
${PRE_RUN_API_COMMAND} test-repos
# target: test-services - Run tests with in services folder
test-services:
${PRE_RUN_API_COMMAND} test-services
# target: test-uows - Run tests with in uows folder
test-uows:
${PRE_RUN_API_COMMAND} test-uows
# target: test-cov - Run tests with coverage
test-cov:
${PRE_RUN_API_COMMAND} test-cov
# target: format - Format the code
format:
${PYTHON} -m isort src tests --force-single-line-imports
${PYTHON} -m autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place src --exclude=__init__.py
${PYTHON} -m black src tests --config pyproject.toml
${PYTHON} -m isort src tests
# target: lint - Run linter
lint:
${PYTHON} -m flake8 --max-complexity 5 --max-cognitive-complexity=3 src
${PYTHON} -m black src tests --check --diff --config pyproject.toml
${PYTHON} -m isort src tests --check --diff
# target: type-check - Run type checker
type-check:
${PYTHON} -m pytype --config=pytype.cfg src
# target: secure - Run all security related commands
secure:
${PYTHON} -m bandit -r src --config pyproject.toml
# target: migrations - Create database migrations
migrations:
alembic -c src/appname/adapters/db/alembic.ini revision --autogenerate
# target: migrate - Run database migrations
migrate:
alembic -c src/appname/adapters/db/alembic.ini upgrade head
# target: run-server - Run the server
server:
${PRE_RUN_API_COMMAND} server
# target: setup - Setup the project locally
setup:
rm -rf ${VENV_FOLDER}
${PYTHON_VERSION} -m venv ${VENV_FOLDER}
${LAUNCH_IN_VENV} pip install flit
# target: Docker targets
# target: build - Build the docker images
build:
${DOCKER_COMPOSE} -f ${DOCKER_ENVIRONMENT} build
# target: run - Run the project
run:
${DOCKER_COMPOSE} -f ${DOCKER_ENVIRONMENT} up -d
# taget: down - Stop the project
down:
${DOCKER_COMPOSE} -f ${DOCKER_ENVIRONMENT} down
# target: clean-volumes - Stop the project and clean all volumes
clean-volumes:
${DOCKER_COMPOSE} -f ${DOCKER_ENVIRONMENT} down -v
# target: logs - Show project logs
logs:
${DOCKER_COMPOSE} -f ${DOCKER_ENVIRONMENT} logs -f