Run PDF parity checks without Poppler on CI
Beffroi Reporting CI A component or integration check failed.
Beffroi/beffroi-reporting/pipeline/head There was a failure building this commit
Details
Beffroi Reporting CI A component or integration check failed.
Beffroi/beffroi-reporting/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
a250b3ce8e
commit
a5b4a8f9cd
|
|
@ -11,8 +11,10 @@ The original renderer is retained locally under `legacy/typst_reporter`. Run its
|
|||
the reference PDFs. `./beffroi.sh test` builds the stored publication and runs
|
||||
`scripts/check-legacy-parity.py` against all 17 PDFs. With the local reference
|
||||
available, the check compares every page raster as well as extracted text and
|
||||
pagination. Recorded original text hashes and page counts also guard CI builds
|
||||
without the ignored legacy directory.
|
||||
pagination. The portable CI check uses pinned `pypdf` via `uv` for text and page
|
||||
counts; Poppler adds its original text check and page raster comparison when
|
||||
available. The recorded hashes guard CI builds without the ignored legacy
|
||||
directory or Poppler tools.
|
||||
|
||||
The diagnostic analyzer at `reports/plugins/diagnostics/analyse.sh` produces a
|
||||
normalized evidence artifact. It is separate from the PDF renderer. The
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# Check the independent Typst plugins and their source-faithful publication.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
for command in git typst python3 pdfinfo pdftotext pdftoppm; do
|
||||
for command in git typst python3 uv; do
|
||||
command -v "$command" >/dev/null 2>&1 || { echo "Missing test dependency: $command" >&2; exit 1; }
|
||||
done
|
||||
for component in reporter reports/plugins/diagnostics reports; do
|
||||
|
|
@ -19,5 +19,6 @@ typst eval --root "$work/workflow" --input diagnostic=diagnostic.json \
|
|||
--in "$work/workflow/check-diagnostic.typ" 'query(<valid>).first().value' >/dev/null
|
||||
[[ $(head -c 5 "$work/workflow/report.pdf") == '%PDF-' ]]
|
||||
scripts/build-publication.sh "$work/publication"
|
||||
python3 scripts/check-legacy-parity.py "$work/publication"
|
||||
uv run --isolated --no-project --with pypdf==6.7.5 python3 \
|
||||
scripts/check-legacy-parity.py "$work/publication"
|
||||
echo 'Component checks and all 17 legacy PDF parity checks passed.'
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ with tempfile.TemporaryDirectory(prefix="beffroi-parity.") as directory:
|
|||
output = Path(directory) / "publication"
|
||||
subprocess.run([str(root / "scripts/build-publication.sh"), str(output)], check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
subprocess.run(["python3", str(root / "scripts/check-legacy-parity.py"), str(output)], check=True)
|
||||
subprocess.run(["uv", "run", "--isolated", "--no-project", "--with", "pypdf==6.7.5",
|
||||
"python3", str(root / "scripts/check-legacy-parity.py"), str(output)], check=True)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@
|
|||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from pypdf import PdfReader
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
REFERENCE = ROOT / "legacy/typst_reporter/build"
|
||||
EXPECTED = {
|
||||
|
|
@ -33,10 +36,37 @@ EXPECTED = {
|
|||
},
|
||||
}
|
||||
|
||||
# Extracted from the original PDFs using pypdf 6.7.5, layout mode. This is the
|
||||
# portable CI oracle; Poppler checks below remain available when installed.
|
||||
EXPECTED_PYPDF = {
|
||||
"reports": {
|
||||
"2026-09-04-clevo-handoff": "e479a341bb3282ae85e0c18bc839c5f679704f92c9a332f9793a47407eac2e8d",
|
||||
"2026-09-04-clevo-initial": "5286ec509e8a77bf77221e19dc92adfd6e85056b1e8db79896a92947cc2a58b9",
|
||||
"2026-09-04-report": "637fa32246969b6410a687b255ac83ab2fc93e577f88a8bed2f489aa2d1a2a41",
|
||||
"2026-09-14-system-stability-diagnostic-notes": "566e811d71dcfbe46161d767d92d0a3b7bfd909bec041259724a932bc5733300",
|
||||
"2026-09-15-clevo-diagnostic-synthesis": "f005a0179181c5d986be478bae4fe640a4f363f46bb157977fb6038cc5390c4d",
|
||||
"2026-09-15-clevo-manufacturer-report": "614f9f2a2cb77075d65549185298d101610b90a314098ff34b43813b09c60863",
|
||||
"2026-09-15-clevo-system-stability-diagnostic-notes": "49ed67cfb4c6186b0b6cc6a56d8182e437553a6c878ed8b90e3299f2fb67560e",
|
||||
},
|
||||
"diagnostics": {
|
||||
"hardware-17-tA6kwqAg-windows-system-report-desktop-2osf051-20260904-134702": "b8c8d9f9118b27fcd9c55825c7d36e3d06f9d4487a8960cfdd058705781c5a0a",
|
||||
"hardware-18-WHA8oUN2-windows-system-report-pcvid008-20260904-134729": "8220f7515481afb9e387e9941448659762a488e139c4dd612156ad63ee7d7e64",
|
||||
"hardware-19-BOOso6wz-windows-system-report-desktop-dh4hot6-20260904-173202": "848ff93eb3d7750e18c2665d22b3655e63989b6386cdad0c958e83afd7c0f2c7",
|
||||
"hardware-20-dlBVl76W-windows-system-report-desktop-pr71lgi-20260904-162618": "e9c40150192191a248d936b6af4b18070e4cc7d03655599280f7f9597f737f95",
|
||||
"hardware-35-NSmkLXTb-windows-system-report-blin2-20260904-161637": "610875982bdd33cdcb4434b6ad01a7df9ade7fb783134dbf0cf98741d8d6c38f",
|
||||
"hardware-51-6M9gNOPR-windows-system-report-desktop-sau019h-20260904-164514": "31a22a61c6740af88507035cfeef6479a4526fe05e724aa346f8309a8de89e94",
|
||||
"hardware-53-AbCX84Q8-windows-system-report-desktop-3pptg49-20260904-135829": "9e2c596d85c222bdd31ba2a4d73a7aecaec7abb090eaa935d53ed66ebc907490",
|
||||
"windows_system_report_DESKTOP-SAU019H_20260914_163753": "70019c92e00c0fb2c0aad31338744670ec5c873140b1927fe94df7edae69dd3a",
|
||||
"windows_system_report_DESKTOP-SAU019H_20260915_113124": "7e86da7c5532fb2a91b2dd93a96f58468ab881a7cd890b0606fa58f3c8073c74",
|
||||
"windows_system_report_DESKTOP-SAU019H_20260915_121057": "5dc7281fa5f2be08e968cae9df408d50a26d2f0ee6236d31d0ea2b708d91b3a4",
|
||||
},
|
||||
}
|
||||
|
||||
def pages(pdf):
|
||||
info = subprocess.check_output(["pdfinfo", str(pdf)], text=True)
|
||||
return int(next(line.split(":", 1)[1] for line in info.splitlines() if line.startswith("Pages:")))
|
||||
|
||||
def portable_pdf_info(pdf):
|
||||
reader = PdfReader(pdf)
|
||||
text = "\n".join(page.extract_text(extraction_mode="layout") for page in reader.pages)
|
||||
return len(reader.pages), hashlib.sha256(text.encode()).hexdigest()
|
||||
|
||||
|
||||
def text_hash(pdf):
|
||||
|
|
@ -57,7 +87,8 @@ def main():
|
|||
print(f"Usage: {sys.argv[0]} BUILD_ROOT", file=sys.stderr)
|
||||
return 2
|
||||
build = Path(sys.argv[1])
|
||||
check_raster = REFERENCE.is_dir()
|
||||
check_poppler_text = shutil.which("pdftotext") is not None
|
||||
check_raster = REFERENCE.is_dir() and shutil.which("pdftoppm") is not None
|
||||
for category, documents in EXPECTED.items():
|
||||
folder = build / category / "pdfs" if category == "reports" else build / category
|
||||
actual = {path.stem: path for path in folder.glob("*.pdf")}
|
||||
|
|
@ -66,9 +97,12 @@ def main():
|
|||
return 1
|
||||
for name, (wanted_pages, wanted_text) in documents.items():
|
||||
pdf = actual[name]
|
||||
if (pages(pdf), text_hash(pdf)) != (wanted_pages, wanted_text):
|
||||
if portable_pdf_info(pdf) != (wanted_pages, EXPECTED_PYPDF[category][name]):
|
||||
print(f"{category}/{name}: page count or text differs", file=sys.stderr)
|
||||
return 1
|
||||
if check_poppler_text and text_hash(pdf) != wanted_text:
|
||||
print(f"{category}/{name}: Poppler text differs", file=sys.stderr)
|
||||
return 1
|
||||
if check_raster:
|
||||
reference = REFERENCE / ("diagnostics" if category == "diagnostics" else "") / f"{name}.pdf"
|
||||
if not raster_equal(reference, pdf):
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ with tempfile.TemporaryDirectory(prefix="beffroi-parity.") as directory:
|
|||
output = Path(directory) / "publication"
|
||||
subprocess.run([str(root / "scripts/build-publication.sh"), str(output)], check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
subprocess.run(["python3", str(root / "scripts/check-legacy-parity.py"), str(output)], check=True)
|
||||
subprocess.run(["uv", "run", "--isolated", "--no-project", "--with", "pypdf==6.7.5",
|
||||
"python3", str(root / "scripts/check-legacy-parity.py"), str(output)], check=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue