https://blueflare.gitea.bluefla.re/alkane-toolkit/ is built from this repo (gh-pages) after every main run: overview, manual, a quality dashboard and the benchmark history, which no longer goes to alkane-benchmarks. The quality grade is now Clippy/rustfmt plus the line-coverage band (the coverage badge's own colour bands), not only the Clippy result, and main CI publishes the full measurement (per-crate and per-file coverage, LOC per crate) as quality.json for the dashboard. README badges link to their pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MIT
|
|
"""Remove generated Toolkit CI work after the release asset is uploaded."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DIRECTORIES = ("target", "dist", "coverage", "bench-site", "site")
|
|
FILES = ("bench-current.txt", "coverage-summary.txt", "quality.json")
|
|
BADGE_FILES = ("bench-baseline.json", "bench-context.json", "quality.json")
|
|
|
|
|
|
def cleanup() -> None:
|
|
if not os.environ.get("GITHUB_RUN_ID"):
|
|
raise ValueError("cleanup is restricted to CI runs")
|
|
for name in DIRECTORIES:
|
|
path = ROOT / name
|
|
if path.is_symlink() or path.parent.resolve() != ROOT.resolve():
|
|
raise ValueError(f"unsafe generated directory: {path}")
|
|
if path.is_dir():
|
|
shutil.rmtree(path)
|
|
print(f"Removed generated directory: {name}")
|
|
elif path.exists():
|
|
raise ValueError(f"expected a generated directory: {path}")
|
|
for name in FILES:
|
|
path = ROOT / name
|
|
if path.is_symlink() or path.parent.resolve() != ROOT.resolve():
|
|
raise ValueError(f"unsafe generated file: {path}")
|
|
if path.is_file():
|
|
path.unlink()
|
|
print(f"Removed generated file: {name}")
|
|
badge_dir = ROOT / "badges"
|
|
if badge_dir.is_symlink():
|
|
raise ValueError("unsafe generated badge directory")
|
|
for name in BADGE_FILES:
|
|
path = badge_dir / name
|
|
if path.is_symlink() or path.parent.resolve() != badge_dir.resolve():
|
|
raise ValueError(f"unsafe generated badge file: {path}")
|
|
if path.is_file():
|
|
path.unlink()
|
|
print(f"Removed generated badge file: {name}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
cleanup()
|
|
except (OSError, ValueError) as error:
|
|
print(f"ERROR: Toolkit cleanup: {error}", file=sys.stderr)
|
|
raise SystemExit(1)
|