-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathdev.py
More file actions
60 lines (47 loc) · 1.7 KB
/
dev.py
File metadata and controls
60 lines (47 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
"""Development script for running tests, linting, and type checking."""
import subprocess
import sys
from pathlib import Path
def run_command(cmd: list[str], description: str) -> bool:
"""Run a command and return True if successful."""
print(f"\n🔍 {description}...")
try:
subprocess.run(cmd, check=True, cwd=Path(__file__).parent)
print(f"✅ {description} passed!")
return True
except subprocess.CalledProcessError as e:
print(f"❌ {description} failed with exit code {e.returncode}")
return False
def main() -> None:
"""Run development checks."""
if len(sys.argv) > 1:
command = sys.argv[1]
else:
command = "all"
success = True
if command in ("lint", "all"):
success &= run_command(["ruff", "check", "json2xml", "tests"], "Linting")
if command in ("test", "all"):
success &= run_command([
"pytest", "--cov=json2xml", "--cov-report=term",
"-xvs", "tests", "-n", "auto"
], "Tests")
if command in ("typecheck", "all"):
success &= run_command(["uvx", "ty", "check", "json2xml", "tests"], "Type checking")
if command == "help":
print("Usage: python dev.py [command]")
print("Commands:")
print(" all - Run all checks (default)")
print(" lint - Run linting only")
print(" test - Run tests only")
print(" typecheck - Run type checking only")
print(" help - Show this help")
return
if not success:
print("\n❌ Some checks failed!")
sys.exit(1)
else:
print("\n🎉 All checks passed!")
if __name__ == "__main__":
main()