diff --git a/ci/deploy.yml b/ci/deploy.yml index 565ebd69e..3e2ca8fdc 100644 --- a/ci/deploy.yml +++ b/ci/deploy.yml @@ -194,3 +194,18 @@ upgrade tests legacy deploy: - branches # run for tags only tags: - deploy + +# UI tests + +ui tests core fixtures deploy: + stage: deploy + variables: + DEPLOY_PATH: "${DEPLOY_BASE_DIR}/ui_tests/" + before_script: [] # no pipenv + dependencies: + - core unix device ui test + script: + - echo "Deploying to $DEPLOY_PATH" + - rsync --delete -va ci/tmp/* "$DEPLOY_PATH" + tags: + - deploy diff --git a/ci/prepare_ui_artifacts.py b/ci/prepare_ui_artifacts.py new file mode 100644 index 000000000..d18be4bb7 --- /dev/null +++ b/ci/prepare_ui_artifacts.py @@ -0,0 +1,30 @@ +import hashlib +import shutil +from pathlib import Path + + +def _hash_files(files): + hasher = hashlib.sha256() + for file in sorted(files): + with open(file, "rb") as f: + content = f.read() + hasher.update(content) + + return hasher.digest().hex() + + +def _compare_hash(test_dir, hash): + with open(test_dir / "hash.txt", "r") as f: + content = f.read() + assert hash == content + + +fixture_root = Path().cwd() / "../tests/ui_tests/fixtures" + +for test_dir in fixture_root.iterdir(): + if test_dir.is_dir(): + recorded_dir = test_dir / "recorded" + if recorded_dir.exists(): + hash = _hash_files(recorded_dir.iterdir()) + _compare_hash(test_dir, hash) + shutil.make_archive("tmp/" + hash, "zip", recorded_dir) diff --git a/ci/test.yml b/ci/test.yml index f9647386f..3de43bcba 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -47,10 +47,13 @@ core unix device ui test: - cd core - pipenv run make test_emu_ui - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} + - cd ../ci + - pipenv run python prepare_ui_artifacts.py artifacts: - name: core-unix-device-test.log + name: core-unix-device-test paths: - trezor.log + - ci/tmp/ expire_in: 1 week core unix device test: diff --git a/ci/tmp/.gitignore b/ci/tmp/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/ci/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tools/style.py.include b/tools/style.py.include index 4bf5eefa1..5a66afc56 100644 --- a/tools/style.py.include +++ b/tools/style.py.include @@ -4,3 +4,4 @@ ^\./legacy/ ^\./storage/ ^\./tests/ +^\./ci/