-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
99 lines (76 loc) · 2.03 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
PORT = 8000
HOST = localhost
TEST_COMMAND = pytest -s -vv --alluredir=allure-results
COVERAGE_COMMAND = coverage run --branch --concurrency=thread,gevent -m pytest
REPORT_COVERAGE_COMMAND = coverage html --show-contexts --title "Coverage for ${SHA}"
EXPORT_COMMAND = python src/export_spec.py
RUFF_COMMAND = ruff
MYPY_COMMAND = mypy
DOCKER_COMPOSE_EXISTS := $(shell command -v docker-compose 2> /dev/null)
ifeq (${DOCKER_COMPOSE_EXISTS}, 0)
DOCKER_COMPOSE_CMD=docker-compose
else
DOCKER_COMPOSE_CMD=docker compose
endif
DOCKER_EXEC = ${DOCKER_COMPOSE_CMD} run --rm -u root app
COVERAGE_DOCKER_EXEC = ${DOCKER_COMPOSE_CMD} run --rm -u root app
# ###############
# Local
# ###############
# NOTE: Make sure that Redis server is running
.PHONY: run
run:
uvicorn src.main:app --proxy-headers --host ${HOST} --port ${PORT} --reload
.PHONY: run_local
run_local:
${DOCKER_COMPOSE_CMD} up -d redis postgres mailhog rabbitmq
.PHONY: test
test:
${TEST_COMMAND} ./
.PHONY: migrate
migrate:
./compose/fastapi/migrate
.PHONY: migrate-arbitrary
migrate-arbitrary:
./compose/fastapi/migrate arbitrary
# NOTE: cq == "Code quality"
.PHONY: cq
cq:
${RUFF_COMMAND} check . && ${RUFF_COMMAND} format --check . && ${MYPY_COMMAND} .
# NOTE: cqf == "Code quality fix"
.PHONY: cqf
cqf:
${RUFF_COMMAND} format . && ${RUFF_COMMAND} check --fix . && ${MYPY_COMMAND} .
# ###############
# Docker
# ###############
# NOTE: dcq == "Docker code quality"
.PHONY: dcq
dcq:
${DOCKER_EXEC} \
${RUFF_COMMAND} check ./ && ${MYPY_COMMAND} ./
.PHONY: dtest
dtest:
${DOCKER_EXEC} \
${TEST_COMMAND} ./
.PHONY: ctest
ctest:
${COVERAGE_DOCKER_EXEC} \
${COVERAGE_COMMAND}
.PHONY: creport
creport:
${COVERAGE_DOCKER_EXEC} \
${REPORT_COVERAGE_COMMAND}
.PHONY: dcheck
dcheck:
${DOCKER_EXEC} \
${RUFF_COMMAND} check ./ && ${MYPY_COMMAND} ./ && ${TEST_COMMAND}
.PHONY: save_specs
save_specs:
${DOCKER_EXEC} \
${EXPORT_COMMAND} ./
# Setting pre-commit hooks to search for aws keys
.PHONY: aws-scan
aws-scan:
git secrets --register-aws --global && \
pre-commit install