-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (80 loc) · 2.27 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
.PHONY: help bash install-hooks update-uv lint test
# colors
GREEN = $(shell tput -Txterm setaf 2)
YELLOW = $(shell tput -Txterm setaf 3)
WHITE = $(shell tput -Txterm setaf 7)
RESET = $(shell tput -Txterm sgr0)
GRAY = $(shell tput -Txterm setaf 6)
TARGET_MAX_CHAR_NUM = 20
# Help
## Shows help.
help:
@echo 'DEBUG_MODE: ${DEBUG_MODE}'
@echo ''
@echo 'Usage:'
@echo ''
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
if (index(lastLine, "|") != 0) { \
stage = substr(lastLine, index(lastLine, "|") + 1); \
printf "\n ${GRAY}%s: \n\n", stage; \
} \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
if (index(lastLine, "|") != 0) { \
helpMessage = substr(helpMessage, 0, index(helpMessage, "|")-1); \
} \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
@echo ''
.DEFAULT_GOAL := help
# Common
## Run bash environment | Common
bash:
@source .venv/bin/activate
# Development
## Install pre-commit hooks. | Development
install-hooks:
pre-commit install --hook-type pre-commit
pre-commit install --hook-type commit-msg
pre-commit install --install-hooks
## Update uv dependencies
update-uv:
@uv sync --all-extras --upgrade
## Run linters
lint:
@uv run pre-commit run --all-files
## Run imports tests
tests-imports:
@uv sync
@uv pip install pytest pytest-asyncio pytest-cov greenlet
@uv run pytest --cov --cov-append -m 'imports' tests/unit/test_imports.py
## Run integration tests
tests-integration:
@docker compose up -d
@echo "Waiting for services to start..."
@sleep 15s
@uv sync --group=dev --all-extras
@uv run pytest --cov --cov-append -m 'integration'
@echo "Stopping services..."
@docker compose down --remove-orphans --volumes
## Run unit tests
tests-unit:
@uv run pytest --cov --cov-append -m 'unit'
## Run all tests
tests-all:
@rm -rf .coverage
@make tests-imports
@make tests-integration
@make tests-unit
@uv run coverage report
@uv sync --group=dev --group=docs --all-extras
## Serve documentation locally
serve-docs:
@uv run mkdocs serve