Skip to content

Commit 0864201

Browse files
committed
test(artifacts): add cross-format parity checks
1 parent 2b53d17 commit 0864201

2 files changed

Lines changed: 39 additions & 11 deletions

File tree

.github/scripts/validate-artifacts.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
"Verification",
2323
"[CUSTOMIZE:",
2424
)
25+
PARITY_PHRASES = (
26+
FULL_TITLE,
27+
"Conventions",
28+
"Purpose",
29+
"Verification",
30+
"Dashboard",
31+
"WP-CLI",
32+
"[CUSTOMIZE:",
33+
)
2534

2635

2736
class ValidationError(Exception):
@@ -74,6 +83,7 @@ def validate_pdf(path: Path) -> None:
7483
text = extract_pdf_text(path)
7584
assert_contains(text, (FULL_TITLE, SHORT_TITLE, "Version 3.1", *CANONICAL_TOKENS), "PDF")
7685
print("OK [PDF] canonical text markers found")
86+
return text
7787

7888

7989
def extract_xml_text(xml_bytes: bytes) -> str:
@@ -104,6 +114,7 @@ def validate_docx(path: Path) -> None:
104114
assert_contains(document_text, ("Conventions", "Purpose", "Verification"), "DOCX")
105115

106116
print("OK [DOCX] structure, metadata, and canonical text markers found")
117+
return document_text
107118

108119

109120
def validate_epub(path: Path) -> None:
@@ -134,14 +145,31 @@ def validate_epub(path: Path) -> None:
134145

135146
epub_text = []
136147
for member in xhtml_members:
137-
epub_text.append(extract_xml_text(archive.read(member)))
138-
assert_contains(" ".join(epub_text), ("WordPress Operations Runbook", *CANONICAL_TOKENS), "EPUB")
148+
epub_text.append(extract_xml_text(archive.read(member)))
149+
joined_text = " ".join(epub_text)
150+
assert_contains(joined_text, ("WordPress Operations Runbook", *CANONICAL_TOKENS), "EPUB")
139151

140152
print("OK [EPUB] structure, metadata, and canonical text markers found")
153+
return joined_text
154+
155+
156+
def validate_markdown(path: Path) -> str:
157+
ensure_exists(path, "Markdown")
158+
text = path.read_text(encoding="utf-8")
159+
assert_contains(text, ("WordPress Operations Runbook", "Conventions", "Dashboard", "WP-CLI", "[CUSTOMIZE:"), "Markdown")
160+
print("OK [Markdown] canonical text markers found")
161+
return text
162+
163+
164+
def validate_cross_format_parity(texts: dict[str, str]) -> None:
165+
for label, text in texts.items():
166+
assert_contains(text, PARITY_PHRASES, label)
167+
print(f"OK [Parity] canonical phrases match across {len(texts)} formats")
141168

142169

143170
def parse_args() -> argparse.Namespace:
144171
parser = argparse.ArgumentParser(description=__doc__)
172+
parser.add_argument("--markdown", default="WP-Operations-Runbook.md", help="Markdown source path")
145173
parser.add_argument("--pdf", default="WP-Operations-Runbook.pdf", help="PDF artifact path")
146174
parser.add_argument("--epub", default="WP-Operations-Runbook.epub", help="EPUB artifact path")
147175
parser.add_argument("--docx", default="WP-Operations-Runbook.docx", help="DOCX artifact path")
@@ -150,20 +178,19 @@ def parse_args() -> argparse.Namespace:
150178

151179
def main() -> int:
152180
args = parse_args()
153-
validators = (
154-
(validate_pdf, Path(args.pdf)),
155-
(validate_epub, Path(args.epub)),
156-
(validate_docx, Path(args.docx)),
157-
)
158-
159181
try:
160-
for validator, path in validators:
161-
validator(path)
182+
texts = {
183+
"Markdown": validate_markdown(Path(args.markdown)),
184+
"PDF": validate_pdf(Path(args.pdf)),
185+
"EPUB": validate_epub(Path(args.epub)),
186+
"DOCX": validate_docx(Path(args.docx)),
187+
}
188+
validate_cross_format_parity(texts)
162189
except ValidationError as exc:
163190
print(f"FAIL {exc}", file=sys.stderr)
164191
return 1
165192

166-
print("All artifact checks passed (3 formats).")
193+
print("All artifact and parity checks passed (4 formats).")
167194
return 0
168195

169196

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to the WordPress Operations Runbook template.
88
- Added a `Series review` issue form so quarterly and pre-release cross-document alignment checks can be tracked explicitly.
99
- Added a repo-local generated-artifact smoke validator and a dedicated `Validate Artifacts` workflow for PDF, EPUB, and DOCX outputs.
1010
- Added a Playwright-based PDF visual smoke test and dedicated workflow with committed baselines for critical page regions.
11+
- Added a cross-format parity check so a small set of canonical phrases must remain present in the Markdown source and generated PDF, EPUB, and DOCX outputs.
1112

1213
### Changed
1314
- Corrected the example WordPress version placeholder to reflect WordPress 6.9.1 as the current stable release.

0 commit comments

Comments
 (0)