refactor(build): unify SDK configuration and release tooling

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.
This commit is contained in:
lingjhf committed 2026-10-06 23:34:15 +08:00
1 parent a13a54d5ec
commit 0343e2f723
57 files changed
+1858 -375

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
"""Shared process/CLI contracts used by application and platform entrypoints."""
import contextlib
import hashlib
import io
from pathlib import Path
import subprocess
import sys
import tempfile
import unittest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from common.files import file_sha256
from common.process import cli, run
class CommonToolsTests(unittest.TestCase):
def test_process_arguments_directory_and_child_environment_are_preserved(self):
with tempfile.TemporaryDirectory(prefix='cutdex common process ') as directory:
code = "import os,sys; print(os.getcwd()); print(os.environ['CUTDEX_TEST']); print(repr(sys.argv[1:]))"
arguments = ['A&B with spaces', 'with "quotes"', '', '%literal%']
result = run([sys.executable, '-c', code, *arguments], cwd=directory,
env={'CUTDEX_TEST': 'child'}, capture_output=True, text=True)
lines = result.stdout.splitlines()
self.assertEqual(Path(lines[0]), Path(directory))
self.assertEqual(lines[1], 'child')
self.assertEqual(lines[2], repr(arguments))
def test_cli_preserves_child_failure_without_exposing_arguments(self):
def fail():
run([sys.executable, '-c', 'import sys; sys.exit(17)', 'secret-token'], capture_output=True)
with contextlib.redirect_stderr(io.StringIO()) as diagnostics:
self.assertEqual(cli(fail), 17)
self.assertIn('exit 17', diagnostics.getvalue())
self.assertNotIn('secret-token', diagnostics.getvalue())
def test_child_stdout_and_stderr_remain_separate(self):
result = run([sys.executable, '-c', "import sys; print('result'); print('diagnostic', file=sys.stderr)"],
capture_output=True, text=True)
self.assertEqual(result.stdout.strip(), 'result')
self.assertEqual(result.stderr.strip(), 'diagnostic')
def test_cli_reports_validation_failure_without_a_traceback(self):
def fail():
raise ValueError('Release files differ from the audited manifest')
with contextlib.redirect_stderr(io.StringIO()) as diagnostics:
self.assertEqual(cli(fail), 1)
self.assertEqual(diagnostics.getvalue(), 'Release files differ from the audited manifest\n')
def test_streamed_file_hash_matches_binary_contents(self):
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / 'artifact'
payload = bytes(range(256)) * 32768
path.write_bytes(payload)
self.assertEqual(file_sha256(path), hashlib.sha256(payload).hexdigest())
if __name__ == '__main__':
unittest.main()