feat: report a published export that fell behind

exports/ is committed but CI cannot rebuild it, since the originals it
patches live in the local cache. The native freshness check now runs
the export offline and compares it with the committed files, and
refresh_stale writes the export again after refreshing an original.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 09:28:14 +02:00
1 parent b6a1304893
commit f8e0b33314
4 files changed
+108 -7

No files matched your search

+34
View File
@@ -12,6 +12,7 @@ import os
import sys
import tempfile
import unittest
from unittest import mock
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -87,6 +88,39 @@ class NativeCacheTests(unittest.TestCase):
self.assertIn("batocera", {r.subject for r in rows})
class PublishedExportTests(unittest.TestCase):
"""exports/ is committed and published, and CI cannot rebuild it."""
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
self.addCleanup(self._tmp.cleanup)
self.published = Path(self._tmp.name)
(self.published / "plat").mkdir()
(self.published / "plat" / "list.txt").write_text("a", encoding="utf-8")
(self.published / "plat.json").write_text("{}", encoding="utf-8")
def _state(self, written: str, ok: bool = True) -> str:
def fake(platform, _cls, _truth, output, *_rest):
(output / platform).mkdir(parents=True)
(output / platform / "list.txt").write_text(written, encoding="utf-8")
(output / f"{platform}.json").write_text("{}", encoding="utf-8")
return ok, [] if ok else ["the platform's own file is required"]
with mock.patch.object(cf.export_native, "export_platform", fake):
return cf.published_export_state(
"plat", object, Path("t"), Path("p"), Path("c"), self.published
)
def test_the_same_bytes_are_fresh(self):
self.assertEqual(self._state("a"), "")
def test_a_moved_hash_is_named(self):
self.assertIn("is not what the export writes now", self._state("b"))
def test_an_export_that_fails_is_named(self):
self.assertIn("the export fails", self._state("a", ok=False))
class PlatformDiffTests(unittest.TestCase):
def _platform(self, version="1", files=None, cores=None):
return {
+6 -2
View File
@@ -46,7 +46,8 @@ class Planning(unittest.TestCase):
self.assertEqual(
[list(c[1:]) for c in jobs[0].then],
[["scripts/generate_truth.py", "--platform", "retrobat"],
["scripts/export_native.py", "--platform", "retrobat", "--refresh-cache"]],
["scripts/export_native.py", "--platform", "retrobat", "--refresh-cache"],
["scripts/export_native.py", "--platform", "retrobat"]],
)
def test_a_native_row_of_a_rescraped_platform_is_not_a_second_job(self):
@@ -64,7 +65,10 @@ class Planning(unittest.TestCase):
)
self.assertEqual(
[list(c[1:]) for c in jobs[0].then],
[["scripts/export_native.py", "--platform", "lakka", "--refresh-cache"]],
# exports/ is published: the corrected file is written again
# from the refreshed original.
[["scripts/export_native.py", "--platform", "lakka", "--refresh-cache"],
["scripts/export_native.py", "--platform", "lakka"]],
)
def test_a_platform_without_a_scraper_is_surfaced(self):