fix(ci): package saved Windows builds without Flutter resolution
Gitea CI / Check code and tests (pull_request) Failing after 5m36s
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:
lingjhf committed 2026-10-06 14:07:09 +08:00
1 parent e9d04bea2c
commit 8377e17ef1
5 files changed
+54 -9

No files matched your search

+4 -2
View File
@@ -15,7 +15,7 @@ import sys
import threading
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):
@@ -49,6 +49,8 @@ def main():
if work.exists():
parser.error('Use a new work directory so previous reports cannot pass this test')
work.mkdir(parents=True)
deskup_root = resolved_deskup()
verify_sdk_version()
command = vpk_command(args.vpk)
check_tool(command)
definitions = work / 'defines.json'
@@ -67,7 +69,7 @@ def main():
'name: cutdex_update_smoke\nversion: 1.0.0+1\n'
'environment:\n sdk: ^3.13.4\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')
entry = source / 'tool/testing/windows_update_smoke.dart'
entry.parent.mkdir(parents=True)
+29 -1
View File
@@ -1,14 +1,42 @@
import hashlib
import importlib.util
import json
from pathlib import Path
from unittest.mock import patch
import tempfile
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):
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):
with tempfile.TemporaryDirectory(prefix='deskup package ') as directory:
root = Path(directory)
+14 -6
View File
@@ -15,6 +15,9 @@ from check_windows_release import audit
from update_versions import numeric_version, update_version
ROOT = Path(__file__).resolve().parents[2]
SDK_VERSION = '1.2.161'
def resolved_deskup():
config = ROOT / '.dart_tool/package_config.json'
if not config.is_file():
@@ -27,12 +30,13 @@ def resolved_deskup():
return Path(url2pathname(uri.path))
DESKUP_ROOT = resolved_deskup()
DESKUP_VERSION = re.search(r'^version: ([^\s]+)',
(DESKUP_ROOT / 'pubspec.yaml').read_text(encoding='utf-8'),
re.MULTILINE).group(1)
SDK_VERSION = re.search(r'set\(DESKUP_VELOPACK_VERSION "([^"]+)"\)',
(DESKUP_ROOT / 'windows/velopack.cmake').read_text(encoding='utf-8')).group(1)
def verify_sdk_version():
"""Validate the resolved build SDK before saving the app for later packaging."""
cmake = (resolved_deskup() / 'windows/velopack.cmake').read_text(encoding='utf-8')
match = re.search(r'set\(DESKUP_VELOPACK_VERSION "([^"]+)"\)', cmake)
if not match or match[1] != SDK_VERSION:
raise ValueError(f'Resolved deskup must use Velopack SDK {SDK_VERSION}')
return SDK_VERSION
def vpk_command(path):
@@ -145,6 +149,7 @@ def serve(directory, port):
def main():
parser = argparse.ArgumentParser(description=__doc__)
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.add_argument('--app', type=Path, required=True)
pack.add_argument('--output', type=Path, required=True)
@@ -156,8 +161,11 @@ def main():
args = parser.parse_args()
try:
if args.command == 'pack':
verify_sdk_version()
print(json.dumps(package_app(args.app, args.output, args.vpk,
development=args.development)))
elif args.command == 'verify-sdk':
print(f'Velopack SDK {verify_sdk_version()} verified')
else:
serve(args.directory, args.port)
except KeyboardInterrupt: