add documents
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import hashlib
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
root = Path('C:/git/MagnetismHeroes')
|
||||
record_path = root / 'artifacts/verification/VisualUpgrade/FinalProduct/completion.json'
|
||||
record = json.loads(record_path.read_text(encoding='utf-8-sig'))
|
||||
assert record['sourceCommit'] == '3346eb559bdfba24332feb4d9be4b7104520233e'
|
||||
failed = [phase for phase in record['phases'] if phase['phase'] == 'AndroidSmoke']
|
||||
assert len(failed) == 1 and failed[0]['exitCode'] == 1 and failed[0]['status'] == 'failed'
|
||||
destination = root / 'artifacts/verification/VisualUpgrade/HorizonFailedSmokeAttempt1'
|
||||
files = list((root / 'artifacts/verification/Final/Fresh30').rglob('*'))
|
||||
files += [root / relative for relative in [
|
||||
'artifacts/verification/Final/androidsmoke-evidence.json',
|
||||
'artifacts/verification/Final/androidsmoke.log',
|
||||
'artifacts/verification/Final/android-final-evidence.json',
|
||||
'artifacts/verification/VisualUpgrade/FinalProduct/completion.json',
|
||||
'artifacts/verification/VisualUpgrade/FinalProduct/androidsmoke-outer.log',
|
||||
'artifacts/verification/VisualUpgrade/FinalProduct/android-readiness.json',
|
||||
]]
|
||||
manifest = {'status': 'preserved-failed-attempt', 'sourceCommit': record['sourceCommit'], 'phaseExitCode': 1, 'files': []}
|
||||
for source in sorted(set(path for path in files if path.is_file())):
|
||||
relative = source.relative_to(root)
|
||||
target = destination / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
digest = hashlib.sha256(source.read_bytes()).hexdigest()
|
||||
if target.exists():
|
||||
assert hashlib.sha256(target.read_bytes()).hexdigest() == digest, str(target)
|
||||
else:
|
||||
shutil.copy2(source, target)
|
||||
assert hashlib.sha256(target.read_bytes()).hexdigest() == digest, str(target)
|
||||
manifest['files'].append({'path': relative.as_posix(), 'sha256': digest, 'bytes': source.stat().st_size})
|
||||
(destination / 'manifest.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8')
|
||||
for field in ['evidence', 'outerLog']:
|
||||
original = Path(failed[0][field])
|
||||
failed[0][field + 'OriginalPath'] = str(original)
|
||||
failed[0][field] = str(destination / original.relative_to(root))
|
||||
record_path.write_text(json.dumps(record, indent=2) + '\n', encoding='utf-8')
|
||||
print(json.dumps({'status': 'preserved', 'files': len(manifest['files']), 'phaseExitCode': 1}))
|
||||
Reference in New Issue
Block a user