refactor(build): 统一本地与 CI 构建入口及平台发布工具 (#9)
Gitea CI / Check code and tests (push) Successful in 7m38s
Gitea CI / Build Android APK (push) Successful in 6m20s
Gitea CI / Audit and package Windows x64 (push) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (push) Canceled after 0s
Gitea CI / Gitea CI passed (push) Canceled after 0s
Gitea CI / Build Windows x64 app (push) Canceled after 14m42s

This commit was merged in pull request #9.
This commit is contained in:
lingjhf committed 2026-10-06 16:14:42 +00:00
1 parent a13a54d5ec
commit 4a759d81a6
61 files changed
+1913 -388

No files matched your search

+33 -19
View File
@@ -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))