Gitea CI / Check code and tests (pull_request) Failing after 8m56s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 4s
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.
71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
"""Select PR compilation and packaging scope from the complete Git change set."""
|
|
|
|
import os
|
|
from pathlib import Path, PurePosixPath
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def packaging_change(path):
|
|
path = path.lower()
|
|
return (
|
|
path.startswith(('.gitea/', '.github/workflows/', '.github/actions/',
|
|
'tool/', 'android/', 'windows/',
|
|
'packages/cutdex_native/android/',
|
|
'packages/cutdex_native/windows/',
|
|
'lib/integrations/app_update',
|
|
'lib/features/settings/update'))
|
|
or PurePosixPath(path).name in {'pubspec.yaml', 'pubspec.lock', '.metadata', '.fvmrc'}
|
|
or (path.startswith('test/') and 'update' in path)
|
|
)
|
|
|
|
|
|
def documentation_change(path):
|
|
path = PurePosixPath(path.lower())
|
|
return (
|
|
str(path).startswith(('docs/', '.github/issue_template/'))
|
|
or str(path) == '.github/pull_request_template.md'
|
|
or (len(path.parts) == 1 and path.suffix in {'.md', '.rst'})
|
|
or (len(path.parts) == 1 and path.name in {'license', 'notice'})
|
|
or (str(path).startswith('packages/') and path.name == 'readme.md')
|
|
)
|
|
|
|
|
|
def select_scope(event, paths):
|
|
paths = list(paths)
|
|
if event != 'pull_request' or not paths or any(packaging_change(path) for path in paths):
|
|
return {'build-app': True, 'package-app': True}
|
|
return {'build-app': not all(documentation_change(path) for path in paths),
|
|
'package-app': False}
|
|
|
|
|
|
def changed_paths(base, head):
|
|
for sha in (base, head):
|
|
if not re.fullmatch(r'[0-9a-f]{40}', sha):
|
|
raise ValueError('PR base and head must be full Git commit SHAs')
|
|
result = subprocess.run(
|
|
['git', 'diff', '--name-only', '--no-renames', '-z', f'{base}...{head}'],
|
|
check=True, capture_output=True,
|
|
)
|
|
return result.stdout.decode('utf-8', errors='surrogateescape').rstrip('\0').split('\0') if result.stdout else []
|
|
|
|
|
|
def main():
|
|
event = os.environ['CI_EVENT_NAME']
|
|
paths = changed_paths(os.environ.get('CI_PR_BASE_SHA', ''),
|
|
os.environ.get('CI_PR_HEAD_SHA', '')) if event == 'pull_request' else []
|
|
scope = select_scope(event, paths)
|
|
with Path(os.environ['GITHUB_OUTPUT']).open('a', encoding='utf-8') as stream:
|
|
for name, enabled in scope.items():
|
|
stream.write(f'{name}={str(enabled).lower()}\n')
|
|
print(f"CI scope: compile={scope['build-app']}, package={scope['package-app']}")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
main()
|
|
except (KeyError, ValueError, subprocess.CalledProcessError) as error:
|
|
print(f'Cannot determine CI scope: {error}', file=sys.stderr)
|
|
sys.exit(1)
|