1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-10-12 10:58:59 +00:00
trezor-firmware/ci/prepare_ui_artifacts.py

22 lines
588 B
Python
Raw Normal View History

2019-12-30 13:09:18 +00:00
import hashlib
import shutil
from pathlib import Path
2020-01-06 14:44:30 +00:00
def _hash_files(path):
files = path.iterdir()
2019-12-30 13:09:18 +00:00
hasher = hashlib.sha256()
for file in sorted(files):
2020-01-06 14:44:30 +00:00
hasher.update(file.read_bytes())
2019-12-30 13:09:18 +00:00
return hasher.digest().hex()
2020-01-06 14:44:30 +00:00
fixture_root = Path().cwd() / "../tests/ui_tests/fixtures/"
2019-12-30 13:09:18 +00:00
2020-01-06 14:44:30 +00:00
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)