Files
libretro/scripts/check_buildbot_system.py
T
Abdessamad Derraz e1bad01b82 refactor: group scraper modules by subject
scraper/ held the platform scrapers next to three other subjects. The
launcher readers move to scraper/launchers/ (their _launchers suffix
dropped), the MAME and FBNeo hash scrapers and romset importers to
scraper/arcade/, the DAT readers and dump catalog importers to
scraper/dats/. The buildbot check is a freshness check and moves to
freshness/buildbot.py. Every -m command, workflow job, schema
description and page follows.

The scraper discovery in scraper/__init__.py had no caller: the
registry's scraper: field names the module, and the pages now say so.
2026-11-24 10:22:26 +01:00

82 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Check buildbot system directory for changes against local registry.
Compares the live buildbot assets/system/.index against _data_dirs.yml
entries using HTTP ETag headers for change detection.
Usage:
python scripts/check_buildbot_system.py
python scripts/check_buildbot_system.py --update
python scripts/check_buildbot_system.py --json
"""
from __future__ import annotations
import argparse
import json
import logging
import os
import sys
from core.cli import InputMissing
from core.paths import DATA_DIRS_FILE
from model.registry import data_dir_registry_at
from packs.datadirs import refresh_keys
from freshness.buildbot import check, pending, print_report, unanswered, updated
def main() -> None:
logging.basicConfig(level=logging.INFO, format="%(message)s")
parser = argparse.ArgumentParser(
allow_abbrev=False,
description="Check buildbot system directory for changes",
)
parser.add_argument(
"--update", action="store_true", help="Auto-refresh changed entries"
)
parser.add_argument(
"--json",
action="store_true",
dest="json_output",
help="Machine-readable JSON output",
)
parser.add_argument(
"--registry", default=DATA_DIRS_FILE,
help="the data directory registry to check (default: %(default)s)",
)
args = parser.parse_args()
# Read after the buildbot answered, a mistyped path ended on a trace.
if not os.path.isfile(args.registry):
raise InputMissing(f"Registry not found: {args.registry}")
report = check(args.registry)
if args.json_output:
print(json.dumps(report, indent=2))
else:
print_report(report)
if args.update:
# The registry checked is the one refreshed, read in this process:
# a child run by relative path read the default registry, and failed
# outside the repository root.
registry = data_dir_registry_at(args.registry, required=True)
failed = refresh_keys(registry, updated(report), force=True)
if failed:
print(f"ERROR: refresh failed for {', '.join(failed)}", file=sys.stderr)
sys.exit(1)
# Unreachable upstream means the freshness question was not answered, and
# a zero exit says it was answered "fresh". An asset whose HEAD went
# unanswered is the same question left open, as check_freshness counts
# UNKNOWN. A new asset nobody tracks, or a tracked one the buildbot
# dropped, is a change to act on: a zero exit there let the online
# pipeline call the system directory current.
if report.get("error") or pending(report) or unanswered(report):
raise SystemExit(1)
if __name__ == "__main__":
from core.cli import run_cli
run_cli(main)