47 lines
1.9 KiB
Python
47 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0CI native-root cleanup guardrails."""
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--root", type=Path, required=True)
|
|
root = parser.parse_args().root
|
|
|
|
|
|
class Phase10CIGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0ci-native-sdk-bottleneck-and-cleanup-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_result(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0ch-native-wsl-sdl-materializer-one-shot-gate.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10ch_manifest_sha256"])
|
|
result = self.data["consumed_attempt"]
|
|
self.assertEqual(result["timeout_seconds"], 600)
|
|
self.assertTrue(result["all_preconfigure_operations_completed"])
|
|
self.assertTrue(result["successful_symbol_try_compile_observed"])
|
|
|
|
def test_cleanup_only(self) -> None:
|
|
cleanup = self.data["cleanup"]
|
|
self.assertEqual(cleanup["exact_root"], "/tmp/chimera-gfx-phase10ch")
|
|
self.assertTrue(cleanup["git_worktree_remove_first"])
|
|
self.assertFalse(cleanup["automatic_retry"])
|
|
auth = self.data["authorizations"]
|
|
self.assertTrue(auth["exact_native_root_cleanup_authorized"])
|
|
for key, value in auth.items():
|
|
if key != "exact_native_root_cleanup_authorized":
|
|
self.assertFalse(value, key)
|
|
|
|
def test_no_timeout_increase(self) -> None:
|
|
self.assertFalse(self.data["decision"]["timeout_increase_allowed"])
|
|
self.assertEqual(self.data["sdk_observation"]["total_bytes"], 29406271)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|