Debian Codegraph @

Makefile

raw
1 SHELL := /bin/bash
2
3 # =============================================================================
4 # Configuration and Environment Variables
5 # =============================================================================
6
7 .DEFAULT_GOAL:=help
8 .ONESHELL:
9 .EXPORT_ALL_VARIABLES:
10 MAKEFLAGS += --no-print-directory
11
12 # -----------------------------------------------------------------------------
13 # Display Formatting and Colors
14 # -----------------------------------------------------------------------------
15 BLUE := $(shell printf "\033[1;34m")
16 GREEN := $(shell printf "\033[1;32m")
17 RED := $(shell printf "\033[1;31m")
18 YELLOW := $(shell printf "\033[1;33m")
19 NC := $(shell printf "\033[0m")
20 INFO := $(shell printf "$(BLUE)ℹ$(NC)")
21 OK := $(shell printf "$(GREEN)✓$(NC)")
22 WARN := $(shell printf "$(YELLOW)⚠$(NC)")
23 ERROR := $(shell printf "$(RED)✖$(NC)")
24
25 # =============================================================================
26 # Help and Documentation
27 # =============================================================================
28
29 .PHONY: help
30 help: ## Display this help text for Makefile
31 @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)
32
33 # =============================================================================
34 # Installation and Environment Setup
35 # =============================================================================
36
37 .PHONY: install-uv
38 install-uv: ## Install latest version of uv
39 @echo "${INFO} Installing uv..."
40 @curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1
41 @uv tool install nodeenv >/dev/null 2>&1
42 @echo "${OK} UV installed successfully"
43
44 .PHONY: install
45 install: destroy clean ## Install the project, dependencies, and pre-commit
46 @echo "${INFO} Starting fresh installation..."
47 @uv python pin 3.12 >/dev/null 2>&1
48 @uv venv >/dev/null 2>&1
49 @uv sync --all-extras --dev
50 @echo "${OK} Installation complete! 🎉"
51
52 .PHONY: destroy
53 destroy: ## Destroy the virtual environment
54 @echo "${INFO} Destroying virtual environment... 🗑️"
55 @uv run pre-commit clean >/dev/null 2>&1
56 @rm -rf .venv
57 @echo "${OK} Virtual environment destroyed 🗑️"
58
59 # =============================================================================
60 # Dependency Management
61 # =============================================================================
62
63 .PHONY: upgrade
64 upgrade: ## Upgrade all dependencies to latest stable versions
65 @echo "${INFO} Updating all dependencies... 🔄"
66 @uv lock --upgrade
67 @echo "${OK} Dependencies updated 🔄"
68 @uv run pre-commit autoupdate
69 @echo "${OK} Updated Pre-commit hooks 🔄"
70
71 .PHONY: lock
72 lock: ## Rebuild lockfiles from scratch
73 @echo "${INFO} Rebuilding lockfiles... 🔄"
74 @uv lock --upgrade >/dev/null 2>&1
75 @echo "${OK} Lockfiles updated"
76
77 # =============================================================================
78 # Build and Release
79 # =============================================================================
80
81 .PHONY: build
82 build: ## Build the package
83 @echo "${INFO} Building package... 📦"
84 @uv build >/dev/null 2>&1
85 @echo "${OK} Package build complete"
86
87 .PHONY: release
88 release: ## Bump version and create release tag
89 @echo "${INFO} Preparing for release... 📦"
90 @make docs
91 @make clean
92 @make build
93 @uv lock --upgrade-package advanced-alchemy >/dev/null 2>&1
94 @uv run bump-my-version bump $(bump)
95 @echo "${OK} Release complete 🎉"
96
97 # =============================================================================
98 # Cleaning and Maintenance
99 # =============================================================================
100
101 .PHONY: clean
102 clean: ## Cleanup temporary build artifacts
103 @echo "${INFO} Cleaning working directory... 🧹"
104 @rm -rf .pytest_cache .ruff_cache .hypothesis build/ 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
105 @find . -name '*.egg-info' -exec rm -rf {} + >/dev/null 2>&1
106 @find . -type f -name '*.egg' -exec rm -f {} + >/dev/null 2>&1
107 @find . -name '*.pyc' -exec rm -f {} + >/dev/null 2>&1
108 @find . -name '*.pyo' -exec rm -f {} + >/dev/null 2>&1
109 @find . -name '*~' -exec rm -f {} + >/dev/null 2>&1
110 @find . -name '__pycache__' -exec rm -rf {} + >/dev/null 2>&1
111 @find . -name '.ipynb_checkpoints' -exec rm -rf {} + >/dev/null 2>&1
112 @echo "${OK} Working directory cleaned"
113 $(MAKE) docs-clean
114
115 # =============================================================================
116 # Testing and Quality Checks
117 # =============================================================================
118
119 .PHONY: test
120 test: ## Run the tests
121 @echo "${INFO} Running test cases... 🧪"
122 @uv run pytest -n 2 --quiet
123 @echo "${OK} Tests passed ✨"
124
125 .PHONY: coverage
126 coverage: ## Run tests with coverage report
127 @echo "${INFO} Running tests with coverage... 📊"
128 @uv run pytest --cov -n auto --quiet
129 @uv run coverage html >/dev/null 2>&1
130 @uv run coverage xml >/dev/null 2>&1
131 @echo "${OK} Coverage report generated ✨"
132
133 # -----------------------------------------------------------------------------
134 # Type Checking
135 # -----------------------------------------------------------------------------
136
137 .PHONY: mypy
138 mypy: ## Run mypy
139 @echo "${INFO} Running mypy... 🔍"
140 @uv run dmypy run
141 @echo "${OK} Mypy checks passed ✨"
142
143 .PHONY: mypy-nocache
144 mypy-nocache: ## Run Mypy without cache
145 @echo "${INFO} Running mypy without cache... 🔍"
146 @uv run mypy
147 @echo "${OK} Mypy checks passed ✨"
148
149 .PHONY: pyright
150 pyright: ## Run pyright
151 @echo "${INFO} Running pyright... 🔍"
152 @uv run pyright
153 @echo "${OK} Pyright checks passed ✨"
154
155 .PHONY: type-check
156 type-check: mypy pyright ## Run all type checking
157
158 # -----------------------------------------------------------------------------
159 # Linting and Formatting
160 # -----------------------------------------------------------------------------
161
162 .PHONY: pre-commit
163 pre-commit: ## Run pre-commit hooks
164 @echo "${INFO} Running pre-commit checks... 🔎"
165 @NODE_OPTIONS="--no-deprecation --disable-warning=ExperimentalWarning" uv run pre-commit run --color=always --all-files
166 @echo "${OK} Pre-commit checks passed ✨"
167
168 .PHONY: slotscheck
169 slotscheck: ## Run slotscheck
170 @echo "${INFO} Running slots check... 🔍"
171 @uv run slotscheck
172 @echo "${OK} Slots check passed ✨"
173
174 .PHONY: fix
175 fix: ## Run code formatters
176 @echo "${INFO} Running code formatters... 🔧"
177 @uv run ruff check --fix --unsafe-fixes
178 @echo "${OK} Code formatting complete ✨"
179
180 .PHONY: lint
181 lint: pre-commit type-check slotscheck ## Run all linting checks
182
183 .PHONY: check-all
184 check-all: lint test coverage ## Run all checks (lint, test, coverage)
185
186 # =============================================================================
187 # Documentation
188 # =============================================================================
189
190 .PHONY: docs-clean
191 docs-clean: ## Clean documentation build
192 @echo "${INFO} Cleaning documentation build assets... 🧹"
193 @rm -rf docs/_build >/dev/null 2>&1
194 @echo "${OK} Documentation assets cleaned"
195
196 .PHONY: docs-serve
197 docs-serve: docs-clean ## Serve documentation locally
198 @echo "${INFO} Starting documentation server... 📚"
199 @uv run sphinx-autobuild docs docs/_build/ -j auto --watch litestar_htmx --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002
200
201 .PHONY: docs
202 docs: docs-clean ## Build documentation
203 @echo "${INFO} Building documentation... 📝"
204 @uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going >/dev/null 2>&1
205 @echo "${OK} Documentation built successfully"
206
207 .PHONY: docs-linkcheck
208 docs-linkcheck: ## Check documentation links
209 @echo "${INFO} Checking documentation links... 🔗"
210 @uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_ignore='http://.*','https://.*'
211 @echo "${OK} Link check complete"
212
213 .PHONY: docs-linkcheck-full
214 docs-linkcheck-full: ## Run full documentation link check
215 @echo "${INFO} Running full link check... 🔗"
216 @uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_anchors=0
217 @echo "${OK} Full link check complete"