Skip to content

Commit 577eeb4

Browse files
committed
Replay onboarding example validator on current main
1 parent 84cd40d commit 577eeb4

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
"""Validate SourceOS/SociOS onboarding control-plane schema/example pairs."""
3+
from __future__ import annotations
4+
5+
import json
6+
from pathlib import Path
7+
8+
import jsonschema
9+
10+
ROOT = Path(__file__).resolve().parents[1]
11+
PAIRS = [
12+
(ROOT / "schemas" / "WorkspaceScope.json", ROOT / "examples" / "workspacescope.json"),
13+
(ROOT / "schemas" / "TrustMode.json", ROOT / "examples" / "trustmode.read_only_analyst.json"),
14+
(ROOT / "schemas" / "CapabilityPack.json", ROOT / "examples" / "capabilitypack.repo_release_prep.json"),
15+
(ROOT / "schemas" / "ConnectorActionScope.json", ROOT / "examples" / "connectoractionscope.github_read_only.json"),
16+
(ROOT / "schemas" / "AutomationTemplate.json", ROOT / "examples" / "automationtemplate.yesterday_git_activity.json"),
17+
(ROOT / "schemas" / "OnboardingReceipt.json", ROOT / "examples" / "onboardingreceipt.first_run_read_only.json"),
18+
]
19+
20+
21+
def validate_pair(schema_path: Path, example_path: Path) -> None:
22+
schema = json.loads(schema_path.read_text(encoding="utf-8"))
23+
jsonschema.validators.validator_for(schema).check_schema(schema)
24+
example = json.loads(example_path.read_text(encoding="utf-8"))
25+
jsonschema.validate(example, schema)
26+
27+
28+
def main() -> int:
29+
checks: dict[str, bool] = {}
30+
for schema_path, example_path in PAIRS:
31+
validate_pair(schema_path, example_path)
32+
checks[example_path.name] = True
33+
print(json.dumps({"ok": all(checks.values()), "checks": checks}, indent=2, sort_keys=True))
34+
return 0
35+
36+
37+
if __name__ == "__main__":
38+
raise SystemExit(main())

0 commit comments

Comments
 (0)