fix: offline target lists are skipped, not ok

Offline, check_freshness labelled every scraped target list static and counted it OK although nothing was compared. Other sections say SKIPPED offline, and now this one does too.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 04:43:45 +02:00
1 parent 2bb4dc9187
commit eaa40d7384
2 files changed
+29 -1

No files matched your search

+10 -1
View File
@@ -473,7 +473,7 @@ def check_targets(
with overrides_path.open(encoding="utf-8") as fh:
overrides = yaml_load(fh) or {}
index = profile_name_index(profiles)
scrapers = {} if offline else _target_scrapers()
scrapers = _target_scrapers()
findings: list[Finding] = []
today = datetime.now(timezone.utc)
@@ -485,6 +485,15 @@ def check_targets(
old = yaml_load(fh) or {}
module = scrapers.get(platform)
targets = old.get("targets") or {}
if module is not None and offline:
# Scraped, so offline means not compared: SKIPPED, as every other
# section says it. Labelled static and OK, a list 400 days old
# read as current.
stamp = str(old.get("scraped_at", ""))[:10]
out = [Finding("targets", platform, SKIPPED, local=stamp, detail="offline")]
missing = unresolved_target_cores(old, index, _platform_overrides(overrides, platform))
out.extend(_unresolved_findings(platform, missing))
return out
if module is None and targets and all(
(t or {}).get("cores", []) is None for t in targets.values()
):
+19
View File
@@ -330,6 +330,25 @@ class RepositoryWiringTests(unittest.TestCase):
solo = [f for f in findings if f.subject == "solo"]
self.assertEqual([(f.status, f.detail) for f in solo], [(cf.OK, "every declared 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."""
import tempfile # noqa: PLC0415
from pathlib import Path as _Path # noqa: PLC0415
scraped = sorted(cf._target_scrapers())
self.assertTrue(scraped)
platform = scraped[0]
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
targets = _Path(tmp) / "targets"
targets.mkdir()
(targets / f"{platform}.yml").write_text(
f"platform: {platform}\nscraped_at: '2025-01-01'\n"
"targets:\n one:\n cores: []\n")
findings = cf.check_targets(_Path(tmp), _Path(tmp), {}, 1, True)
row = [f for f in findings if f.subject == platform]
self.assertEqual([(f.status, f.detail) for f in row], [(cf.SKIPPED, "offline")])
def test_romm_emulatorjs_pin_is_read_from_its_dockerfile(self):
"""emulatorjs.yml is no registered platform: a RomM image moving to
another EmulatorJS changed the cores its users run, unnoticed."""