diff --git a/ci/publish-bench-pages.py b/ci/publish-bench-pages.py index 1819f5a..5e3e930 100644 --- a/ci/publish-bench-pages.py +++ b/ci/publish-bench-pages.py @@ -12,6 +12,8 @@ import tempfile from urllib.request import Request, urlopen PAGES_REPO = "ssh://git@gitea.bluefla.re:2222/blueflare/alkane-benchmarks.git" +GUARD_REPO = "https://gitea.bluefla.re/blueflare/alkane-benchmarks.git" +GUARD_COMMIT = "ea160545c49bc419a245692deda8dd7db7a611eb" PAGES_HOST = "gitea.bluefla.re" PAGES_HOST_FINGERPRINT = "SHA256:lqB5cmC9E5HNeg/lkzdOwQ++I8A70Wx7lnNs6liN24g" @@ -43,12 +45,20 @@ def publish(site: str) -> None: page = Path("bench-site/index.html").read_bytes() if not page.startswith(b"") or len(page) > 1_048_576: raise ValueError("invalid benchmark page") - key = os.environ["BENCH_PAGES_DEPLOY_KEY"] - if not key.startswith("-----BEGIN OPENSSH PRIVATE KEY-----"): - raise ValueError("missing benchmark Pages deploy key") - with tempfile.TemporaryDirectory(prefix="alkane-pages-") as directory: temporary = Path(directory) + guard_checkout = temporary / "guard" + run("git", "clone", "--quiet", "--single-branch", "--branch", "next", + GUARD_REPO, str(guard_checkout)) + guard_source = run("git", "show", f"{GUARD_COMMIT}:ci/validate_site.py", + cwd=guard_checkout).stdout + guard_script = temporary / "validate_site.py" + guard_script.write_text(guard_source) + run("python3", str(guard_script), "--page", site, + str(Path("bench-site/index.html").resolve())) + key = os.environ["BENCH_PAGES_DEPLOY_KEY"] + if not key.startswith("-----BEGIN OPENSSH PRIVATE KEY-----"): + raise ValueError("missing benchmark Pages deploy key") key_path = temporary / "deploy_key" key_path.write_text(key.rstrip("\n") + "\n") key_path.chmod(0o600)