40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MIT
|
|
"""Keep OS jobs on the verified Alkane runner image."""
|
|
|
|
from pathlib import Path
|
|
import re
|
|
import sys
|
|
|
|
import yaml
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
IMAGE = (ROOT / "ci/runner-image.txt").read_text().strip()
|
|
|
|
|
|
def main() -> int:
|
|
if not re.fullmatch(
|
|
r"gitea\.bluefla\.re/blueflare/alkane-ci@sha256:[0-9a-f]{64}", IMAGE
|
|
):
|
|
print("Runner image must be pinned by Gitea registry digest", file=sys.stderr)
|
|
return 1
|
|
for path in sorted((ROOT / ".gitea/workflows").glob("*.yml")):
|
|
workflow = yaml.load(path.read_text(), Loader=yaml.BaseLoader)
|
|
for name, job in workflow.get("jobs", {}).items():
|
|
if (job.get("runs-on") in {"alkane-fast", "alkane-pages"}
|
|
and "secrets." in str(job)):
|
|
print(f"{path.name}: {name} exposes a secret to the fast runner", file=sys.stderr)
|
|
return 1
|
|
if job.get("runs-on") not in {"alkane-ci", "alkane-fast", "alkane-verify"}:
|
|
continue
|
|
if job.get("container", {}).get("image") != IMAGE:
|
|
print(f"{path.name}: {name} has a different runner image", file=sys.stderr)
|
|
return 1
|
|
print("OS runner image pins: PASS")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|