30 lines
883 B
Python
30 lines
883 B
Python
#!/usr/bin/env python3
|
|
"""Validate the current public Pages branch in a disposable directory."""
|
|
|
|
import io
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tarfile
|
|
from tempfile import TemporaryDirectory
|
|
|
|
from validate_site import validate
|
|
|
|
|
|
def main() -> int:
|
|
subprocess.run(["git", "fetch", "--quiet", "origin", "gh-pages"], check=True)
|
|
archive = subprocess.check_output(["git", "archive", "FETCH_HEAD"])
|
|
with TemporaryDirectory(prefix="alkane-benchmarks-site-") as directory:
|
|
with tarfile.open(fileobj=io.BytesIO(archive)) as source:
|
|
source.extractall(directory, filter="data")
|
|
errors = validate(Path(directory))
|
|
for error in errors:
|
|
print(error)
|
|
if errors:
|
|
return 1
|
|
print("Published benchmark pages are data-only and structurally valid")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|