| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
.PHONY: install |
| 6 |
install: |
| 7 |
@echo "🚀 Creating uv Python virtual environment" |
| 8 |
@uv python install 3.14 |
| 9 |
@uv sync --python=3.14 |
| 10 |
@echo "🚀 Installing Git prek hooks locally" |
| 11 |
@uv run prek install -f |
| 12 |
@echo "🚀 Installing Prettier using npm" |
| 13 |
@npm install -q --no-fund --include=dev |
| 14 |
|
| 15 |
.PHONY: check |
| 16 |
check: |
| 17 |
@echo "🚀 Checking lock file consistency with 'pyproject.toml'" |
| 18 |
@uv lock --locked |
| 19 |
@echo "🚀 Auto-formatting/Linting code and documentation: Running prek" |
| 20 |
@uv run prek run -a |
| 21 |
@echo "🚀 Static type checking: Running mypy" |
| 22 |
@uv run mypy |
| 23 |
|
| 24 |
.PHONY: format |
| 25 |
format: |
| 26 |
@uv run ruff format |
| 27 |
|
| 28 |
.PHONY: lint |
| 29 |
lint: |
| 30 |
@uv run ruff check --fix |
| 31 |
|
| 32 |
.PHONY: typecheck |
| 33 |
typecheck: |
| 34 |
@uv run mypy |
| 35 |
|
| 36 |
.PHONY: test |
| 37 |
test: |
| 38 |
@echo "🚀 Testing code: Running pytest" |
| 39 |
@uv run python -Xutf8 -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests |
| 40 |
|
| 41 |
.PHONY: docs-test |
| 42 |
docs-test: |
| 43 |
@uv run zensical build -s |
| 44 |
|
| 45 |
.PHONY: docs |
| 46 |
docs: |
| 47 |
@uv run zensical serve -o |
| 48 |
|
| 49 |
.PHONY: build |
| 50 |
build: clean-build |
| 51 |
@echo "🚀 Creating wheel file" |
| 52 |
@uv build |
| 53 |
|
| 54 |
.PHONY: tag |
| 55 |
tag: |
| 56 |
@echo "🚀 Creating git tag: ${TAG}" |
| 57 |
@git tag -a ${TAG} -m "" |
| 58 |
@echo "🚀 Pushing tag to origin: ${TAG}" |
| 59 |
@git push origin ${TAG} |
| 60 |
|
| 61 |
.PHONY: validate-tag |
| 62 |
validate-tag: |
| 63 |
@echo "🚀 Validating version tag" |
| 64 |
@uv run scripts/validate_tag.py |
| 65 |
|
| 66 |
.PHONY: publish-test |
| 67 |
publish-test: validate-tag build |
| 68 |
@echo "🚀 Publishing: Dry run." |
| 69 |
@uv run uv-publish --repository testpypi |
| 70 |
|
| 71 |
.PHONY: publish |
| 72 |
publish: validate-tag build |
| 73 |
@echo "🚀 Publishing." |
| 74 |
@uv run uv-publish |
| 75 |
|
| 76 |
|
| 77 |
BUILD_DIRS = build dist *.egg-info |
| 78 |
DOC_DIRS = build |
| 79 |
MYPY_DIRS = .mypy_cache dmypy.json dmypy.sock |
| 80 |
TEST_DIRS = .cache .pytest_cache htmlcov |
| 81 |
TEST_FILES = .coverage coverage.xml |
| 82 |
|
| 83 |
.PHONY: clean-build |
| 84 |
clean-build: |
| 85 |
@echo "🚀 Removing build artifacts" |
| 86 |
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(BUILD_DIRS)'.split() if os.path.isdir(d)]" |
| 87 |
|
| 88 |
.PHONY: clean-docs |
| 89 |
clean-docs: |
| 90 |
@echo "🚀 Removing documentation artifacts" |
| 91 |
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(DOC_DIRS)'.split() if os.path.isdir(d)]" |
| 92 |
|
| 93 |
.PHONY: clean-mypy |
| 94 |
clean-mypy: |
| 95 |
@echo "🚀 Removing mypy artifacts" |
| 96 |
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(MYPY_DIRS)'.split() if os.path.isdir(d)]" |
| 97 |
|
| 98 |
.PHONY: clean-pycache |
| 99 |
clean-pycache: |
| 100 |
@echo "🚀 Removing pycache artifacts" |
| 101 |
@-find . -type d -name "__pycache__" -exec rm -r {} + |
| 102 |
|
| 103 |
.PHONY: clean-ruff |
| 104 |
clean-ruff: |
| 105 |
@echo "🚀 Removing ruff artifacts" |
| 106 |
@uv run ruff clean |
| 107 |
|
| 108 |
.PHONY: clean-test |
| 109 |
clean-test: |
| 110 |
@echo "🚀 Removing test artifacts" |
| 111 |
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(TEST_DIRS)'.split() if os.path.isdir(d)]" |
| 112 |
@uv run python -c "from pathlib import Path; [Path(f).unlink(missing_ok=True) for f in '$(TEST_FILES)'.split()]" |
| 113 |
|
| 114 |
.PHONY: clean |
| 115 |
clean: clean-build clean-docs clean-mypy clean-pycache clean-ruff clean-test |
| 116 |
@echo "🚀 Cleaned all artifacts" |
| 117 |
|
| 118 |
.PHONY: help |
| 119 |
help: |
| 120 |
@uv run python -c "import re; \ |
| 121 |
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]" |
| 122 |
|
| 123 |
.DEFAULT_GOAL := help |