Expose prepublication benchmark page guard
next-site-candidate / validate-and-candidate (push) Successful in 5s

This commit is contained in:
Alkane CI
2026-10-16 08:44:49 -06:00
parent 334b993d52
commit ea160545c4
2 changed files with 14 additions and 2 deletions
+9
View File
@@ -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 + '<meta http-equiv="refresh" content="0">')
self.assertEqual(subprocess.run(command, capture_output=True).returncode, 1)
def test_rejects_active_content(self):
(self.root / "os/index.html").write_text(PAGE + "<script>alert(1)</script>")
self.assertTrue(any("forbidden tag" in error for error in validate(self.root)))
+5 -2
View File
@@ -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