fix: read targets and data from --platforms-dir

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 14:57:45 +01:00
1 parent 88e39b6380
commit 7203b5be84
4 files changed
+28 -17

No files matched your search

+1 -1
View File
@@ -143,7 +143,7 @@ def main() -> int:
if "coreinfo" in areas:
findings.extend(check_coreinfo(profiles, args.cache_dir, args.offline))
if "data" in areas:
findings.extend(check_data(args.offline))
findings.extend(check_data(platforms_dir, args.offline))
if "catalogs" in areas:
findings.extend(check_catalogs(args.cache_dir, args.offline))
if "ci" in areas:
+7 -8
View File
@@ -4,17 +4,18 @@ from __future__ import annotations
import contextlib
import io
from pathlib import Path
from core.paths import DATA_DIRS_FILE, REPO_ROOT
from core.paths import DATA_DIRS_FILE
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]:
def check_data(platforms_dir: Path, 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)
registry = load_data_dir_registry(platforms_dir, required=True)
sink = io.StringIO()
with contextlib.redirect_stdout(sink):
results = datadirs.refresh_all(registry, dry_run=True)
@@ -26,11 +27,11 @@ def check_data(offline: bool) -> list[Finding]:
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())
findings.append(_check_buildbot_system(platforms_dir))
return findings
def _check_buildbot_system() -> Finding:
def _check_buildbot_system(platforms_dir: Path) -> Finding:
"""The buildbot's system directory against what _data_dirs.yml tracks.
The registry entries are refreshed above. An asset published since, or
@@ -39,9 +40,7 @@ def _check_buildbot_system() -> Finding:
from scraper import buildbot_system
with contextlib.redirect_stdout(io.StringIO()):
report = buildbot_system.check(
str(REPO_ROOT / DATA_DIRS_FILE)
)
report = buildbot_system.check(str(platforms_dir / Path(DATA_DIRS_FILE).name))
if report.get("error"):
return Finding("data", "buildbot system", UNKNOWN, detail="index unreachable")
todo = buildbot_system.pending(report)
+3 -4
View File
@@ -8,7 +8,6 @@ from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timezone
from pathlib import Path
from core.paths import REPO_ROOT
from model.profiles import upstream_profile_index
from model.sources import source_yaml_file
from model.targets import apply_target_overrides, platform_overrides, read_target_overrides
@@ -87,7 +86,7 @@ def check_targets(
# sudachi without one are BIOS its pack never carries.
out = [Finding("targets", platform, OK, local="static",
detail="every declared core")]
declared = _declared_cores(platform)
declared = _declared_cores(platform, platforms_dir)
missing = unresolved_target_cores(
{"targets": {name: {"cores": declared} for name in targets}},
index, platform_overrides(overrides, platform),
@@ -140,12 +139,12 @@ def check_targets(
return findings
def _declared_cores(platform: str) -> list[str]:
def _declared_cores(platform: str, platforms_dir: Path) -> list[str]:
"""The cores and standalone emulators a platform's own file names."""
from model.platforms import load_platform_config
try:
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
config = load_platform_config(platform, str(platforms_dir))
except (FileNotFoundError, OSError):
return []
cores = config.get("cores")
+17 -4
View File
@@ -726,6 +726,19 @@ class RepositoryWiringTests(unittest.TestCase):
solo = [f for f in findings if f.subject == "solo"]
self.assertEqual([(f.status, f.detail) for f in solo], [(OK, "every declared core")])
def test_a_static_target_reads_the_given_platforms_dir(self):
"""The declared cores were read from the repository's platforms/
whatever --platforms-dir named."""
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "targets").mkdir()
(root / "targets" / "solo.yml").write_text(
"platform: solo\nsource: static\ntargets:\n only:\n cores: null\n")
(root / "solo.yml").write_text("platform: solo\ncores: [unprofiled_core]\nsystems: {}\n")
findings = check_targets(root, root, {}, 1, True)
rows = [f for f in findings if f.subject == "solo cores"]
self.assertEqual([f.items for f in rows], [["unprofiled_core"]])
def test_a_scraped_target_offline_is_skipped_not_ok(self):
"""Offline, scraped target lists were labelled static and counted OK
without any comparison, so a list 400 days old read as current."""
@@ -789,11 +802,11 @@ class AStaticTargetStillNamesItsCores(unittest.TestCase):
before reading the names, and its 50 unprofiled emulators never showed."""
def test_declared_names_are_checked(self):
names = _declared_cores("retrobat")
names = _declared_cores("retrobat", REPO_ROOT / "platforms")
self.assertIn("winuae", names)
source = (SCRIPTS / "freshness" / "targets.py").read_text(encoding="utf-8")
static = source.index('detail="every declared core"')
self.assertLess(static, source.index("_declared_cores(platform)"))
self.assertLess(static, source.index("_declared_cores(platform, platforms_dir)"))
@@ -811,11 +824,11 @@ class TheBuildbotIndexIsRead(unittest.TestCase):
{"zip": "Old.zip", "status": "OK", "key": "old"},
]}
with mock.patch.object(buildbot_system, "check", lambda registry: report):
finding = _check_buildbot_system()
finding = _check_buildbot_system(REPO_ROOT / "platforms")
self.assertEqual(finding.status, STALE)
self.assertIn("new New.zip", finding.detail)
with mock.patch.object(buildbot_system, "check", lambda registry: {"error": "x", "entries": []}):
self.assertEqual(_check_buildbot_system().status, UNKNOWN)
self.assertEqual(_check_buildbot_system(REPO_ROOT / "platforms").status, UNKNOWN)
self.assertEqual([e["zip"] for e in buildbot_system.pending(report)], ["New.zip"])