mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
check_buildbot_system --update ran scripts/refresh_data_dirs.py by a relative path and without --registry: the refresh read the default registry, and outside the repository root the child was not found and every updated entry was reported failed. The command now refreshes in process through packs.datadirs.refresh_keys with the registry it checked; buildbot_system keeps the check and its selectors.
88 lines
2.8 KiB
Python
88 lines
2.8 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 scraper.buildbot_system 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)
|