Files
alkane-benchmarks/ci/check_live_pages.py
T
noah a2ef500560
next-site-candidate / validate-and-candidate (push) Successful in 5s
main-site-gate / validate-and-release (push) Successful in 10s
Gate benchmark releases on live Pages privacy
2026-10-17 03:04:38 -06:00

54 lines
1.5 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
"""Check that benchmark Pages are public and source repository Pages stay closed."""
from urllib.error import HTTPError, URLError
from urllib.request import HTTPRedirectHandler, Request, build_opener
BASE = "https://blueflare.gitea.bluefla.re"
PUBLIC = (
"/alkane-benchmarks/",
"/alkane-benchmarks/sdk/",
"/alkane-benchmarks/os/",
"/alkane-benchmarks/toolkit/",
)
PRIVATE = ("/alkane-sdk/", "/alkane-os/", "/alkane-toolkit/")
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, request, response, code, message, headers, url):
return None
def status(opener, path: str) -> int:
request = Request(BASE + path, headers={"User-Agent": "alkane-pages-gate/1"})
try:
with opener.open(request, timeout=15) as response:
return response.status
except HTTPError as error:
return error.code
def main() -> int:
opener = build_opener(NoRedirect)
failed = False
for path in PUBLIC + PRIVATE:
expected = 200 if path in PUBLIC else 404
try:
actual = status(opener, path)
except URLError as error:
print(f"FAIL {path}: {error.reason}")
failed = True
continue
if actual != expected:
print(f"FAIL {path}: HTTP {actual}; expected {expected}")
failed = True
else:
print(f"PASS {path}: HTTP {actual}")
return int(failed)
if __name__ == "__main__":
raise SystemExit(main())