Spaces:
Sleeping
Sleeping
| # ---------- Config ---------- | |
| VENV_DIR ?= .venv | |
| PY ?= $(if $(wildcard $(VENV_DIR)/bin/python),$(VENV_DIR)/bin/python,python3) | |
| PIP ?= $(if $(wildcard $(VENV_DIR)/bin/pip),$(VENV_DIR)/bin/pip,pip) | |
| UVICORN ?= $(if $(wildcard $(VENV_DIR)/bin/uvicorn),$(VENV_DIR)/bin/uvicorn,uvicorn) | |
| RUFF ?= $(if $(wildcard $(VENV_DIR)/bin/ruff),$(VENV_DIR)/bin/ruff,ruff) | |
| MYPY ?= $(if $(wildcard $(VENV_DIR)/bin/mypy),$(VENV_DIR)/bin/mypy,mypy) | |
| PYTEST ?= $(if $(wildcard $(VENV_DIR)/bin/pytest),$(VENV_DIR)/bin/pytest,pytest) | |
| DOCKER_IMG ?= nl2sql-copilot | |
| PORT ?= 8000 | |
| .DEFAULT_GOAL := help | |
| # ---------- Meta ---------- | |
| help: ## Show this help | |
| @printf "\n\033[1mAvailable targets:\033[0m\n" | |
| @awk 'BEGIN {FS = ":.*##"} /^[[:alnum:]_.-]+:.*##/ {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
| # ---------- Setup ---------- | |
| venv: ## Create virtual environment in .venv/ | |
| python3 -m venv $(VENV_DIR) | |
| $(PIP) install --upgrade pip wheel | |
| install: ## Install runtime dependencies inside venv | |
| $(PIP) install -r requirements.txt | |
| dev-install: ## Install dev tools (ruff, mypy, pytest, coverage, uvicorn, etc.) | |
| $(PIP) install -U pip wheel | |
| $(PIP) install ruff mypy pytest pytest-cov uvicorn pre-commit | |
| bootstrap: venv dev-install ## Create venv and install dev tools | |
| # ---------- Quality (read-only for CI) ---------- | |
| fmt-check: ## Verify formatting without modifying files | |
| $(RUFF) format . --check | |
| lint: ## Run linting | |
| $(RUFF) check . | |
| typecheck: ## Run type checking only | |
| $(MYPY) . --ignore-missing-imports --explicit-package-bases | |
| # ---------- Quality (write mode for local dev) ---------- | |
| format: ## Auto-format & fix with ruff | |
| $(RUFF) format . | |
| $(RUFF) check . --fix | |
| # ---------- Tests ---------- | |
| test: ## Run fast test suite (exclude slow) | |
| PYTHONPATH=$$PWD $(PYTEST) -q -m "not slow" | |
| test-all: ## Run full test suite including slow tests | |
| PYTHONPATH=$$PWD $(PYTEST) -q | |
| cov: ## Run tests with coverage | |
| PYTHONPATH=$$PWD $(PYTEST) --cov=nl2sql --cov-report=term-missing | |
| # ---------- Unified gate for CI ---------- | |
| check: ## Run format check, lint, typecheck, and fast tests | |
| make fmt-check | |
| make lint | |
| make typecheck | |
| make test | |
| # ---------- Pre-commit ---------- | |
| precommit: ## Run all pre-commit hooks on all files | |
| pre-commit run --all-files | |
| # ---------- Run ---------- | |
| run: ## Run FastAPI app (reload mode) | |
| $(UVICORN) app.main:app --reload --host 0.0.0.0 --port $(PORT) | |
| # ---------- Benchmarks ---------- | |
| bench: ## Run benchmark suite (DummyLLM fallback) | |
| $(PY) -m benchmarks.run | |
| # ---------- Docker ---------- | |
| docker-build: ## Build Docker image | |
| docker build -t $(DOCKER_IMG) . | |
| docker-run: ## Run Docker container on port $(PORT) | |
| docker run --rm -p $(PORT):8000 $(DOCKER_IMG) | |
| # ---------- Clean ---------- | |
| clean: ## Remove Python caches | |
| rm -rf __pycache__ .pytest_cache .mypy_cache .ruff_cache | |
| clean-all: clean ## Remove build artifacts and coverage | |
| rm -rf dist build .coverage *.egg-info | |