@@ -5,34 +5,25 @@ SHELL := /bin/bash
55
66.DEFAULT_GOAL: =help
77.ONESHELL :
8- USING_NPM = $(shell python3 -c "if __import__('pathlib') .Path('package-lock.json').exists(): print('yes')")
9- ENV_PREFIX =.venv/bin/
10- NODE_MODULES_EXISTS = $(shell python3 -c "if __import__('pathlib') .Path('node_modules').exists(): print('yes')")
11- SRC_DIR =src
12- BUILD_DIR =dist
13-
148.EXPORT_ALL_VARIABLES :
15-
16- ifndef VERBOSE
17- .SILENT :
18- endif
19-
9+ MAKEFLAGS += --no-print-directory
10+
11+ # Define colors and formatting
12+ BLUE := $(shell printf "\033[1;34m")
13+ GREEN := $(shell printf "\033[1;32m")
14+ RED := $(shell printf "\033[1;31m")
15+ YELLOW := $(shell printf "\033[1;33m")
16+ NC := $(shell printf "\033[0m")
17+ INFO := $(shell printf "$(BLUE ) ℹ$(NC ) ")
18+ OK := $(shell printf "$(GREEN ) ✓$(NC ) ")
19+ WARN := $(shell printf "$(YELLOW ) ⚠$(NC ) ")
20+ ERROR := $(shell printf "$(RED ) ✖$(NC ) ")
2021
2122.PHONY : help
22- help : # # Display this help text for Makefile
23+ help : # # Display this help text for Makefile
2324 @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
2425
2526
26- .PHONY : upgrade
27- upgrade : # # Upgrade all dependencies to the latest stable versions
28- @echo " => Updating all dependencies"
29- @uv lock --upgrade
30- @echo " => Python Dependencies Updated"
31- @if [ " $( USING_NPM) " ]; then npm upgrade --latest; fi
32- @echo " => Node Dependencies Updated"
33- @$(ENV_PREFIX ) pre-commit autoupdate
34- @echo " => Updated Pre-commit"
35-
3627# =============================================================================
3728# Developer Utils
3829# =============================================================================
@@ -43,109 +34,183 @@ install-uv: ## Install latest version of
4334 @uv tool install nodeenv > /dev/null 2>&1
4435 @echo " ${OK} UV installed successfully"
4536
46- install : # # Install the project and
47- @uv sync
48- uv run python scripts/pre-build.py --install-packages
49- @if [ " $( NODE_MODULES_EXISTS) " ]; then echo " => Removing existing node modules" ; fi
50- if [ " $( NODE_MODULES_EXISTS) " ]; then $( MAKE) destroy-node_modules; fi
51- @echo " => Install complete! Note: If you want to re-install re-run 'make install'"
52-
53-
54- clean : # # Cleanup temporary build artifacts
55- @echo " => Cleaning working directory"
56- @rm -rf .pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/ .coverage coverage.xml coverage.json htmlcov/ .mypy_cache
57- @find . -name ' *.egg-info' -exec rm -rf {} +
58- @find . -name ' *.egg' -exec rm -f {} +
59- @find . -name ' *.pyc' -exec rm -f {} +
60- @find . -name ' *.pyo' -exec rm -f {} +
61- @find . -name ' *~' -exec rm -f {} +
62- @find . -name ' __pycache__' -exec rm -rf {} +
63- @find . -name ' .pytest_cache' -exec rm -rf {} +
64- @find . -name ' .ipynb_checkpoints' -exec rm -rf {} +
65-
66- destroy-venv : # # Destroy the virtual environment
67- @echo " => Cleaning Python virtual environment"
68- @rm -rf .venv
69-
70- destroy-node_modules : # # Destroy the node environment
71- @echo " => Cleaning Node modules"
72- @rm -rf node_modules
73-
74- tidy : clean destroy-venv destroy-node_modules # # Clean up everything
75-
76- migrations : # # Generate database migrations
77- @echo " ATTENTION: This operation will create a new database migration for any defined models changes."
78- @while [ -z " $$ MIGRATION_MESSAGE" ]; do read -r -p " Migration message: " MIGRATION_MESSAGE; done ;
79- @$(ENV_PREFIX ) app database make-migrations --autogenerate -m " $$ {MIGRATION_MESSAGE}"
37+ .PHONY : install
38+ install : destroy clean # # Install the project, dependencies, and pre-commit for local development
39+ @echo " ${INFO} Starting fresh installation..."
40+ @uv python pin 3.12 > /dev/null 2>&1
41+ @uv venv > /dev/null 2>&1
42+ @uv sync --all-extras --dev
43+ @if ! command -v npm > /dev/null 2>&1 ; then \
44+ echo " ${INFO} Installing Node environment... 📦" ; \
45+ uvx nodeenv .venv --force --quiet; \
46+ fi
47+ @NODE_OPTIONS=" --no-deprecation --disable-warning=ExperimentalWarning" npm install --no-fund
48+ @echo " ${OK} Installation complete! 🎉"
8049
81- .PHONY : migrate
82- migrate : # # Generate database migrations
83- @echo " ATTENTION: Will apply all database migrations."
84- @$(ENV_PREFIX ) app database upgrade
85-
86- .PHONY : build
87- build :
88- @echo " => Building package..."
89- uv run python scripts/pre-build.py --build-assets
90- @uv build
91- @echo " => Package build complete..."
50+ .PHONY : upgrade
51+ upgrade : # # Upgrade all dependencies to the latest stable versions
52+ @echo " ${INFO} Updating all dependencies... 🔄"
53+ @uv lock --upgrade
54+ @NODE_OPTIONS=" --no-deprecation --disable-warning=ExperimentalWarning" uv run npm upgrade --latest
55+ @echo " ${OK} Dependencies updated 🔄"
56+ @NODE_OPTIONS=" --no-deprecation --disable-warning=ExperimentalWarning" uv run pre-commit autoupdate
57+ @echo " ${OK} Updated Pre-commit hooks 🔄"
58+
59+ .PHONY : clean
60+ clean : # # Cleanup temporary build artifacts
61+ @echo " ${INFO} Cleaning working directory..."
62+ @rm -rf pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/ .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/** /.pytest_cache .mypy_cache .unasyncd_cache/ .auto_pytabs_cache node_modules > /dev/null 2>&1
63+ @find . -name ' *.egg-info' -exec rm -rf {} + > /dev/null 2>&1
64+ @find . -type f -name ' *.egg' -exec rm -f {} + > /dev/null 2>&1
65+ @find . -name ' *.pyc' -exec rm -f {} + > /dev/null 2>&1
66+ @find . -name ' *.pyo' -exec rm -f {} + > /dev/null 2>&1
67+ @find . -name ' *~' -exec rm -f {} + > /dev/null 2>&1
68+ @find . -name ' __pycache__' -exec rm -rf {} + > /dev/null 2>&1
69+ @find . -name ' .ipynb_checkpoints' -exec rm -rf {} + > /dev/null 2>&1
70+ @echo " ${OK} Working directory cleaned"
71+ $(MAKE ) docs-clean
72+
73+ .PHONY : destroy
74+ destroy : # # Destroy the virtual environment
75+ @echo " ${INFO} Destroying virtual environment... 🗑️"
76+ @uv run pre-commit clean > /dev/null 2>&1
77+ @rm -rf .venv
78+ @echo " ${OK} Virtual environment destroyed 🗑️"
9279
9380.PHONY : lock
94- lock : # # Rebuild lockfiles from scratch, updating all dependencies
95- @uv lock
81+ lock : # # Rebuild lockfiles from scratch, updating all dependencies
82+ @echo " ${INFO} Rebuilding lockfiles... 🔄"
83+ @uv lock --upgrade > /dev/null 2>&1
84+ @echo " ${OK} Lockfiles updated"
85+
86+ .PHONY : release
87+ release : # # Bump version and create release tag
88+ @echo " ${INFO} Preparing for release... 📦"
89+ @make clean
90+ @uv run bump-my-version bump $(bump )
91+ @make build
92+ @echo " ${OK} Release complete 🎉"
9693
97- start-infra :
98- docker compose -f docker-compose.infra.yml up --force-recreate -d
9994
100- stop-infra :
101- docker compose -f docker-compose.infra.yml down --remove-orphans
10295# =============================================================================
10396# Tests, Linting, Coverage
10497# =============================================================================
105- .PHONY : lint
106- lint : # # Runs pre-commit hooks; includes ruff linting, codespell, black
107- @echo " => Running pre-commit process"
108- @$(ENV_PREFIX ) pre-commit run --all-files
109- @echo " => Pre-commit complete"
98+ .PHONY : mypy
99+ mypy : # # Run mypy
100+ @echo " ${INFO} Running mypy... 🔍"
101+ @uv run dmypy run
102+ @echo " ${OK} Mypy checks passed ✨"
103+
104+ .PHONY : pyright
105+ pyright : # # Run pyright
106+ @echo " ${INFO} Running pyright... 🔍"
107+ @uv run pyright
108+ @echo " ${OK} Pyright checks passed ✨"
109+
110+ .PHONY : type-check
111+ type-check : mypy pyright # # Run all type checking
112+
113+ .PHONY : pre-commit
114+ pre-commit : # # Runs pre-commit hooks; includes ruff formatting and linting, codespell
115+ @echo " ${INFO} Running pre-commit checks... 🔎"
116+ @uv run pre-commit run --color=always --all-files
117+ @echo " ${OK} Pre-commit checks passed ✨"
118+
119+ .PHONY : slotscheck
120+ slotscheck : # # Run slotscheck
121+ @echo " ${INFO} Running slots check... 🔍"
122+ @uv run slotscheck -m app
123+ @echo " ${OK} Slots check passed ✨"
124+
125+ .PHONY : fix
126+ fix : # # Run formatting scripts
127+ @echo " ${INFO} Running code formatters... 🔧"
128+ @uv run ruff check --fix --unsafe-fixes
129+ @echo " ${OK} Code formatting complete ✨"
110130
111- .PHONY : format
112- format : # # Runs code formatting utilities
113- @echo " => Running pre-commit process"
114- @$(ENV_PREFIX ) ruff . --fix
115- @echo " => Pre-commit complete"
131+ .PHONY : lint
132+ lint : pre-commit type-check slotscheck # # Run all linting
116133
117134.PHONY : coverage
118- coverage : # # Run the tests and generate coverage report
119- @echo " => Running tests with coverage"
120- @$( ENV_PREFIX ) pytest tests --cov=app
121- @$( ENV_PREFIX ) coverage html
122- @$( ENV_PREFIX ) coverage xml
123- @echo " => Coverage report generated"
135+ coverage : # # Run the tests and generate coverage report
136+ @echo " ${INFO} Running tests with coverage... 📊 "
137+ @uv run pytest tests --cov -n auto --quiet
138+ @uv run coverage html > /dev/null 2>&1
139+ @uv run coverage xml > /dev/null 2>&1
140+ @echo " ${OK} Coverage report generated ✨ "
124141
125142.PHONY : test
126- test : # # Run the tests
127- @echo " => Running test cases"
128- @$(ENV_PREFIX ) pytest tests
129- @echo " => Tests complete"
143+ test : # # Run the tests
144+ @echo " ${INFO} Running test cases... 🧪"
145+ @uv run pytest tests -n 2 --quiet
146+ @echo " ${OK} Tests passed ✨"
147+
148+ .PHONY : test-all
149+ test-all : # # Run all tests
150+ @echo " ${INFO} Running all test cases... 🧪"
151+ @uv run pytest tests -m ' ' -n 2 --quiet
152+ @echo " ${OK} All tests passed ✨"
153+
154+ .PHONY : check-all
155+ check-all : lint test-all coverage # # Run all linting, tests, and coverage checks
156+
130157
131158# =============================================================================
132159# Docs
133160# =============================================================================
134- .PHONY : docs-install
135- docs-install : # # Install docs dependencies
136- @echo " => Installing documentation dependencies"
137- @uv sync --group docs
138- @echo " => Installed documentation dependencies"
139-
140- docs-clean : # # Dump the existing built docs
141- @echo " => Cleaning documentation build assets"
142- @rm -rf docs/_build
143- @echo " => Removed existing documentation build assets"
144-
145- docs-serve : docs-clean # # Serve the docs locally
146- @echo " => Serving documentation"
147- $uv run sphinx-autobuild docs docs/_build/ -j auto --watch src --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002
148-
149- docs : docs-clean # # Dump the existing built docs and rebuild them
150- @echo " => Building documentation"
151- @uv run sphinx-build -M html docs docs/_build/ -E -a -j auto --keep-going
161+ .PHONY : docs-clean
162+ docs-clean : # # Dump the existing built docs
163+ @echo " ${INFO} Cleaning documentation build assets... 🧹"
164+ @rm -rf docs/_build > /dev/null 2>&1
165+ @echo " ${OK} Documentation assets cleaned"
166+
167+ .PHONY : docs-serve
168+ docs-serve : docs-clean # # Serve the docs locally
169+ @echo " ${INFO} Starting documentation server... 📚"
170+ @uv run sphinx-autobuild docs docs/_build/ -j auto --watch app --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002
171+
172+ .PHONY : docs
173+ docs : docs-clean # # Dump the existing built docs and rebuild them
174+ @echo " ${INFO} Building documentation... 📝"
175+ @uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going
176+ @echo " ${OK} Documentation built successfully"
177+
178+ .PHONY : docs-linkcheck
179+ docs-linkcheck : # # Run the link check on the docs
180+ @echo " ${INFO} Checking documentation links... 🔗"
181+ @uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_ignore=' http://.*' ,' https://.*' > /dev/null 2>&1
182+ @echo " ${OK} Link check complete"
183+
184+ .PHONY : docs-linkcheck-full
185+ docs-linkcheck-full : # # Run the full link check on the docs
186+ @echo " ${INFO} Running full link check... 🔗"
187+ @uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_anchors=0 > /dev/null 2>&1
188+ @echo " ${OK} Full link check complete"
189+
190+
191+ # -----------------------------------------------------------------------------
192+ # Local Infrastructure
193+ # -----------------------------------------------------------------------------
194+
195+ .PHONY : start-infra
196+ start-infra : # # Start local containers
197+ @echo " ${INFO} Starting local infrastructure... 🚀"
198+ @docker compose -f deploy/docker-compose.infra.yml up -d --force-recreate > /dev/null 2>&1
199+ @echo " ${OK} Infrastructure is ready"
200+
201+ .PHONY : stop-infra
202+ stop-infra : # # Stop local containers
203+ @echo " ${INFO} Stopping infrastructure... 🛑"
204+ @docker compose -f deploy/docker-compose.infra.yml down > /dev/null 2>&1
205+ @echo " ${OK} Infrastructure stopped"
206+
207+ .PHONY : wipe-infra
208+ wipe-infra : # # Remove local container info
209+ @echo " ${INFO} Wiping infrastructure... 🧹"
210+ @docker compose -f deploy/docker-compose.infra.yml down -v --remove-orphans > /dev/null 2>&1
211+ @echo " ${OK} Infrastructure wiped clean"
212+
213+ .PHONY : infra-logs
214+ infra-logs : # # Tail development infrastructure logs
215+ @echo " ${INFO} Tailing infrastructure logs... 📋"
216+ @docker compose -f deploy/docker-compose.infra.yml logs -f
0 commit comments