mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
refactor: move check_freshness logic to freshness
This commit is contained in:
1 parent
5fa802a3c5
commit
8a2ef047ab
26 files changed
+2171
-1987
No files matched your search
@@ -0,0 +1,54 @@
|
||||
"""The data directories and the buildbot system assets against their upstream."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
from core.paths import DATA_DIRS_FILE, REPO_ROOT
|
||||
from model.registry import load_data_dir_registry
|
||||
from packs import datadirs
|
||||
from freshness.findings import OK, SHOWN_NAMES, SKIPPED, STALE, UNKNOWN, Finding
|
||||
|
||||
|
||||
def check_data(offline: bool) -> list[Finding]:
|
||||
if offline:
|
||||
return [Finding("data", "_data_dirs.yml", SKIPPED, detail="offline")]
|
||||
registry = load_data_dir_registry(REPO_ROOT / "platforms", required=True)
|
||||
sink = io.StringIO()
|
||||
with contextlib.redirect_stdout(sink):
|
||||
results = datadirs.refresh_all(registry, dry_run=True)
|
||||
findings = []
|
||||
for key, result in sorted(results.items()):
|
||||
if result is None:
|
||||
findings.append(Finding("data", key, UNKNOWN, detail="remote unreachable"))
|
||||
elif result:
|
||||
findings.append(Finding("data", key, STALE, detail="upstream changed, refresh_data_dirs.py fetches it"))
|
||||
else:
|
||||
findings.append(Finding("data", key, OK))
|
||||
findings.append(_check_buildbot_system())
|
||||
return findings
|
||||
|
||||
|
||||
def _check_buildbot_system() -> Finding:
|
||||
"""The buildbot's system directory against what _data_dirs.yml tracks.
|
||||
|
||||
The registry entries are refreshed above. An asset published since, or
|
||||
one the buildbot no longer serves, is only seen by reading its .index.
|
||||
"""
|
||||
from scraper import buildbot_system
|
||||
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
report = buildbot_system.check(
|
||||
str(REPO_ROOT / DATA_DIRS_FILE)
|
||||
)
|
||||
if report.get("error"):
|
||||
return Finding("data", "buildbot system", UNKNOWN, detail="index unreachable")
|
||||
todo = buildbot_system.pending(report)
|
||||
if not todo:
|
||||
return Finding("data", "buildbot system", OK)
|
||||
every = [f"{e['status'].lower()} {e['zip']}" for e in todo]
|
||||
names = ", ".join(every[:SHOWN_NAMES])
|
||||
more = f", ... (--json lists all {len(todo)})" if len(todo) > SHOWN_NAMES else ""
|
||||
return Finding("data", "buildbot system", STALE, local=f"{len(todo)} to track",
|
||||
detail=f"{names}{more} (_data_dirs.yml)", items=every)
|
||||
Reference in new issue
Block a user