Clean OS CI outputs after build and release
next-build / build (push) Canceled after 0s

This commit is contained in:
2026-10-15 11:48:14 -06:00
parent 59249d44d3
commit 96dd7bf6d2
5 changed files with 110 additions and 0 deletions
+7
View File
@@ -7,6 +7,8 @@ on:
jobs:
verify-and-release:
runs-on: alkane-ci
env:
CARGO_TARGET_DIR: target
permissions:
contents: write
actions: write
@@ -28,6 +30,8 @@ jobs:
run: python3 ci/test-conformance.py
- name: Release publication checks
run: python3 ci/test-release.py
- name: CI cleanup containment checks
run: python3 ci/test-cleanup-generated.py
- name: Quality
run: cargo clippy --all-targets --locked -- -D warnings
- name: Build
@@ -101,3 +105,6 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python3 ci/release.py "${{ steps.version.outputs.tag }}" false "dist/alkane-os-${{ steps.version.outputs.version }}-source.tar.gz" dist/alkane-os dist/bench-current.txt
- name: Clean generated build and benchmark work
if: always()
run: python3 ci/cleanup-generated.py
+5
View File
@@ -7,6 +7,8 @@ on:
jobs:
build:
runs-on: alkane-ci
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v4
with:
@@ -27,3 +29,6 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python3 ci/release.py "${{ steps.version.outputs.tag }}" true "dist/alkane-os-${{ steps.version.outputs.version }}-source.tar.gz" dist/alkane-os
- name: Clean generated candidate build
if: always()
run: python3 ci/cleanup-generated.py
+6
View File
@@ -0,0 +1,6 @@
# Alkane OS working rules
- Keep the project MIT-licensed and preserve third-party licenses in vendored dependencies.
- Use run-scoped Cargo output for one-off work. In CI, set `CARGO_TARGET_DIR=target` and remove generated target, coverage, benchmark, and release staging after artifact publication, including failed runs.
- Keep the main release gate on all seven boards, all 64 same-vendor pairings, unmodified stock firmware evidence, and genuine pool acceptance from real captured silicon nonces. Do not promote host-only probes to board conformance.
- No emojis in files or persisted text.
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
"""Remove generated Alkane OS CI files after tests and release upload."""
import os
from pathlib import Path
import shutil
import sys
ROOT = Path(__file__).resolve().parents[1]
DIRECTORIES = ("target", "coverage", "dist", "bench-site")
FILES = ("tests-current.txt", "bench-current.txt")
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}")
if __name__ == "__main__":
try:
cleanup()
except (OSError, ValueError) as error:
print(f"ERROR: Alkane OS cleanup: {error}", file=sys.stderr)
raise SystemExit(1)
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
"""Verify cleanup removes only generated files inside the CI checkout."""
import importlib.util
import os
from pathlib import Path
import tempfile
from unittest.mock import patch
SPEC = importlib.util.spec_from_file_location(
"cleanup_generated", Path(__file__).resolve().with_name("cleanup-generated.py"))
CLEANUP = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(CLEANUP)
def main() -> None:
with tempfile.TemporaryDirectory(prefix="alkane-os-cleanup-") as temporary:
root = Path(temporary)
outside = root.parent / (root.name + "-outside")
outside.mkdir()
(outside / "keep").write_bytes(b"safe")
previous = CLEANUP.ROOT
CLEANUP.ROOT = root
try:
with patch.dict(os.environ, {"GITHUB_RUN_ID": "123"}):
(root / "target").mkdir()
(root / "target/build").write_bytes(b"generated")
(root / "bench-current.txt").write_bytes(b"generated")
CLEANUP.cleanup()
assert not (root / "target").exists()
assert not (root / "bench-current.txt").exists()
(root / "target").symlink_to(outside, target_is_directory=True)
try:
CLEANUP.cleanup()
except ValueError:
pass
else:
raise AssertionError("cleanup followed a symlink")
assert (outside / "keep").read_bytes() == b"safe"
finally:
CLEANUP.ROOT = previous
(outside / "keep").unlink()
outside.rmdir()
print("Alkane OS CI cleanup containment: PASS")
if __name__ == "__main__":
main()