Gate benchmark releases on live Pages privacy
This commit is contained in:
@@ -21,6 +21,8 @@ jobs:
|
||||
run: python3 -m unittest discover -s ci -p 'test_*.py'
|
||||
- name: Validate published Pages snapshot
|
||||
run: python3 ci/check_published.py
|
||||
- name: Verify live Pages and source isolation
|
||||
run: python3 ci/check_live_pages.py
|
||||
- name: Publish measured repository badges
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/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())
|
||||
Reference in New Issue
Block a user