Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions tools/check-repo-meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Phase 0 manifest drift gate for dist/repo.meta.json.
"""Per-repo manifest drift gate for dist/repo.meta.json.

Validates that:
1. The given manifest file parses as JSON and conforms to its
Expand All @@ -9,10 +9,11 @@

Exits 0 on success; non-zero with structured stderr output on failure.

This is the per-repo local mirror of `.github/profile/build/validate-repo-meta.py`
(Track A / Phase 0 plan §2). Once the org-level validator is published,
this script may delegate to it via URL; for now it carries an inline
copy so the gate is self-contained.
Self-contained mirror of the canonical validator at
`.github/profile/build/validate-repo-meta.py`. Self-containment keeps
`make check-manifest` runnable without an extra checkout or network
detour while CI / smoke tests run the canonical script against the
published manifests.
"""

from __future__ import annotations
Expand All @@ -30,15 +31,17 @@


def _load_schema(schema_uri: str, repo_root: Path) -> dict:
"""Load the schema from URL or, if the canonical URL is unreachable,
fall back to a sibling .github checkout under the org parent dir."""
"""Load the schema from `schema_uri`. If the network is unavailable,
fall back to a sibling `.github` checkout under the same parent dir
(the canonical layout for a dev box with multiple m-dev-tools repos
checked out side by side)."""
try:
with urllib.request.urlopen(schema_uri, timeout=5) as resp:
return json.load(resp)
except Exception as e: # noqa: BLE001
sys.stderr.write(
f"NOTE: could not fetch schema from {schema_uri} ({e}); "
"trying local fallback at ../.github/profile/repo.meta.schema.json\n"
"falling back to sibling .github checkout\n"
)
fallback = repo_root.parent / ".github" / "profile" / "repo.meta.schema.json"
if not fallback.exists():
Expand Down
Loading