Packaging, rtut check, tests CI job; schemas move into the package (RBT-WP-0009-T02)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: sonnet
Assistant-Process: 295952@bnt-lap001
Assistant-Session: e93f64ad-516c-46eb-9666-aad8d300c477
This commit is contained in:
tegwick 2026-09-29 21:32:19 +02:00
parent 6d3414d8b7
commit e021fd979f
16 changed files with 163 additions and 10 deletions

View file

@ -59,6 +59,45 @@ def _run(pk, a) -> int:
return 1
def _check(root: str) -> int:
"""One command for CI and for humans: everything declarative in a repository must validate."""
from . import project as J
from .attrs import Registry
reg = Registry([Path(root)])
bad = 0
print("runbooks")
for p in reg.packs.values():
print(f" {'ok ' if p.ok else 'FAIL'} {p.id}")
for err in p.errors:
print(f" - {err}")
bad += not p.ok
print("attribute sets")
for sid, d in reg.sets.items():
print(f" {'ok ' if d.ok else 'FAIL'} {sid}")
for err in d.errors:
print(f" - {err}")
bad += not d.ok
print("projects")
for pid, d in reg.projects.items():
errs = J.validate(reg, d)
print(f" {'ok ' if not errs else 'FAIL'} {pid}")
for err in errs:
print(f" - {err}")
bad += bool(errs)
print("templates")
for tid, d in reg.templates.items():
print(f" {'ok ' if d.ok else 'FAIL'} {tid}")
for err in d.errors:
print(f" - {err}")
bad += not d.ok
total = len(reg.packs) + len(reg.sets) + len(reg.projects) + len(reg.templates)
if not total:
print("nothing to check", file=sys.stderr)
return 1
print(f"{total - bad} of {total} ok")
return 1 if bad else 0
def _project(a) -> int:
from . import project as J
from .attrs import Registry
@ -135,6 +174,8 @@ def main(argv: list[str] | None = None) -> int:
sp = sub.add_parser("ui", help="serve the local UI on 127.0.0.1")
sp.add_argument("roots", nargs="*", default=["."])
sp.add_argument("--port", type=int, default=8877)
sp = sub.add_parser("check", help="validate every pack, attribute set, project and template under a repository")
sp.add_argument("root", nargs="?", default=".")
sp = sub.add_parser("maturity", help="derived maturity of a pack at its current revision")
sp.add_argument("manifest")
sp = sub.add_parser("review", help="record that you reviewed the pack at its current revision")
@ -172,6 +213,8 @@ def main(argv: list[str] | None = None) -> int:
except KeyboardInterrupt:
pass
return 0
if a.cmd == "check":
return _check(a.root)
if a.cmd == "project":
return _project(a)
if a.cmd in ("maturity", "review"):
@ -257,5 +300,10 @@ def main(argv: list[str] | None = None) -> int:
return 0
def cli() -> None:
"""Console-script entry point (`rtut`)."""
sys.exit(main())
if __name__ == "__main__":
sys.exit(main())