-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontracts.py
More file actions
43 lines (37 loc) · 1.91 KB
/
Copy pathcontracts.py
File metadata and controls
43 lines (37 loc) · 1.91 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
#!/usr/bin/env python3
"""Run known offline contract checks when their owning component is present."""
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[2]
CHECKS = (
("hook", "plugins/crw/skills/crw-run/scripts/hook_probe.py",
"plugins/crw/skills/crw-run/references/hook-contract.md", ["replay"]),
("operations", "scripts/check_operations_contract.py",
"plugins/crw/skills/crw-run/references/operations.md", []),
# Re-derives the committed component identity from this checkout, so the one
# compatibility definition cannot drift away from the source it describes.
("runtime", "scripts/runtime_install.py",
"scripts/crw_runtime/components.json", ["verify-definition"]),
# The two closed-vocabulary start-policy fields are checked against the table that
# declares them, so the checker and the contract cannot drift apart unnoticed.
("start policy", "plugins/crw/skills/crw-run/scripts/start_policy.py",
"plugins/crw/skills/crw-run/references/start-policy.md", ["selftest"]),
# The parent title rule lives in the binding procedure, so the checker is paired with it
# rather than with the skill the script happens to sit under.
("parent title", "plugins/crw/skills/crw-run/scripts/parent_title.py",
"plugins/crw/skills/crw-plan/references/integrations.md", ["replay"]),
)
def main():
for name, script, contract, args in CHECKS:
present = [(ROOT / p).is_file() for p in (script, contract)]
if any(present) and not all(present):
print(f"Incomplete {name} contract/check pair", file=sys.stderr)
return 1
if not any(present):
print(f"{name}: component absent; no coverage claimed", flush=True)
continue
subprocess.run([sys.executable, str(ROOT / script), *args], cwd=ROOT, check=True)
return 0
if __name__ == "__main__":
raise SystemExit(main())