| name: Validate data catalog |
|
|
| on: |
| pull_request: |
| push: |
| branches: [main] |
|
|
| permissions: |
| contents: read |
|
|
| jobs: |
| validate: |
| runs-on: ubuntu-latest |
| timeout-minutes: 10 |
| steps: |
| - uses: actions/checkout@v4 |
| - uses: actions/setup-python@v5 |
| with: |
| python-version: "3.13" |
| - name: Validate structured catalog |
| run: | |
| python - <<'PY' |
| import hashlib |
| import json |
| from pathlib import Path |
| |
| root = Path("structured") |
| catalog = json.loads((root / "catalog-v1.json").read_text()) |
| for entry in catalog["datasets"]: |
| path = root / "v1" / entry["filename"] |
| digest = hashlib.sha256(path.read_bytes()).hexdigest() |
| if digest != entry["sha256"]: |
| raise SystemExit(f"{path}: checksum mismatch") |
| if path.stat().st_size != entry["bytes"]: |
| raise SystemExit(f"{path}: size mismatch") |
| print(f"Validated {len(catalog['datasets'])} catalog entries") |
| PY |
| - name: Check archive integrity |
| run: | |
| python - <<'PY' |
| from pathlib import Path |
| from zipfile import BadZipFile, ZipFile |
| |
| archives = sorted(Path(".").glob("**/*.zip")) |
| for archive in archives: |
| try: |
| with ZipFile(archive) as source: |
| bad = source.testzip() |
| except BadZipFile as error: |
| raise SystemExit(f"{archive}: {error}") from error |
| if bad: |
| raise SystemExit(f"{archive}: corrupt member {bad}") |
| print(f"Validated {len(archives)} ZIP archives") |
| PY |
|
|