Spaces:
Sleeping
Sleeping
File size: 1,067 Bytes
fe0c99f de8ccff fe0c99f de8ccff fe0c99f | 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 | #!/usr/bin/env python3
"""Run lint, typing, tests, and optional security checks in one command."""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def _venv_python() -> Path:
if sys.platform.startswith("win"):
return ROOT / ".venv" / "Scripts" / "python.exe"
return ROOT / ".venv" / "bin" / "python"
def _run(cmd: list[str]) -> int:
return subprocess.call(cmd, cwd=str(ROOT))
def main() -> int:
include_security = "--security" in sys.argv
py = _venv_python()
interpreter = str(py if py.exists() else Path(sys.executable))
steps = [
[interpreter, "-m", "ruff", "check", "."],
[interpreter, "-m", "mypy", "api", "core"],
[interpreter, "scripts/run_tests.py"],
]
if include_security:
steps.append([interpreter, "-m", "pip_audit"])
for cmd in steps:
code = _run(cmd)
if code != 0:
return code
return 0
if __name__ == "__main__":
raise SystemExit(main())
|