feat: integrate Orven workspace and engineering repairs for 1.25.9
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"""Verify separate source/program releases without accessing installed user data."""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path, PurePosixPath
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
source_receipt, output = sys.argv[1:]
|
||||
release = json.loads(Path('releases/latest.json').read_text(encoding='utf-8'))
|
||||
source = json.loads(Path(source_receipt).read_text(encoding='utf-8'))
|
||||
program_root = Path(release['portableRoot'])
|
||||
program = json.loads((program_root / 'MANIFEST.json').read_text(encoding='utf-8'))
|
||||
assert source['sourceCommit'] == release['documentation']['sourceCommit']
|
||||
assert source['version'] == program['version']
|
||||
result = {'success': True, 'version': source['version'], 'sourceCommit': source['sourceCommit'], 'archives': []}
|
||||
for kind, receipt, manifest, top in [
|
||||
('program', release['portable'], program, program_root.name),
|
||||
('source', source, source, 'Agent-Workbench-' + source['version'] + '-source'),
|
||||
]:
|
||||
archive_path = Path(receipt['path'])
|
||||
assert archive_path.stat().st_size == receipt['bytes']
|
||||
assert hashlib.sha256(archive_path.read_bytes()).hexdigest() == receipt['sha256']
|
||||
expected = {entry['path']: entry for entry in manifest['files']}
|
||||
assert len(expected) == len(manifest['files'])
|
||||
if kind == 'program':
|
||||
contents = (program_root / 'MANIFEST.json').read_bytes()
|
||||
expected['MANIFEST.json'] = {'bytes': len(contents), 'sha256': hashlib.sha256(contents).hexdigest()}
|
||||
seen = set()
|
||||
with zipfile.ZipFile(archive_path) as bundle:
|
||||
assert bundle.testzip() is None
|
||||
for entry in bundle.infolist():
|
||||
name = PurePosixPath(entry.filename.replace('\\', '/'))
|
||||
assert not name.is_absolute() and '..' not in name.parts and name.parts[0] == top
|
||||
if entry.is_dir():
|
||||
continue
|
||||
relative = '/'.join(name.parts[1:])
|
||||
assert relative in expected and relative not in seen, relative
|
||||
contents = bundle.read(entry)
|
||||
assert len(contents) == expected[relative]['bytes'], relative
|
||||
assert hashlib.sha256(contents).hexdigest() == expected[relative]['sha256'], relative
|
||||
if kind == 'program':
|
||||
assert (program_root / relative).read_bytes() == contents, relative
|
||||
seen.add(relative)
|
||||
assert seen == set(expected)
|
||||
result['archives'].append({'kind': kind, 'files': len(seen), 'crc': 'passed', 'everyByteAndSha256': 'passed', 'path': str(archive_path)})
|
||||
Path(output).parent.mkdir(parents=True, exist_ok=True)
|
||||
with Path(output).open('x', encoding='utf-8') as stream:
|
||||
json.dump(result, stream, ensure_ascii=False, indent=2)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
Reference in New Issue
Block a user