Melika Kheirieh commited on
Commit
e1aca60
·
1 Parent(s): 1af43ae

chore(make): add project Makefile (lint/test/run/bench/docker)

Browse files
Files changed (1) hide show
  1. Makefile +80 -0
Makefile ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Usage: `make <target>` (e.g., `make test`)
2
+ # Lines with `##` appear in `make help`.
3
+
4
+ # ---------- Config ----------
5
+ PY ?= python3
6
+ PIP ?= pip
7
+ UVICORN ?= uvicorn
8
+ PACKAGE_DIRS= nl2sql adapters app benchmarks
9
+ TESTS = tests
10
+ DOCKER_IMG = nl2sql-copilot
11
+ PORT ?= 8000
12
+
13
+ .DEFAULT_GOAL := help
14
+
15
+ # ---------- Meta ----------
16
+ .PHONY: help
17
+ help: ## Show this help
18
+ @awk 'BEGIN {FS := ":.*##"; printf "\n\033[1mAvailable targets:\033[0m\n"} /^[a-zA-Z0-9_.-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 } /^.PHONY:/ {gsub(/.PHONY: /, "", $$0)}' $(MAKEFILE_LIST)
19
+
20
+ # ---------- Dev basics ----------
21
+ .PHONY: install
22
+ install: ## Install runtime dependencies
23
+ $(PIP) install -r requirements.txt
24
+
25
+ .PHONY: dev-install
26
+ dev-install: ## Install dev tools (ruff, mypy, pytest, coverage, uvicorn, etc.)
27
+ $(PIP) install -U pip wheel
28
+ $(PIP) install ruff mypy pytest pytest-cov uvicorn
29
+
30
+ # ---------- Quality ----------
31
+ .PHONY: format
32
+ format: ## Auto-format & quick-fix with ruff
33
+ ruff format .
34
+ ruff check . --fix
35
+
36
+ .PHONY: lint
37
+ lint: ## Lint only (no auto-fix)
38
+ ruff check .
39
+ mypy .
40
+
41
+ .PHONY: typecheck
42
+ typecheck: ## mypy type checking
43
+ mypy .
44
+
45
+ # ---------- Tests ----------
46
+ .PHONY: test
47
+ test: ## Run unit tests (quiet)
48
+ PYTHONPATH=$$PWD pytest -q
49
+
50
+ .PHONY: cov
51
+ cov: ## Run tests with coverage (package-only)
52
+ PYTHONPATH=$$PWD pytest --cov=nl2sql --cov-report=term-missing
53
+
54
+ # ---------- App run ----------
55
+ .PHONY: run
56
+ run: ## Run FastAPI (dev, reload)
57
+ $(UVICORN) app.main:app --reload --host 0.0.0.0 --port $(PORT)
58
+
59
+ # ---------- Benchmarks ----------
60
+ .PHONY: bench
61
+ bench: ## Run minimal benchmark script (no API keys needed with DummyLLM fallbacks)
62
+ $(PY) -m benchmarks.run
63
+
64
+ # ---------- Docker ----------
65
+ .PHONY: docker-build
66
+ docker-build: ## Build Docker image
67
+ docker build -t $(DOCKER_IMG) .
68
+
69
+ .PHONY: docker-run
70
+ docker-run: ## Run Docker container on port $(PORT)
71
+ docker run --rm -p $(PORT):8000 $(DOCKER_IMG)
72
+
73
+ # ---------- Clean ----------
74
+ .PHONY: clean
75
+ clean: ## Remove Python caches
76
+ rm -rf __pycache__ .pytest_cache .mypy_cache
77
+
78
+ .PHONY: clean-all
79
+ clean-all: clean ## Remove build artifacts & coverage files
80
+ rm -rf dist build .coverage *.egg-info