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