mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 02:27:52 -06:00
feat: write the verify excerpt from a real run
The RetroDECK excerpt of wiki/reading-reports.md went stale with every file the collection gained, three times on 2026-11-12. It now sits between generated markers, and generate_report_excerpt.py writes it from verify.py --platform retrodeck at pipeline step 7 (--check reports a stale block).
This commit is contained in:
1 parent
865f56b539
commit
16b452bf3c
6 files changed
+141
-3
No files matched your search
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Write the verify excerpt of wiki/reading-reports.md from a real run.
|
||||
|
||||
Usage:
|
||||
python scripts/generate_report_excerpt.py # rewrite the block
|
||||
python scripts/generate_report_excerpt.py --check # exit 1 when stale
|
||||
|
||||
The page quotes `verify.py --platform retrodeck` to show how a report reads.
|
||||
Written by hand, it went stale with every file the collection gained: three
|
||||
times on 2026-11-12, each time a red test. The block between
|
||||
`<!-- generated: verify-retrodeck -->` and its closing marker is the run's
|
||||
own output: its first line, the entries a reader learns the shapes from
|
||||
(the first UNTESTED line, the first DISCREPANCY with the line under it),
|
||||
then every count line.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
PAGE = ROOT / "wiki" / "reading-reports.md"
|
||||
BLOCK = re.compile(
|
||||
r"(<!-- generated: verify-retrodeck -->\n```\n)(.*?)(```\n<!-- /generated: verify-retrodeck -->)",
|
||||
re.S)
|
||||
# The count lines, in the order verify prints them.
|
||||
COUNTS = (" Core files:", " Bundled with their emulator", " Core files held",
|
||||
" Game data:", " Game data held", " Launcher reads", " Launcher records",
|
||||
" No external files:", " Ground truth:", " ")
|
||||
|
||||
|
||||
def excerpt(lines: list[str]) -> list[str]:
|
||||
"""The lines of a verify run the page shows."""
|
||||
kept = [lines[0]]
|
||||
untested = next((line for line in lines if line.startswith(" UNTESTED")), None)
|
||||
if untested:
|
||||
kept.append(untested)
|
||||
for index, line in enumerate(lines):
|
||||
if line.startswith(" DISCREPANCY") and index + 1 < len(lines) \
|
||||
and lines[index + 1].startswith(" "):
|
||||
kept += [line, lines[index + 1]]
|
||||
break
|
||||
counts_from = next(i for i, line in enumerate(lines) if line.startswith(" Core files:"))
|
||||
kept += [line for line in lines[counts_from:] if line.startswith(COUNTS)]
|
||||
return kept
|
||||
|
||||
|
||||
def run() -> list[str]:
|
||||
proc = subprocess.run([sys.executable, str(ROOT / "scripts" / "verify.py"),
|
||||
"--platform", "retrodeck"], capture_output=True, text=True,
|
||||
cwd=ROOT, check=False)
|
||||
lines = proc.stdout.splitlines()
|
||||
if not lines or not lines[0].startswith("RetroDECK:"):
|
||||
raise SystemExit(f"verify did not run: {proc.stderr[-300:]}")
|
||||
return lines
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False,
|
||||
description=__doc__.split("\n\n", 1)[0])
|
||||
parser.add_argument("--check", action="store_true",
|
||||
help="exit 1, writing nothing, when the block is not the run's")
|
||||
args = parser.parse_args()
|
||||
text = PAGE.read_text(encoding="utf-8")
|
||||
found = BLOCK.search(text)
|
||||
if found is None:
|
||||
print(f"{PAGE.relative_to(ROOT)}: no verify-retrodeck block", file=sys.stderr)
|
||||
return 1
|
||||
body = "\n".join(excerpt(run())) + "\n"
|
||||
if found.group(2) == body:
|
||||
return 0
|
||||
if args.check:
|
||||
print(f"STALE {PAGE.relative_to(ROOT)}: the verify excerpt is not the run's. "
|
||||
"Run python scripts/generate_report_excerpt.py", file=sys.stderr)
|
||||
return 1
|
||||
PAGE.write_text(text[:found.start(2)] + body + text[found.end(2):], encoding="utf-8")
|
||||
print(f"Wrote {PAGE.relative_to(ROOT)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from common import run_cli
|
||||
|
||||
run_cli(main)
|
||||
+5
-1
@@ -28,6 +28,7 @@ Steps, numbered as the run prints them:
|
||||
6 --verify-packs pack integrity, extraction and hashes
|
||||
7 generate_readme.py README.md and CONTRIBUTING.md
|
||||
generate_installer_doc.py run samples and tables of wiki/installer.md
|
||||
generate_report_excerpt.py the verify excerpt of wiki/reading-reports.md
|
||||
8 generate_site.py site pages, into the Starlight project in website/
|
||||
8b npm run build (website/) rendered as the site deploy renders it, then validate_site.py
|
||||
|
||||
@@ -1526,7 +1527,10 @@ def main() -> None:
|
||||
# the manifests step 4b just wrote.
|
||||
doc_ok, _ = run([sys.executable, "scripts/generate_installer_doc.py"],
|
||||
"7 generate installer page")
|
||||
ok = ok and doc_ok
|
||||
# The verify excerpt of wiki/reading-reports.md, from this run's data.
|
||||
excerpt_ok, _ = run([sys.executable, "scripts/generate_report_excerpt.py"],
|
||||
"7 generate report excerpt")
|
||||
ok = ok and doc_ok and excerpt_ok
|
||||
results["generate_readme"] = ok
|
||||
all_ok = all_ok and ok
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user