-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
89 lines (75 loc) · 2.39 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
# Define the name of the main virtual environment directory
DEV_VENV_DIR := .venv
# Define the Python executable to use
PYTHON := python3
# Define the command to create a virtual environment
VENV_CMD := $(PYTHON) -m venv $(DEV_VENV_DIR)
# Define the command to activate the base virtual environment
ACTIVATE_DEV := . $(DEV_VENV_DIR)/bin/activate
# ANSI color codes for red, green, and bold text
RED_BOLD := \033[1;31m
GREEN_BOLD := \033[1;32m
RESET := \033[0m
# Check if Python is available
check_python:
@command -v $(PYTHON) >/dev/null 2>&1 || { \
echo -e "$(RED_BOLD)Python is not installed. Aborting.$(RESET)"; \
exit 1; \
}
# Create the development virtual environment if it doesn't exist
create_dev_venv: check_python
@if [ ! -d "$(DEV_VENV_DIR)" ]; then \
echo -e "$(GREEN_BOLD)Creating development virtual environment...$(RESET)"; \
$(VENV_CMD); \
else \
echo -e "\nDevelopment virtual environment already exists.\n"; \
fi
# Activate the base virtual environment and install uv
install_uv_dev: create_dev_venv
$(ACTIVATE_DEV) && pip install uv
# Compile and install development requirements using uv in the development virtual environment
install_dev_requirements: create_dev_venv
@$(ACTIVATE_DEV) && \
pip install uv && \
uv pip compile pyproject.toml -o requirements.txt && \
uv pip compile pyproject.toml --extra dev -o requirements-dev.txt && \
uv pip install -r requirements.txt \
uv pip install -r requirements-dev.txt
# Install pre-commit hooks
install_pre_commit: install_dev_requirements
@$(ACTIVATE_DEV) && pre-commit install
# Setup the development environment
setup_dev: install_dev_requirements install_pre_commit
@echo -e "\n$(GREEN_BOLD)Development environment setup complete.$(RESET)\n"
# Make a new Alembic migration
migrations:
@$(ACTIVATE_DEV) && alembic revision --autogenerate
# Upgrade the database to the latest revision
upgrade:
@$(ACTIVATE_DEV) && alembic upgrade head
# Bootstrap the CDK stack
bootstrap:
@node_modules/aws-cdk/bin/cdk bootstrap
# Deploy the CDK stack
deploy:
@node_modules/aws-cdk/bin/cdk deploy --all
# Destroy the CDK stack
destroy:
@node_modules/aws-cdk/bin/cdk destroy
# Run the unit tests
tests:
@$(ACTIVATE_DEV) && pytest tests
.PHONY: \
check_python \
create_dev_venv \
install_uv_dev \
compile_dev_requirements \
install_dev_requirements \
setup_dev \
migrations \
deploy \
destroy \
upgrade \
bootstrap \
tests \
install_pre_commit