优化 Gitea 并行构建、重试与 Windows 更新发布 #5
No files matched your search
@@ -24,6 +24,9 @@ the runner user's `%LOCALAPPDATA%/Cutdex/ci-tools/`. Later builds reuse them aft
|
|||||||
version checks. Python interpreter identity and tool versions isolate the cache,
|
version checks. Python interpreter identity and tool versions isolate the cache,
|
||||||
and a mutex protects installation across concurrent workflows. .NET setup remains
|
and a mutex protects installation across concurrent workflows. .NET setup remains
|
||||||
in the Windows packaging job to provide SDK 10 and the runtime required by `vpk`.
|
in the Windows packaging job to provide SDK 10 and the runtime required by `vpk`.
|
||||||
|
The Windows build verifies that the resolved deskup native SDK matches the pinned
|
||||||
|
Velopack version before saving the app. Packaging imports no Flutter package
|
||||||
|
configuration and independently verifies the installed vpk version.
|
||||||
|
|
||||||
APK and Windows package uploads use `compression-level: 0` to avoid recompressing
|
APK and Windows package uploads use `compression-level: 0` to avoid recompressing
|
||||||
already compressed artifacts. The saved Windows app uses compression level 1,
|
already compressed artifacts. The saved Windows app uses compression level 1,
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ jobs:
|
|||||||
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
|
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
|
||||||
flutter build windows --no-pub --release --flavor production
|
flutter build windows --no-pub --release --flavor production
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' }
|
if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' }
|
||||||
|
- name: Verify native SDK matches pinned packaging tools
|
||||||
|
run: |
|
||||||
|
python tool/windows/windows_updates.py verify-sdk
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Windows native SDK version validation failed.' }
|
||||||
- name: Save Windows app for independent packaging retries
|
- name: Save Windows app for independent packaging retries
|
||||||
uses: ./.gitea/actions/upload-artifact
|
uses: ./.gitea/actions/upload-artifact
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from windows_updates import DESKUP_ROOT, ROOT, check_tool, pack_release, update_version, vpk_command
|
from windows_updates import ROOT, check_tool, pack_release, resolved_deskup, update_version, verify_sdk_version, vpk_command
|
||||||
|
|
||||||
|
|
||||||
class TestHandler(SimpleHTTPRequestHandler):
|
class TestHandler(SimpleHTTPRequestHandler):
|
||||||
@@ -49,6 +49,8 @@ def main():
|
|||||||
if work.exists():
|
if work.exists():
|
||||||
parser.error('Use a new work directory so previous reports cannot pass this test')
|
parser.error('Use a new work directory so previous reports cannot pass this test')
|
||||||
work.mkdir(parents=True)
|
work.mkdir(parents=True)
|
||||||
|
deskup_root = resolved_deskup()
|
||||||
|
verify_sdk_version()
|
||||||
command = vpk_command(args.vpk)
|
command = vpk_command(args.vpk)
|
||||||
check_tool(command)
|
check_tool(command)
|
||||||
definitions = work / 'defines.json'
|
definitions = work / 'defines.json'
|
||||||
@@ -67,7 +69,7 @@ def main():
|
|||||||
'name: cutdex_update_smoke\nversion: 1.0.0+1\n'
|
'name: cutdex_update_smoke\nversion: 1.0.0+1\n'
|
||||||
'environment:\n sdk: ^3.13.4\n'
|
'environment:\n sdk: ^3.13.4\n'
|
||||||
'dependencies:\n flutter:\n sdk: flutter\n'
|
'dependencies:\n flutter:\n sdk: flutter\n'
|
||||||
f' deskup:\n path: {DESKUP_ROOT.as_posix()}\n'
|
f' deskup:\n path: {deskup_root.as_posix()}\n'
|
||||||
'flutter:\n uses-material-design: true\n', encoding='utf-8')
|
'flutter:\n uses-material-design: true\n', encoding='utf-8')
|
||||||
entry = source / 'tool/testing/windows_update_smoke.dart'
|
entry = source / 'tool/testing/windows_update_smoke.dart'
|
||||||
entry.parent.mkdir(parents=True)
|
entry.parent.mkdir(parents=True)
|
||||||
|
|||||||
@@ -1,14 +1,42 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
import importlib.util
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from windows_updates import resolved_deskup, numeric_version, pack_release, update_version, validate_previous, verify_manifest
|
from windows_updates import SDK_VERSION, check_tool, resolved_deskup, numeric_version, pack_release, update_version, validate_previous, verify_manifest, verify_sdk_version
|
||||||
|
|
||||||
|
|
||||||
class UpdatePublicationTests(unittest.TestCase):
|
class UpdatePublicationTests(unittest.TestCase):
|
||||||
|
def test_packaging_module_imports_in_clean_checkout_without_flutter_config(self):
|
||||||
|
spec = importlib.util.spec_from_file_location('isolated_windows_updates',
|
||||||
|
Path(__file__).with_name('windows_updates.py'))
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
with patch.object(Path, 'is_file', return_value=False):
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
self.assertEqual(module.SDK_VERSION, SDK_VERSION)
|
||||||
|
|
||||||
|
def test_packaging_tool_check_does_not_resolve_flutter_dependencies(self):
|
||||||
|
from subprocess import CompletedProcess
|
||||||
|
with patch('windows_updates.resolved_deskup', side_effect=AssertionError('No Flutter config')), \
|
||||||
|
patch('windows_updates.subprocess.run', return_value=CompletedProcess([], 0, f'vpk {SDK_VERSION}', '')):
|
||||||
|
check_tool(['vpk'])
|
||||||
|
|
||||||
|
def test_build_sdk_check_rejects_mismatched_and_missing_versions(self):
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
root = Path(directory)
|
||||||
|
cmake = root / 'windows/velopack.cmake'
|
||||||
|
cmake.parent.mkdir()
|
||||||
|
with patch('windows_updates.resolved_deskup', return_value=root):
|
||||||
|
for contents in ('set(DESKUP_VELOPACK_VERSION "9.9.9")', ''):
|
||||||
|
cmake.write_text(contents)
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Resolved deskup must use'):
|
||||||
|
verify_sdk_version()
|
||||||
|
cmake.write_text(f'set(DESKUP_VELOPACK_VERSION "{SDK_VERSION}")')
|
||||||
|
self.assertEqual(verify_sdk_version(), SDK_VERSION)
|
||||||
|
|
||||||
def test_deskup_is_located_from_resolved_package_config(self):
|
def test_deskup_is_located_from_resolved_package_config(self):
|
||||||
with tempfile.TemporaryDirectory(prefix='deskup package ') as directory:
|
with tempfile.TemporaryDirectory(prefix='deskup package ') as directory:
|
||||||
root = Path(directory)
|
root = Path(directory)
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ from check_windows_release import audit
|
|||||||
from update_versions import numeric_version, update_version
|
from update_versions import numeric_version, update_version
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[2]
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
SDK_VERSION = '1.2.161'
|
||||||
|
|
||||||
|
|
||||||
def resolved_deskup():
|
def resolved_deskup():
|
||||||
config = ROOT / '.dart_tool/package_config.json'
|
config = ROOT / '.dart_tool/package_config.json'
|
||||||
if not config.is_file():
|
if not config.is_file():
|
||||||
@@ -27,12 +30,13 @@ def resolved_deskup():
|
|||||||
return Path(url2pathname(uri.path))
|
return Path(url2pathname(uri.path))
|
||||||
|
|
||||||
|
|
||||||
DESKUP_ROOT = resolved_deskup()
|
def verify_sdk_version():
|
||||||
DESKUP_VERSION = re.search(r'^version: ([^\s]+)',
|
"""Validate the resolved build SDK before saving the app for later packaging."""
|
||||||
(DESKUP_ROOT / 'pubspec.yaml').read_text(encoding='utf-8'),
|
cmake = (resolved_deskup() / 'windows/velopack.cmake').read_text(encoding='utf-8')
|
||||||
re.MULTILINE).group(1)
|
match = re.search(r'set\(DESKUP_VELOPACK_VERSION "([^"]+)"\)', cmake)
|
||||||
SDK_VERSION = re.search(r'set\(DESKUP_VELOPACK_VERSION "([^"]+)"\)',
|
if not match or match[1] != SDK_VERSION:
|
||||||
(DESKUP_ROOT / 'windows/velopack.cmake').read_text(encoding='utf-8')).group(1)
|
raise ValueError(f'Resolved deskup must use Velopack SDK {SDK_VERSION}')
|
||||||
|
return SDK_VERSION
|
||||||
|
|
||||||
|
|
||||||
def vpk_command(path):
|
def vpk_command(path):
|
||||||
@@ -145,6 +149,7 @@ def serve(directory, port):
|
|||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
commands = parser.add_subparsers(dest='command', required=True)
|
commands = parser.add_subparsers(dest='command', required=True)
|
||||||
|
commands.add_parser('verify-sdk', help='Verify resolved native SDK before saving a build')
|
||||||
pack = commands.add_parser('pack', help='Package a complete audited release; never uploads')
|
pack = commands.add_parser('pack', help='Package a complete audited release; never uploads')
|
||||||
pack.add_argument('--app', type=Path, required=True)
|
pack.add_argument('--app', type=Path, required=True)
|
||||||
pack.add_argument('--output', type=Path, required=True)
|
pack.add_argument('--output', type=Path, required=True)
|
||||||
@@ -156,8 +161,11 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
try:
|
try:
|
||||||
if args.command == 'pack':
|
if args.command == 'pack':
|
||||||
|
verify_sdk_version()
|
||||||
print(json.dumps(package_app(args.app, args.output, args.vpk,
|
print(json.dumps(package_app(args.app, args.output, args.vpk,
|
||||||
development=args.development)))
|
development=args.development)))
|
||||||
|
elif args.command == 'verify-sdk':
|
||||||
|
print(f'Velopack SDK {verify_sdk_version()} verified')
|
||||||
else:
|
else:
|
||||||
serve(args.directory, args.port)
|
serve(args.directory, args.port)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
Reference in new issue
Block a user