Adaptive Music v0.8.0 release candidate
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
8c07a468a4
commit
95b0427aa1
48 files changed
+3631
-313
No files matched your search
+36
-1
@@ -2,6 +2,7 @@ import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import stat
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -24,7 +25,7 @@ class ReleaseTests(unittest.TestCase):
|
||||
root=Path(folder);bundle=release.build_release(output=root);first=bundle.read_bytes();release.build_release(output=root)
|
||||
self.assertEqual(first,bundle.read_bytes())
|
||||
with zipfile.ZipFile(bundle) as outer:
|
||||
self.assertTrue({'adaptive-music.zip','module.json','adaptive-music-source.zip','README.md','INSTALL.md','CHANGELOG.md','LICENSE','THIRD-PARTY-NOTICES','SHA256SUMS'}.issubset(outer.namelist()))
|
||||
self.assertTrue({'adaptive-music.zip','module.json','adaptive-music-source.zip','README.md','INSTALL.md','CHANGELOG.md','HANDOFF.md','USER-ACCEPTANCE.md','LICENSE','THIRD-PARTY-NOTICES','SHA256SUMS'}.issubset(outer.namelist()))
|
||||
standalone=json.loads(outer.read('module.json'))
|
||||
for row in outer.read('SHA256SUMS').decode().splitlines():
|
||||
digest,name=row.split(' ',1);self.assertEqual(hashlib.sha256(outer.read(name)).hexdigest(),digest)
|
||||
@@ -39,6 +40,8 @@ class ReleaseTests(unittest.TestCase):
|
||||
if (ROOT/evidence).is_file():
|
||||
self.assertEqual(outer.read(evidence),source.read(f'adaptive-music-source/{evidence}'))
|
||||
release.validate_package(root/'adaptive-music.zip',standalone)
|
||||
self.assertEqual(json.loads((root/'release.json').read_bytes())['runtimeAssetsSHA256'],
|
||||
release.runtime_assets_sha256(root/'adaptive-music.zip'))
|
||||
(root/'licenses').mkdir(exist_ok=True)
|
||||
(root/'licenses/unmanaged.txt').write_text('must not be swept into the release')
|
||||
with self.assertRaises(ValueError):release.build_release(output=root)
|
||||
@@ -58,4 +61,36 @@ class ReleaseTests(unittest.TestCase):
|
||||
with patch.object(release.subprocess,'check_output',side_effect=FileNotFoundError):
|
||||
entries=release.source_entries(manifest)
|
||||
self.assertIn('adaptive-music-source/src/audio/gm-host.mjs',entries)
|
||||
self.assertIn('adaptive-music-source/HANDOFF.md',entries)
|
||||
self.assertIn('adaptive-music-source/USER-ACCEPTANCE.md',entries)
|
||||
self.assertIn('adaptive-music-source/SOURCE_REVISION.txt',entries)
|
||||
|
||||
def test_source_revision_status_distinguishes_checkout_and_generated_manifest(self):
|
||||
manifest=release.release_manifest()
|
||||
with patch.object(release.subprocess,'check_output',return_value=''):
|
||||
self.assertEqual(release.source_revision_status(manifest),'clean Git checkout')
|
||||
generated=release.release_manifest('https://github.com/example/adaptive-music')
|
||||
self.assertIn('generated release manifest',release.source_revision_status(generated))
|
||||
with patch.object(release.subprocess,'check_output',return_value=' M src/file\n'):
|
||||
self.assertIn('base revision',release.source_revision_status(manifest))
|
||||
with patch.object(release.subprocess,'check_output',side_effect=FileNotFoundError):
|
||||
self.assertIn('without Git metadata',release.source_revision_status(manifest))
|
||||
|
||||
def test_package_rejects_unexpected_files_or_replaced_provenance(self):
|
||||
manifest=release.release_manifest()
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
path=Path(folder)/'bad.zip'
|
||||
entries=release.module_entries(manifest)
|
||||
release.write_zip(path,{**entries,'adaptive-music/extra.json':b'{}'})
|
||||
with self.assertRaisesRegex(ValueError,'inventory'):release.validate_package(path)
|
||||
entries['adaptive-music/vendor/provenance.json']=b'{}'
|
||||
release.write_zip(path,entries)
|
||||
with self.assertRaisesRegex(ValueError,'provenance'):release.validate_package(path)
|
||||
entries=release.module_entries(manifest)
|
||||
with zipfile.ZipFile(path,'w') as archive:
|
||||
for name,data in entries.items():
|
||||
info=zipfile.ZipInfo(name)
|
||||
if name.endswith('/LICENSE'):
|
||||
info.external_attr=(stat.S_IFLNK|0o777)<<16
|
||||
archive.writestr(info,data)
|
||||
with self.assertRaisesRegex(ValueError,'inventory'):release.validate_package(path)
|
||||
Reference in new issue
Block a user