Melika Kheirieh commited on
Commit
3dcdaae
·
1 Parent(s): d85610e

chore(dev): add pre-commit hooks and integrate with Makefile

Browse files
Files changed (2) hide show
  1. .pre-commit-config.yaml +35 -0
  2. Makefile +5 -0
.pre-commit-config.yaml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ # --- Basic hygiene checks ---
3
+ - repo: https://github.com/pre-commit/pre-commit-hooks
4
+ rev: v4.6.0
5
+ hooks:
6
+ - id: check-merge-conflict
7
+ - id: end-of-file-fixer
8
+ - id: trailing-whitespace
9
+
10
+ # --- Ruff: linting and formatting ---
11
+ - repo: https://github.com/astral-sh/ruff-pre-commit
12
+ rev: v0.7.1
13
+ hooks:
14
+ - id: ruff
15
+ args: [--fix, --exit-non-zero-on-fix]
16
+ - id: ruff-format
17
+
18
+ # --- Mypy: type-checking on staged Python files ---
19
+ - repo: https://github.com/pre-commit/mirrors-mypy
20
+ rev: v1.11.2
21
+ hooks:
22
+ - id: mypy
23
+ args:
24
+ - --ignore-missing-imports
25
+ - --explicit-package-bases
26
+
27
+ # --- Run pytest via Makefile when pushing ---
28
+ - repo: local
29
+ hooks:
30
+ - id: pytest-on-push
31
+ name: pytest (pre-push)
32
+ entry: make test
33
+ language: system
34
+ pass_filenames: false
35
+ stages: [push]
Makefile CHANGED
@@ -60,6 +60,11 @@ test: ## Run pytest quietly
60
  cov: ## Run tests with coverage
61
  PYTHONPATH=$$PWD $(PYTEST) --cov=nl2sql --cov-report=term-missing
62
 
 
 
 
 
 
63
  # ---------- Run ----------
64
  .PHONY: run
65
  run: ## Run FastAPI app (reload mode)
 
60
  cov: ## Run tests with coverage
61
  PYTHONPATH=$$PWD $(PYTEST) --cov=nl2sql --cov-report=term-missing
62
 
63
+ # ---------- Pre-commit ----------
64
+ .PHONY: precommit
65
+ precommit: ## Run all pre-commit hooks on all files
66
+ pre-commit run --all-files
67
+
68
  # ---------- Run ----------
69
  .PHONY: run
70
  run: ## Run FastAPI app (reload mode)