-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
155 lines (128 loc) · 5.64 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
SHELL := /bin/bash
# =============================================================================
# Variables
# =============================================================================
.DEFAULT_GOAL:=help
.ONESHELL:
.EXPORT_ALL_VARIABLES:
.PHONY: help
help: ## Display this help text for Makefile
@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)
.PHONY: upgrade
upgrade: ## Upgrade all dependencies to the latest stable versions
@echo "=> Updating all dependencies"
@uv lock --upgrade
@echo "=> Dependencies Updated"
@uv run pre-commit autoupdate
@echo "=> Updated Pre-commit"
# =============================================================================
# Developer Utils
# =============================================================================
.PHONY: install-uv
install-uv: ## Install latest version of uv
@curl -LsSf https://astral.sh/uv/install.sh | sh
.PHONY: install
install: destroy clean ## Install the project, dependencies, and pre-commit for local development
@uv python pin 3.12
@uv sync --all-extras --dev
@echo "=> Install complete!"
.PHONY: clean
clean: ## Cleanup temporary build artifacts
@echo "=> Cleaning working directory"
@rm -rf .pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/
@find . -name '*.egg-info' -exec rm -rf {} +
@find . -type f -name '*.egg' -exec rm -f {} +
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@find . -name '*~' -exec rm -f {} +
@find . -name '__pycache__' -exec rm -rf {} +
@find . -name '.ipynb_checkpoints' -exec rm -rf {} +
@rm -rf .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/**/.pytest_cache .mypy_cache .unasyncd_cache/
$(MAKE) docs-clean
.PHONY: destroy
destroy: ## Destroy the virtual environment
@uv run pre-commit clean
@rm -rf .venv
.PHONY: lock
lock: ## Rebuild lockfiles from scratch, updating all dependencies
@uv lock --upgrade
# =============================================================================
# Tests, Linting, Coverage
# =============================================================================
.PHONY: mypy
mypy: ## Run mypy
@echo "=> Running mypy"
@uv run dmypy run
@echo "=> mypy complete"
.PHONY: mypy-nocache
mypy-nocache: ## Run Mypy without cache
@echo "=> Running mypy without a cache"
@uv run mypy
@echo "=> mypy complete"
.PHONY: pyright
pyright: ## Run pyright
@echo "=> Running pyright"
@uv run pyright
@echo "=> pyright complete"
.PHONY: type-check
type-check: mypy pyright ## Run all type checking
.PHONY: pre-commit
pre-commit: ## Runs pre-commit hooks; includes ruff formatting and linting, codespell
@echo "=> Running pre-commit process"
@uv run pre-commit run --color=always --all-files
@echo "=> Pre-commit complete"
.PHONY: slotscheck
slotscheck: ## Run slotscheck
@echo "=> Running slotscheck"
@uv run slotscheck \
-m advanced_alchemy.config \
-m advanced_alchemy.repository \
-m advanced_alchemy.service \
-m advanced_alchemy.extensions \
-m advanced_alchemy.base \
-m advanced_alchemy.types \
-m advanced_alchemy.operations
@echo "=> slotscheck complete"
.PHONY: fix
fix: ## Run formatting scripts
@uv run ruff check --fix --unsafe-fixes
.PHONY: lint
lint: pre-commit type-check slotscheck ## Run all linting
.PHONY: coverage
coverage: ## Run the tests and generate coverage report
@echo "=> Running tests with coverage"
@uv run pytest tests --cov -n auto
@uv run coverage html
@uv run coverage xml
@echo "=> Coverage report generated"
.PHONY: test
test: ## Run the tests
@echo "=> Running test cases"
@uv run pytest tests -m 'not asyncmy and not asyncpg and not psycopg_async and not psycopg_sync and not oracledb_async and not oracledb_sync and not spanner and not mssql_async and not mssql_sync and not cockroachdb_async and not cockroachdb_sync' -n 2
@echo "=> Tests complete"
.PHONY: test-all
test-all: ## Run all tests
@echo "=> Running test cases"
@uv run pytest tests -m '' -n 2
@echo "=> Tests complete"
.PHONY: check-all
check-all: lint test-all coverage ## Run all linting, tests, and coverage checks
# =============================================================================
# Docs
# =============================================================================
docs-clean: ## Dump the existing built docs
@echo "=> Cleaning documentation build assets"
@rm -rf docs/_build
@echo "=> Removed existing documentation build assets"
docs-serve: docs-clean ## Serve the docs locally
@echo "=> Serving documentation"
uv run sphinx-autobuild docs docs/_build/ -j auto --watch advanced_alchemy --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002
docs: docs-clean ## Dump the existing built docs and rebuild them
@echo "=> Building documentation"
@uv run sphinx-build -M html docs docs/_build/ -E -a -j auto -W --keep-going
.PHONY: docs-linkcheck
docs-linkcheck: ## Run the link check on the docs
@uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_ignore='http://.*','https://.*'
.PHONY: docs-linkcheck-full
docs-linkcheck-full: ## Run the full link check on the docs
@uv run sphinx-build -b linkcheck ./docs ./docs/_build -D linkcheck_anchors=0