1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-02 04:18:20 +00:00
trezor-firmware/ci/prepare_ui_artifacts.py
2020-01-06 14:59:12 +00:00

22 lines
588 B
Python

import hashlib
import shutil
from pathlib import Path
def _hash_files(path):
files = path.iterdir()
hasher = hashlib.sha256()
for file in sorted(files):
hasher.update(file.read_bytes())
return hasher.digest().hex()
fixture_root = Path().cwd() / "../tests/ui_tests/fixtures/"
for recorded_dir in fixture_root.glob("*/recorded"):
expected_hash = (recorded_dir.parent / "hash.txt").read_text()
actual_hash = _hash_files(recorded_dir)
assert expected_hash == actual_hash
shutil.make_archive("ui_test_records/" + actual_hash, "zip", recorded_dir)