refactor(core): own editor UI and pin verified native releases
Gitea CI / Check code and tests (pull_request) Failing after 8s
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 1s
Gitea CI / Check code and tests (pull_request) Failing after 8s
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 1s
This commit is contained in:
1 parent
796a3852a2
commit
38ca180cf7
354 files changed
+29841
-642
No files matched your search
@@ -0,0 +1,77 @@
|
||||
"""Expose exact application dependencies to CI or update development commit pins."""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
DEPENDENCIES = ('core', 'nativeFlutter')
|
||||
|
||||
|
||||
def validate_pins(pins):
|
||||
if pins.get('schemaVersion') != 1:
|
||||
raise ValueError('Unsupported application dependency lock schema.')
|
||||
for name in DEPENDENCIES:
|
||||
pin = pins[name]
|
||||
if not re.fullmatch(r'[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+', pin['repository']):
|
||||
raise ValueError(f'{name}: invalid repository identity.')
|
||||
if not re.fullmatch(r'[a-f0-9]{40}', pin['revision']):
|
||||
raise ValueError(f'{name}: dependency must pin a full commit SHA.')
|
||||
reference = pin.get('ref', pin['revision'])
|
||||
if reference != pin['revision'] and reference != 'v' + pin.get('version', ''):
|
||||
raise ValueError(f'{name}: release ref must match the recorded version.')
|
||||
if reference != pin['revision'] and not re.fullmatch(r'\d+\.\d+\.\d+', pin['version']):
|
||||
raise ValueError(f'{name}: invalid release version.')
|
||||
return pins
|
||||
|
||||
|
||||
def write_outputs(pins, output):
|
||||
validate_pins(pins)
|
||||
for name in DEPENDENCIES:
|
||||
pin = pins[name]
|
||||
for key in ('repository', 'revision'):
|
||||
output.write(f'{name}-{key}={pin[key]}\n')
|
||||
output.write(f"{name}-ref={pin.get('ref', pin['revision'])}\n")
|
||||
|
||||
|
||||
def verify_checkouts(pins):
|
||||
validate_pins(pins)
|
||||
for name, directory in (('core', 'cutdex_core'), ('nativeFlutter', 'cutdex_native_flutter')):
|
||||
revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'],
|
||||
cwd=ROOT / '.dependencies' / directory, text=True).strip()
|
||||
if revision != pins[name]['revision']:
|
||||
raise ValueError(f'{name}: checkout does not match the recorded commit.')
|
||||
print('Both dependency checkouts match their recorded commits.')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--core', type=Path, help='Update the core pin from this committed checkout')
|
||||
parser.add_argument('--native-flutter', type=Path, help='Update the native Flutter pin from this committed checkout')
|
||||
parser.add_argument('--verify', action='store_true', help='Verify CI dependency checkouts match the recorded commits')
|
||||
args = parser.parse_args()
|
||||
path = ROOT / 'dependencies.json'
|
||||
pins = json.loads(path.read_text())
|
||||
if args.core or args.native_flutter:
|
||||
for name, checkout in (('core', args.core), ('nativeFlutter', args.native_flutter)):
|
||||
if checkout:
|
||||
sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=checkout, text=True).strip()
|
||||
manifest = 'native-dependencies.json' if name == 'nativeFlutter' else 'native-flutter-dependency.json'
|
||||
subprocess.check_output(['git', 'show', f'{sha}:{manifest}'], cwd=checkout)
|
||||
pubspec = subprocess.check_output(['git', 'show', f'{sha}:pubspec.yaml'], cwd=checkout, text=True)
|
||||
pins[name].update(revision=sha, version=re.search(r'^version:\s*(\S+)\s*$', pubspec, re.M)[1])
|
||||
pins[name].pop('ref', None)
|
||||
validate_pins(pins)
|
||||
path.write_text(json.dumps(pins, indent=2) + '\n')
|
||||
print('Updated committed application dependency pins.')
|
||||
elif args.verify:
|
||||
verify_checkouts(pins)
|
||||
else:
|
||||
with Path(os.environ['GITHUB_OUTPUT']).open('a', encoding='utf-8') as output:
|
||||
write_outputs(pins, output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user