refactor(build): 统一本地与 CI 构建入口及平台发布工具 (#9)
Gitea CI / Check code and tests (push) Successful in 7m38s
Gitea CI / Build Android APK (push) Successful in 6m20s
Gitea CI / Audit and package Windows x64 (push) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (push) Canceled after 0s
Gitea CI / Gitea CI passed (push) Canceled after 0s
Gitea CI / Build Windows x64 app (push) Canceled after 14m42s

This commit was merged in pull request #9.
This commit is contained in:
lingjhf committed 2026-10-06 16:14:42 +00:00
1 parent a13a54d5ec
commit 4a759d81a6
61 files changed
+1913 -388

No files matched your search

+40 -1
View File
@@ -2,6 +2,7 @@
import base64
from pathlib import Path
import plistlib
import subprocess
import tempfile
import unittest
from unittest.mock import patch
@@ -51,6 +52,44 @@ class UpdateConfigurationTests(unittest.TestCase):
class PublicationVersionTests(unittest.TestCase):
def test_publication_writes_signed_archive_and_preserves_feed_on_tool_failure(self):
for failure in (False, True):
with self.subTest(failure=failure), tempfile.TemporaryDirectory() as directory:
output = Path(directory)
feed = output / 'appcast.xml'
original = (f'<rss xmlns:sparkle="{SPARKLE}"><channel><item>'
'<sparkle:version>1</sparkle:version>'
'</item></channel></rss>').encode()
feed.write_bytes(original)
generated = (f'<rss xmlns:sparkle="{SPARKLE}"><channel><item>'
'<sparkle:version>2</sparkle:version>'
'<enclosure sparkle:edSignature="test-signature"/>'
'</item></channel></rss>').encode()
def generate(command, *, cwd, check):
self.assertEqual(cwd, Path.cwd())
self.assertTrue(check)
if command[0] == 'ditto':
Path(command[-1]).write_bytes(b'archive')
elif failure:
raise subprocess.CalledProcessError(19, command)
else:
Path(command[command.index('-o') + 1]).write_bytes(generated)
with patch('macos_updates.validate_app', return_value={'CFBundleVersion': '2'}), \
patch('macos_updates.run', side_effect=generate):
if failure:
with self.assertRaises(subprocess.CalledProcessError) as raised:
publish(Path('app'), output, 'https://example.com/', Path('tools'))
self.assertEqual(raised.exception.returncode, 19)
self.assertEqual(feed.read_bytes(), original)
self.assertEqual(list(output.glob('*.zip')), [])
else:
archive = publish(Path('app'), output, 'https://example.com/', Path('tools'))
self.assertEqual(archive.read_bytes(), b'archive')
self.assertEqual(feed.read_bytes(), generated)
self.assertFalse((output / 'appcast.xml.pending').exists())
def test_older_or_equivalent_build_cannot_replace_current_feed(self):
for current, candidate in [('900002', '900001'), ('2', '2.0'), ('2.10', '2.9')]:
with self.subTest(current=current, candidate=candidate), tempfile.TemporaryDirectory() as directory:
@@ -70,7 +109,7 @@ class PublicationVersionTests(unittest.TestCase):
'<enclosure sparkle:edSignature="test-signature"/>'
'</item></channel></rss>')
with patch('macos_updates.validate_app', return_value={'CFBundleVersion': candidate}), \
patch('macos_updates.subprocess.run', side_effect=generate) as run:
patch('macos_updates.run', side_effect=generate) as run:
with self.assertRaisesRegex(ValueError, 'newer'):
publish(Path('app'), output, 'https://example.com/', Path('tools'))
run.assert_not_called()