-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.py
More file actions
62 lines (40 loc) · 1.63 KB
/
Copy pathdev.py
File metadata and controls
62 lines (40 loc) · 1.63 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
61
62
#!/usr/bin/env python3
"""Local dev runner for agsess — stdlib Python driving cargo, no task runner.
The same `python dev.py check` gate as every nativelite package, so the muscle
memory is identical across languages. Here `check` is the zero-dependency guard
plus `cargo fmt --check` and `cargo test` (unit + integration + doctests):
python dev.py check # guard + cargo fmt --check + cargo test
python dev.py test # cargo test
python dev.py build # cargo build --release
python dev.py fmt # cargo fmt --check
python dev.py guard # zero-dependency guard
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
PY = sys.executable
def run(*args: str) -> int:
print(f"$ {' '.join(args)}")
return subprocess.call(args, cwd=str(ROOT))
def test() -> int:
return run("cargo", "test", "--all-targets") or run("cargo", "test", "--doc")
def build() -> int:
return run("cargo", "build", "--release")
def fmt() -> int:
return run("cargo", "fmt", "--check")
def guard() -> int:
return run(PY, "tools/dep_guard.py")
def check() -> int:
return guard() or fmt() or test()
COMMANDS = {"test": test, "build": build, "fmt": fmt, "guard": guard, "check": check}
def main(argv: list[str]) -> int:
cmd = argv[1] if len(argv) > 1 else "check"
fn = COMMANDS.get(cmd)
if fn is None:
print(f"unknown command {cmd!r}; choose from: {', '.join(COMMANDS)}")
return 2
return fn()
if __name__ == "__main__":
raise SystemExit(main(sys.argv))