Files
claude-scripts/Makefile

102 lines
3.6 KiB
Makefile

.PHONY: help install install-dev test test-cov lint format typecheck clean build publish precommit analyze release-private
SHELL := /bin/bash
VENV := .venv
PYTHON := $(VENV)/bin/python
UV := uv
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
install: ## Install production dependencies
@echo "Activating virtual environment and installing production dependencies..."
@source $(VENV)/bin/activate && $(UV) pip install -e .
install-dev: ## Install development dependencies
@echo "Activating virtual environment and installing all dependencies..."
@source $(VENV)/bin/activate && $(UV) pip install -e ".[dev]"
@echo "Installing pre-commit hooks..."
@source $(VENV)/bin/activate && pre-commit install
test: ## Run tests
@echo "Running tests..."
@source $(VENV)/bin/activate && pytest
test-cov: ## Run tests with coverage
@echo "Running tests with coverage..."
@source $(VENV)/bin/activate && pytest --cov=quality --cov-report=term-missing
lint: ## Run linting checks
@echo "Running ruff linting..."
@source $(VENV)/bin/activate && ruff check src/
@echo "Running ruff format check..."
@source $(VENV)/bin/activate && ruff format --check src/
format: ## Format code
@echo "Formatting code with ruff..."
@source $(VENV)/bin/activate && ruff check --fix src/
@source $(VENV)/bin/activate && ruff format src/
typecheck: ## Run type checking
@echo "Running mypy type checking..."
@source $(VENV)/bin/activate && mypy src/
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
@rm -rf dist/ build/ *.egg-info
@rm -rf .pytest_cache .mypy_cache .ruff_cache
@rm -rf htmlcov/ .coverage coverage.xml
@find . -type d -name __pycache__ -exec rm -rf {} +
@find . -type f -name "*.pyc" -delete
build: ## Build distribution packages
@echo "Building distribution packages..."
@source $(VENV)/bin/activate && python -m build
publish: ## Publish to PyPI
@echo "Publishing to PyPI..."
@source $(VENV)/bin/activate && python -m twine upload dist/*
precommit: ## Run pre-commit on all files
@echo "Running pre-commit on all files..."
@source $(VENV)/bin/activate && pre-commit run --all-files
analyze: ## Run full code quality analysis
@echo "Running full code quality analysis..."
@source $(VENV)/bin/activate && claude-quality full-analysis src/ --format console
release-private: ## VERSION=1.2.3 -> bump pyproject version, build, upload to private PyPI
ifndef VERSION
$(error VERSION is required, e.g., make release-private VERSION=1.2.3)
endif
@echo "Bumping version to $(VERSION) in pyproject.toml..."
@python - <<'PY'
from pathlib import Path
import tomllib
import tomli_w
pyproject_path = Path("pyproject.toml")
data = tomllib.loads(pyproject_path.read_text())
data["project"]["version"] = "$(VERSION)"
pyproject_path.write_text(tomli_w.dumps(data), encoding="utf-8")
print(f"pyproject.toml version set to {data['project']['version']}")
PY
@echo "Building distribution packages..."
@source $(VENV)/bin/activate && python -m build
@echo "Uploading to private PyPI (gitea)..."
@source $(VENV)/bin/activate && python -m twine upload -r gitea dist/*
venv: ## Create virtual environment
@echo "Creating virtual environment..."
@python3.12 -m venv $(VENV)
@echo "Virtual environment created at $(VENV)"
update-deps: ## Update all dependencies
@echo "Updating dependencies..."
@source $(VENV)/bin/activate && $(UV) pip install --upgrade -e ".[dev]"
check-all: lint typecheck test ## Run all checks (lint, typecheck, test)