supported_v1.py
file-level
1
files
1
commits
0
hotspots
0
🧊 dead
0
💥 blast risk
| 1 | """Run the supported matrix from a source installation, without publication. |
| 2 | |
| 3 | Git CI needs no Muse installation. Combined CI explicitly supplies a separate |
| 4 | Muse venv and verifies the exact package sources used for integration validation. |
| 5 | """ |
| 6 | from pathlib import Path |
| 7 | import argparse |
| 8 | import subprocess |
| 9 | import sys |
| 10 | |
| 11 | KIT = Path(__file__).resolve().parents[2] |
| 12 | MUSE_SOURCE_SHA256 = '7b181b6eff6bde1b53105f2a7be7bd8937224988965d7462a3a6b04658f35e92' |
| 13 | |
| 14 | |
| 15 | def main(): |
| 16 | parser = argparse.ArgumentParser(description=__doc__) |
| 17 | parser.add_argument('--muse-python', type=Path) |
| 18 | parser.add_argument('--junitxml', required=True) |
| 19 | args = parser.parse_args() |
| 20 | # Source snapshots and distribution archives must carry hidden CI/policy |
| 21 | # files. A green suite from an incomplete export is not sufficient. |
| 22 | for relative in ('.github/workflows/supported-v1.yml', '.gitignore', |
| 23 | '.museignore', 'requirements-v1-dev.txt'): |
| 24 | if not (KIT / relative).is_file(): |
| 25 | parser.error('source file missing: ' + relative) |
| 26 | if Path(sys.prefix).resolve() != KIT / '.venv': |
| 27 | parser.error('run with this source installation\'s .venv/bin/python') |
| 28 | command = [sys.executable, '-m', 'pytest', '-q', 'tests/v1', 'tests/retained'] |
| 29 | if args.muse_python: |
| 30 | python = args.muse_python |
| 31 | if (not python.is_absolute() or python.parent.name != 'bin' |
| 32 | or not (python.parent.parent / 'pyvenv.cfg').is_file() |
| 33 | or python.parent.parent.resolve() == Path(sys.prefix).resolve()): |
| 34 | parser.error('--muse-python requires a separate absolute venv executable') |
| 35 | probe = '''from pathlib import Path |
| 36 | import hashlib, importlib.metadata, sys |
| 37 | import muse |
| 38 | assert sys.prefix != sys.base_prefix |
| 39 | assert importlib.metadata.version('muse') == '0.2.1rc5' |
| 40 | root = Path(muse.__file__).resolve().parent |
| 41 | assert root.is_relative_to(Path(sys.prefix).resolve()) |
| 42 | h = hashlib.sha256() |
| 43 | for p in sorted(root.rglob('*.py')): |
| 44 | h.update(p.relative_to(root).as_posix().encode() + b'\\0' + p.read_bytes() + b'\\0') |
| 45 | assert h.hexdigest() == sys.argv[1], 'Muse package source differs from reviewed rc5' |
| 46 | ''' |
| 47 | subprocess.run([str(python), '-I', '-B', '-c', probe, MUSE_SOURCE_SHA256], check=True) |
| 48 | command += ['tests/muse', '--muse-python', str(python)] |
| 49 | command += ['-p', 'no:cacheprovider', '--junitxml', args.junitxml] |
| 50 | return subprocess.call(command, cwd=KIT) |
| 51 | |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | raise SystemExit(main()) |