Files
cutdex/tool/check.py
T
lingjhf 8785eaf095
Gitea CI / Check code and tests (push) Failing after 11m29s
Gitea CI / Build Android APK (push) Skipped
Gitea CI / Build Windows x64 app (push) Skipped
Gitea CI / Audit and package Windows x64 (push) Skipped
Gitea CI / Assemble and validate CI artifacts (push) Skipped
Gitea CI / Gitea CI passed (push) Failing after 2s
Recover releases from independently retried CI packaging (#15)
2026-10-11 20:52:05 +00:00

75 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""Check code, application/package tests and tools without building or publishing an app."""
import argparse
import ast
import os
import sys
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)
run_command(command)
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 = host_bash()
if bash:
for path in sorted(path for directory in tool_roots for path in directory.rglob('*.sh')):
run([bash, '-n', path.as_posix()])
else:
print('Shell syntax: skipped (bash unavailable)', flush=True)
python = sys.executable
run([python, 'tool/check_public_repository.py'])
run([python, 'tool/check_package_boundaries.py'])
for directory, pattern in [
('tool/macos', '*_unit.py'),
('tool/tests', '*_test.py'),
('tool/windows', 'test_check_windows_release.py'),
('tool/windows', '*_unit.py'),
('tool/gitea', 'test_*.py'),
]:
run([python, '-m', 'unittest', 'discover', '-s', directory, '-p', pattern])
def check_analyze():
run(tool_command('dart', ['analyze', '--fatal-infos']))
def check_flutter():
package_tests = sorted(str(path.relative_to(ROOT)) for pattern in ('*/test', '*/example/test')
for path in (ROOT / 'packages').glob(pattern))
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--exclude-tags', 'codegen',
'test', *package_tests]))
# build_runner compiles generators and performs repository-wide file I/O.
# Keep this gate serial with widget tests to avoid competing with their isolates.
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--tags', 'codegen',
'test/generated_code_test.dart']))
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__':
sys.exit(cli(main))