Ship MIT notices with published outputs and keep runtime credentials, configuration and history out of source archives. Audit working files, staged blobs and reachable history before publication. Refs #19
41 lines
1.9 KiB
Python
41 lines
1.9 KiB
Python
"""Check release assembly and manifest versions without invoking NativeAOT."""
|
|
import contextlib
|
|
import io
|
|
import json
|
|
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
from unittest.mock import patch
|
|
import xml.etree.ElementTree as ET
|
|
import zipfile
|
|
|
|
import publish
|
|
|
|
|
|
class PublishTests(unittest.TestCase):
|
|
def test_published_manifest_uses_shared_version(self):
|
|
def fake_publish(command, **kwargs):
|
|
stage = Path(command[command.index('-o') + 1])
|
|
stage.mkdir(parents=True)
|
|
(stage / (stage.name + '.exe')).write_bytes(b'synthetic executable')
|
|
|
|
with tempfile.TemporaryDirectory(prefix='finaltoken-publish-test-') as temporary:
|
|
output = Path(temporary) / 'package'
|
|
with patch('sys.argv', ['publish.py', 'win-x64', '--out', str(output)]), \
|
|
patch.object(publish.subprocess, 'run', side_effect=fake_publish), \
|
|
contextlib.redirect_stdout(io.StringIO()):
|
|
publish.main()
|
|
version = ET.parse(Path(publish.__file__).resolve().parent.parent / 'Directory.Build.props').findtext('.//Version')
|
|
self.assertIsNotNone(version)
|
|
manifest = json.loads((output / 'streamdeck/de.finalfactory.finaltoken.sdPlugin/manifest.json').read_text(encoding='utf-8'))
|
|
self.assertEqual(version + '.0', manifest['Version'])
|
|
license_text = (Path(publish.__file__).resolve().parent.parent / 'LICENSE').read_text(encoding='utf-8')
|
|
self.assertEqual(license_text, (output / 'LICENSE').read_text(encoding='utf-8'))
|
|
self.assertEqual(license_text, (output / 'streamdeck/de.finalfactory.finaltoken.sdPlugin/LICENSE').read_text(encoding='utf-8'))
|
|
with zipfile.ZipFile(output.with_suffix('.zip')) as bundle:
|
|
self.assertEqual(license_text, bundle.read('LICENSE').decode('utf-8'))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|