Pin Flutter with FVM and share local environment loading across IDE, Python, and Dart entrypoints. Keep CI on the verified preinstalled SDK and skip local overrides. Extract common build presets, process execution, and file hashing. Propagate project roots through SDK selection and release commands, and migrate macOS release, signing, and DMG orchestration to Python. Reuse local check suites in CI, support Android source overrides, and update documentation and regression tests.
88 lines
4.1 KiB
Python
88 lines
4.1 KiB
Python
"""Build and relocate a Release smoke app; exercise no-model and configured-model startup.
|
|
|
|
The JSON config supplies WHISPER_SOURCE, M2M100_SOURCE, MELBAND_SOURCE and
|
|
CUTDEX_ASR_FIXTURE. Models are copied into the app-managed resource layout.
|
|
Run build_macos_release.py afterwards to produce the normal application.
|
|
"""
|
|
import argparse
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import sys
|
|
from functools import partial
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
from project_tools import project_environment, tool_command
|
|
from common.process import cli, run as run_command
|
|
from release import sign_app
|
|
|
|
run = partial(run_command, timeout=900)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--runtime', type=Path, required=True)
|
|
parser.add_argument('--config', type=Path, required=True)
|
|
parser.add_argument('--report', type=Path, required=True)
|
|
args = parser.parse_args()
|
|
repo = Path(__file__).resolve().parents[2]
|
|
config = json.loads(args.config.read_text(encoding='utf-8'))
|
|
model_keys = ['WHISPER_SOURCE', 'M2M100_SOURCE', 'MELBAND_SOURCE']
|
|
for key in model_keys + ['CUTDEX_ASR_FIXTURE']:
|
|
if not Path(config[key]).is_absolute() or not Path(config[key]).exists():
|
|
raise ValueError(f'Missing absolute input path: {key}')
|
|
runtime = args.runtime.resolve()
|
|
environment = project_environment()
|
|
run(tool_command('flutter', ['build', 'macos', '--release',
|
|
'--flavor=production', '--target=tool/testing/release_smoke.dart']), cwd=repo, env=environment)
|
|
with tempfile.TemporaryDirectory(prefix='cutdex relocated release ') as temporary:
|
|
root = Path(temporary)
|
|
app = root / 'cutdex.app'
|
|
run(['/usr/bin/ditto', repo / 'build/macos/Build/Products/Release-production/cutdex.app', app])
|
|
# A previous release build may have embedded a different runtime.
|
|
embedded = app / 'Contents/Resources/processing'
|
|
if embedded.exists():
|
|
shutil.rmtree(embedded)
|
|
run(['/usr/bin/ditto', runtime, embedded])
|
|
sign_app(app, environment=environment)
|
|
run([sys.executable, repo / 'tool/macos/check_macos_release.py', '--app', app], env=environment)
|
|
results = []
|
|
for configured in [False, True]:
|
|
home = root / ('with-models' if configured else 'without-models')
|
|
home.mkdir()
|
|
report = home / 'result.json'
|
|
env = {'PATH': '/usr/bin:/bin', 'HOME': str(home), 'TMPDIR': str(home),
|
|
'CUTDEX_SMOKE_REPORT': str(report), 'CUTDEX_SMOKE_MODELS': str(int(configured)),
|
|
'CUTDEX_SMOKE_MEDIA': config['CUTDEX_ASR_FIXTURE']}
|
|
# No CUTDEX_PROCESSING_ROOT: exercise the executable-relative Bundle default.
|
|
if configured:
|
|
processing = home / 'Documents/Cutdex/Resources/Processing'
|
|
shutil.copytree(config['WHISPER_SOURCE'],
|
|
processing / 'Transcription/whisper-turbo/1')
|
|
shutil.copytree(config['M2M100_SOURCE'],
|
|
processing / 'Translation/m2m100-418m/1')
|
|
vocals = processing / 'VocalSeparation/melband/1'
|
|
vocals.mkdir(parents=True)
|
|
shutil.copy2(config['MELBAND_SOURCE'], vocals / 'melband.pt')
|
|
with (home / 'app.log').open('w') as log:
|
|
try:
|
|
run([app / 'Contents/MacOS/cutdex'], env=env, stdout=log, stderr=subprocess.STDOUT)
|
|
except Exception:
|
|
print((home / 'app.log').read_text())
|
|
if report.exists():
|
|
print(report.read_text())
|
|
raise
|
|
result = json.loads(report.read_text())
|
|
if not result['passed']:
|
|
raise RuntimeError(result)
|
|
results.append(result)
|
|
args.report.parent.mkdir(parents=True, exist_ok=True)
|
|
args.report.write_text(json.dumps(results, indent=2) + '\n')
|
|
print('Release smoke passed: no models; three configured capabilities and real translation.')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(cli(main))
|