From 398246b064f17f1a6179145a6d9e54c6a8f12c46 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:11:12 +0100 Subject: [PATCH] feat: link the change reports and the wanted CSV --- scripts/generate_site.py | 11 +++++++++++ scripts/siteexports.py | 10 ++++++++-- tests/test_export_report.py | 11 +++++++++++ tests/test_provenance.py | 6 ++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index c01fc7919..b8b79744a 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -1847,6 +1847,15 @@ def _publish_manifests(api: Path) -> list[tuple]: _record(targets / source.name) assets.append((targets / source.name, f"Target list: {source.stem}", "application/json", "schemas/target-manifest.schema.json")) + # Every change each updated platform file carries, for a maintainer who + # reviews them by script: the Exports page linked only the files. + exports = api / "exports" + exports.mkdir(parents=True, exist_ok=True) + for source in sorted((_REPO_ROOT / "exports").glob("*.json")): + shutil.copy2(source, exports / source.name) + _record(exports / source.name) + assets.append((exports / source.name, f"Updated platform file, its changes: {source.stem}", + "application/json", None)) release = _REPO_ROOT / "release.json" if release.is_file(): shutil.copy2(release, api / "release.json") @@ -5344,6 +5353,8 @@ def generate_provenance_page( "matching one of these hashes is welcome: see " "[Contributing](contributing.md).", "", + markup.button("Download the list (CSV)", "downloads/provenance-wanted.csv"), + "", ] ) diff --git a/scripts/siteexports.py b/scripts/siteexports.py index d6be34f48..870cbe43d 100644 --- a/scripts/siteexports.py +++ b/scripts/siteexports.py @@ -17,6 +17,8 @@ EXPORTS_DIR = "exports" REPO_BLOB = "https://github.com/Abdess/retrobios/blob/main" REPO_TREE = "https://github.com/Abdess/retrobios/tree/main" REPO_RAW = "https://raw.githubusercontent.com/Abdess/retrobios/main" +# Where the site publishes each report, beside the API (generate_site). +API_EXPORTS = "api/v1/exports" # Report key, then how a line of it reads on the page. CHANGE_KINDS = ( @@ -318,16 +320,20 @@ def generate_exports_page(reports: list[dict], names: dict[str, str]) -> str: originals = report.get("originals") or {} files = report["files"] raw = [f"{REPO_RAW}/{EXPORTS_DIR}/{platform}/{name}" for name in files] + # Every change as JSON, the report the page is written from. + changes = markup.button("Every change (JSON)", f"{API_EXPORTS}/{platform}.json") if len(files) == 1: lines.extend([ markup.button("Download the updated file", raw[0], primary=True) + " " - + markup.button("See it on GitHub", f"{REPO_BLOB}/{EXPORTS_DIR}/{platform}/{files[0]}"), + + markup.button("See it on GitHub", f"{REPO_BLOB}/{EXPORTS_DIR}/{platform}/{files[0]}") + + " " + changes, "", ]) else: lines.extend([ markup.button(f"Browse the {len(files)} updated files", - f"{REPO_TREE}/{EXPORTS_DIR}/{platform}", primary=True), + f"{REPO_TREE}/{EXPORTS_DIR}/{platform}", primary=True) + + " " + changes, "", ]) if len(originals) > 1: diff --git a/tests/test_export_report.py b/tests/test_export_report.py index 5ebf2283f..1b25ab45e 100644 --- a/tests/test_export_report.py +++ b/tests/test_export_report.py @@ -89,6 +89,17 @@ class CorrectedFilesPage(unittest.TestCase): self.page, ) + def test_every_section_links_its_changes_as_json(self): + """exports/batocera.json listed 141 changes and no page or catalog + entry named it: a maintainer had to scrape the HTML.""" + for platform in ("recalbox", "retropie"): + self.assertIn(f'href="api/v1/exports/{platform}.json"', self.page) + source = (ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8") + publish = source[source.index("def _publish_manifests("):] + publish = publish[:publish.index("\ndef ")] + self.assertIn('(_REPO_ROOT / "exports").glob("*.json")', publish) + self.assertIn('exports = api / "exports"', publish) + def test_several_files_link_to_their_directory(self): self.assertIn("tree/main/exports/retropie", self.page) self.assertIn("The 2 original files it is based on", self.page) diff --git a/tests/test_provenance.py b/tests/test_provenance.py index 14ce31bfe..9f3eebea4 100644 --- a/tests/test_provenance.py +++ b/tests/test_provenance.py @@ -470,6 +470,12 @@ class TestProvenancePage(unittest.TestCase): self.assertIn("14df4f6c1e367ce097c11deae21566b4fe5647a9", page) self.assertIn("### Redump", page) + def test_the_wanted_list_links_its_csv(self): + """provenance-wanted.csv was linked from the data page alone.""" + page = self._page() + wanted = page[page.index("## Wanted: catalogued dumps"):] + self.assertIn('href="downloads/provenance-wanted.csv"', wanted[:wanted.index("###")]) + def test_page_has_anchor_targets_for_badges(self): """System-page badges link to ../provenance.md#.""" page = self._page()