From ea160545c49bc419a245692deda8dd7db7a611eb Mon Sep 17 00:00:00 2001 From: Alkane CI Date: Fri, 16 Oct 2026 08:44:49 -0600 Subject: [PATCH] Expose prepublication benchmark page guard --- ci/test_validate_site.py | 9 +++++++++ ci/validate_site.py | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ci/test_validate_site.py b/ci/test_validate_site.py index f4807b0..5d924a1 100644 --- a/ci/test_validate_site.py +++ b/ci/test_validate_site.py @@ -4,6 +4,8 @@ import tempfile import unittest from pathlib import Path +import subprocess +import sys from validate_site import validate @@ -28,6 +30,13 @@ class SiteValidationTests(unittest.TestCase): def test_valid_data_only_site(self): self.assertEqual(validate(self.root), []) + def test_single_page_prepublication_cli(self): + command = [sys.executable, str(Path(__file__).with_name("validate_site.py")), + "--page", "os", str(self.root / "os/index.html")] + self.assertEqual(subprocess.run(command, capture_output=True).returncode, 0) + (self.root / "os/index.html").write_text(PAGE + '') + self.assertEqual(subprocess.run(command, capture_output=True).returncode, 1) + def test_rejects_active_content(self): (self.root / "os/index.html").write_text(PAGE + "") self.assertTrue(any("forbidden tag" in error for error in validate(self.root))) diff --git a/ci/validate_site.py b/ci/validate_site.py index f1475da..f6a6947 100644 --- a/ci/validate_site.py +++ b/ci/validate_site.py @@ -111,13 +111,16 @@ def validate(root: Path) -> list[str]: def main() -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("site", type=Path) + parser.add_argument("--page", choices=("sdk", "os", "toolkit"), + help="validate one generated report before publication") args = parser.parse_args() - errors = validate(args.site) + errors = (validate_page(args.site, f"{args.page}/index.html") + if args.page else validate(args.site)) for error in errors: print(error) if errors: return 1 - print(f"Validated {len(PAGES)} public benchmark pages") + print(f"Validated {args.page or len(PAGES)} public benchmark pages") return 0