.PHONY: help install dev lint format format-check typecheck test test-unit test-integration test-e2e check clean build coverage helm-lint helm-template

UV := uv

help: ## Show this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

install: ## Install the package
	$(UV) sync

dev: ## Install with dev dependencies
	$(UV) sync --extra dev

lint: ## Run ruff linter
	$(UV) run ruff check src/ tests/

format: ## Format code with ruff
	$(UV) run ruff format src/ tests/
	$(UV) run ruff check --fix src/ tests/

format-check: ## Check formatting without modifying files
	$(UV) run ruff format --check src/ tests/

typecheck: ## Run mypy type checker
	$(UV) run mypy src/

test: ## Run all tests
	$(UV) run pytest

test-unit: ## Run unit tests only
	$(UV) run pytest -m unit

test-integration: ## Run integration tests (may need network)
	$(UV) run pytest -m integration

test-e2e: ## Run e2e tests (requires LINODE_TOKEN)
	$(UV) run pytest -m e2e

check: lint format-check typecheck test-unit ## Run all checks (lint + format + typecheck + unit tests)

coverage: ## Run tests with coverage report
	$(UV) run pytest --cov=linode_llm --cov-report=term-missing --cov-report=html

clean: ## Remove build artifacts and caches
	rm -rf dist/ build/ *.egg-info .mypy_cache .ruff_cache .pytest_cache htmlcov .coverage
	find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true

build: ## Build the package
	$(UV) build

helm-lint: ## Lint the Helm chart
	helm lint src/linode_llm/helm/linode-llm

helm-template: ## Render Helm templates for review
	helm template test-release src/linode_llm/helm/linode-llm
