-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvalidate_collector_scaffold.py
More file actions
73 lines (61 loc) · 1.82 KB
/
validate_collector_scaffold.py
File metadata and controls
73 lines (61 loc) · 1.82 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
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
"""
Create a throwaway collector app under .test_artifacts/ and verify ruff + pyright pass.
Run from repo root: python scripts/validate_collector_scaffold.py
CI: invoked after dependencies are installed (see .github/workflows/actions.yml).
"""
from __future__ import annotations
import json
import shutil
import subprocess
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
# Must not collide with any INSTALLED_APPS name.
APP_LABEL = "zzcollectorscaffoldci"
SCRATCH_PARENT = REPO_ROOT / ".test_artifacts" / "collector_scaffold_probe"
def main() -> int:
SCRATCH_PARENT.mkdir(parents=True, exist_ok=True)
app_dir = SCRATCH_PARENT / APP_LABEL
if app_dir.exists():
shutil.rmtree(app_dir)
subprocess.run(
[
sys.executable,
str(REPO_ROOT / "manage.py"),
"startcollector",
APP_LABEL,
"--path",
str(SCRATCH_PARENT),
],
cwd=str(REPO_ROOT),
check=True,
)
subprocess.run(
["uv", "run", "--with", "ruff", "ruff", "check", str(app_dir)],
cwd=str(REPO_ROOT),
check=True,
)
cfg_path = SCRATCH_PARENT / "pyrightconfig.json"
cfg = {
"include": [APP_LABEL],
"exclude": [
"**/migrations/**",
"**/tests/**",
"**/._*",
"**/.___*",
],
"pythonVersion": "3.13",
"typeCheckingMode": "basic",
"reportMissingImports": True,
"extraPaths": ["../.."],
}
cfg_path.write_text(json.dumps(cfg, indent=2) + "\n", encoding="utf-8")
subprocess.run(
["uv", "run", "pyright", "--project", str(SCRATCH_PARENT)],
cwd=str(SCRATCH_PARENT),
check=True,
)
return 0
if __name__ == "__main__":
raise SystemExit(main())