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:
1 parent
a13a54d5ec
commit
0343e2f723
57 files changed
+1858
-375
No files matched your search
+33
-19
@@ -1,33 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check repository tooling without building, signing, or publishing an app."""
|
||||
"""Check code, application/package tests and tools without building or publishing an app."""
|
||||
import argparse
|
||||
import ast
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
from project_tools import ROOT, host_bash, project_environment, tool_command
|
||||
from common.process import cli, run as run_command
|
||||
|
||||
|
||||
def run(command):
|
||||
print('+ ' + ' '.join(map(str, command)), flush=True)
|
||||
subprocess.run(command, cwd=ROOT, check=True)
|
||||
run_command(command)
|
||||
|
||||
|
||||
def main():
|
||||
argparse.ArgumentParser(description=__doc__).parse_args()
|
||||
if sys.version_info < (3, 11):
|
||||
raise SystemExit('Python 3.11 or newer is required for repository tooling.')
|
||||
def check_tools():
|
||||
tool_roots = [ROOT / 'tool', *(ROOT / 'packages').glob('*/tool')]
|
||||
for path in sorted(path for directory in tool_roots for path in directory.rglob('*.py')):
|
||||
ast.parse(path.read_text(encoding='utf-8'), filename=str(path))
|
||||
print('Python syntax: passed', flush=True)
|
||||
bash = shutil.which('bash')
|
||||
bash = host_bash()
|
||||
if bash:
|
||||
for path in sorted(path for directory in tool_roots for path in directory.rglob('*.sh')):
|
||||
run([bash, '-n', str(path)])
|
||||
run([bash, '-n', path.as_posix()])
|
||||
else:
|
||||
print('Shell syntax: skipped (bash unavailable)', flush=True)
|
||||
python = sys.executable
|
||||
@@ -41,14 +36,33 @@ def main():
|
||||
('tool/gitea', 'test_*.py'),
|
||||
]:
|
||||
run([python, '-m', 'unittest', 'discover', '-s', directory, '-p', pattern])
|
||||
flutter = os.environ.get('FLUTTER') or shutil.which('flutter')
|
||||
if not flutter:
|
||||
raise SystemExit('Flutter is required; set FLUTTER to its executable path.')
|
||||
run([flutter, 'analyze', 'lib', 'test', 'integration_test', 'test_driver', 'tool', 'packages'])
|
||||
|
||||
|
||||
def check_analyze():
|
||||
run(tool_command('dart', ['analyze', '--fatal-infos']))
|
||||
|
||||
|
||||
def check_flutter():
|
||||
package_tests = sorted(str(path.relative_to(ROOT)) for path in (ROOT / 'packages').glob('*/test'))
|
||||
if package_tests:
|
||||
run([flutter, 'test', *package_tests])
|
||||
run(tool_command('flutter', ['test', '--reporter', 'expanded', 'test', *package_tests]))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--suite', choices=['all', 'analyze', 'flutter', 'tools'], default='all',
|
||||
help='CI runs the same suites as the default local check')
|
||||
args = parser.parse_args()
|
||||
if sys.version_info < (3, 11):
|
||||
raise SystemExit('Python 3.11 or newer is required for repository tooling.')
|
||||
environment = project_environment()
|
||||
# Cross-language tests and child scripts inherit this same SDK and config.
|
||||
os.environ.clear()
|
||||
os.environ.update(environment)
|
||||
suites = {'analyze': check_analyze, 'flutter': check_flutter, 'tools': check_tools}
|
||||
for name, check in suites.items():
|
||||
if args.suite in ('all', name):
|
||||
check()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
sys.exit(cli(main))
|
||||
Reference in new issue
Block a user