Files
baji-vc/gateway/scripts/check-archive.py
T

42 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Portable model-free archive regression: isolated temp root + synthetic persona manifests."""
import json
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
root = Path(__file__).resolve().parents[1]
with tempfile.TemporaryDirectory(prefix='lan-voice-archive-check-') as folder:
stage = Path(folder)
for source in root.glob('*.py'): shutil.copy2(source, stage/source.name)
for name in ('tests','personas','web'):
shutil.copytree(root/name, stage/name, ignore=shutil.ignore_patterns('__pycache__'))
target=stage/'.runtime/personas'; target.mkdir(parents=True)
for name in ('lvbu','yangmi_fiction'):
# Public dummy IDs only; no production profile/reference audio/runtime copied.
(target/(name+'.json')).write_text(json.dumps({'voice_id':'synthetic-'+name}))
runner=r'''
import sys,unittest
sys.path[:0]=['.','tests']
from pathlib import Path
ordered=['test_gateway','test_continuity','test_history','test_v08','test_debug','test_segmentation','test_guests','test_personas','test_face_context','test_gateway_reply_face']
ordered += sorted(p.stem for p in Path('tests').glob('test_*.py') if p.stem not in ordered)
suite=unittest.TestSuite(unittest.defaultTestLoader.loadTestsFromName(name) for name in ordered)
def safe(suite):
result=unittest.TestSuite()
for item in suite:
if isinstance(item,unittest.TestSuite): result.addTest(safe(item))
elif item.id().endswith('.test_silero_silence_and_state'):
# Model artifacts are intentionally absent; never download/load a model in archive checks.
item.setUp=lambda: (_ for _ in ()).throw(unittest.SkipTest('Silero artifact excluded from source archive'))
result.addTest(item)
else: result.addTest(item)
return result
out=unittest.TextTestRunner(verbosity=2).run(safe(suite))
raise SystemExit(not out.wasSuccessful())
'''
raise SystemExit(subprocess.run([sys.executable,'-c',runner],cwd=stage,env={**os.environ,'PYTHONDONTWRITEBYTECODE':'1'}).returncode)