diff --git a/scripts/check_freshness.py b/scripts/check_freshness.py index 4dfd8a1f..217ca46c 100644 --- a/scripts/check_freshness.py +++ b/scripts/check_freshness.py @@ -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() ): diff --git a/tests/test_check_freshness.py b/tests/test_check_freshness.py index 25719c74..8d7d0892 100644 --- a/tests/test_check_freshness.py +++ b/tests/test_check_freshness.py @@ -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."""