33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MIT
|
|
"""Publish measured main-branch metric badges to the private badge branch."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from badge_store import publish_file
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
NAMES = ("tests", "coverage", "bench", "bench-coverage", "loc",
|
|
"dependencies", "quality", "license")
|
|
|
|
|
|
def main() -> None:
|
|
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
|
repo = os.environ["GITHUB_REPOSITORY"]
|
|
token = os.environ["GITEA_TOKEN"]
|
|
for name in NAMES:
|
|
data = (ROOT / "badges" / f"{name}.svg").read_bytes()
|
|
if not data.lstrip().startswith(b"<svg"):
|
|
raise ValueError(f"invalid {name} SVG")
|
|
publish_file(api, repo, f"badges/{name}.svg", data, token,
|
|
f"Update measured {name} badge")
|
|
data = (ROOT / "badges/metrics.json").read_bytes()
|
|
publish_file(api, repo, "badges/metrics.json", data, token,
|
|
"Update measured badge data")
|
|
print(f"Published {len(NAMES)} measured badge SVGs and metrics.json")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|