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

chore(make): refine Makefile targets for ruff/mypy/pytest/docker

Browse files
Files changed (1) hide show
  1. Makefile +31 -28
Makefile CHANGED
@@ -1,25 +1,28 @@
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
@@ -29,36 +32,36 @@ dev-install: ## Install dev tools (ruff, mypy, pytest, coverage, uvicorn, etc.)
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 ----------
@@ -76,5 +79,5 @@ 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
 
 
 
1
 
2
  # ---------- Config ----------
3
+ VENV_DIR ?= .venv
4
+ PY ?= $(if $(wildcard $(VENV_DIR)/bin/python),$(VENV_DIR)/bin/python,python3)
5
+ PIP ?= $(if $(wildcard $(VENV_DIR)/bin/pip),$(VENV_DIR)/bin/pip,pip)
6
+ UVICORN ?= $(if $(wildcard $(VENV_DIR)/bin/uvicorn),$(VENV_DIR)/bin/uvicorn,uvicorn)
7
+ DOCKER_IMG ?= nl2sql-copilot
8
+ PORT ?= 8000
 
9
 
10
  .DEFAULT_GOAL := help
11
 
12
  # ---------- Meta ----------
13
  .PHONY: help
14
  help: ## Show this help
15
+ @printf "\n\033[1mAvailable targets:\033[0m\n"
16
+ @awk 'BEGIN {FS = ":.*##"} /^[[:alnum:]_.-]+:.*##/ {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
17
+
18
+ # ---------- Setup ----------
19
+ .PHONY: venv
20
+ venv: ## Create virtual environment in .venv/
21
+ python3 -m venv $(VENV_DIR)
22
+ $(PIP) install --upgrade pip wheel
23
 
 
24
  .PHONY: install
25
+ install: ## Install runtime dependencies inside venv
26
  $(PIP) install -r requirements.txt
27
 
28
  .PHONY: dev-install
 
32
 
33
  # ---------- Quality ----------
34
  .PHONY: format
35
+ format: ## Auto-format & fix with ruff
36
+ $(VENV_DIR)/bin/ruff format .
37
+ $(VENV_DIR)/bin/ruff check . --fix
38
 
39
  .PHONY: lint
40
+ lint: ## Run linting and type checking
41
+ $(VENV_DIR)/bin/ruff check .
42
+ $(VENV_DIR)/bin/mypy .
43
 
44
  .PHONY: typecheck
45
+ typecheck: ## Run type checking only
46
+ $(VENV_DIR)/bin/mypy .
47
 
48
  # ---------- Tests ----------
49
  .PHONY: test
50
+ test: ## Run pytest quietly
51
+ PYTHONPATH=$$PWD $(VENV_DIR)/bin/pytest -q
52
 
53
  .PHONY: cov
54
+ cov: ## Run tests with coverage
55
+ PYTHONPATH=$$PWD $(VENV_DIR)/bin/pytest --cov=nl2sql --cov-report=term-missing
56
 
57
+ # ---------- Run ----------
58
  .PHONY: run
59
+ run: ## Run FastAPI app (reload mode)
60
  $(UVICORN) app.main:app --reload --host 0.0.0.0 --port $(PORT)
61
 
62
  # ---------- Benchmarks ----------
63
  .PHONY: bench
64
+ bench: ## Run benchmark suite (DummyLLM fallback)
65
  $(PY) -m benchmarks.run
66
 
67
  # ---------- Docker ----------
 
79
  rm -rf __pycache__ .pytest_cache .mypy_cache
80
 
81
  .PHONY: clean-all
82
+ clean-all: clean ## Remove build artifacts and coverage
83
  rm -rf dist build .coverage *.egg-info