1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-01 19:38:33 +00:00

ci: add UI-specific diff markers for PR comment

This way, we can quickly see if there are any UI diffs found by the tests
(the first round icon) or there are any UI diffs from `main` (the second one).

[no changelog]
This commit is contained in:
Roman Zeyde 2025-07-16 13:30:59 +03:00
parent 6cc9c62941
commit 6cc2d4e7d2
5 changed files with 28 additions and 6 deletions

View File

@ -30,7 +30,7 @@ def main():
def print_table(lang):
main = f"[main]({REPORT_URL}/{lang}_index.html)"
screens = f"[screens]({REPORT_URL}/{lang}_diff.html)"
screens = f"[all]({REPORT_URL}/{lang}_diff.html)"
print(f"\n# `{lang}` {main}({screens})\n")
# Currently, persistence_test is not running with translations
@ -45,15 +45,17 @@ def print_table(lang):
for test_type in test_types:
test_prefix = f"{REPORT_URL}/{model}-{lang}-core_{test_type}"
img = f'<img src="{test_prefix}-status.png" width="20px" height="20px" />'
job_img = f'<img src="{test_prefix}-status.png"/>'
test_diff = f"[test]({test_prefix}-index.html)"
test_screens = f"[screens]({test_prefix}-differing_screens.html)"
test_screens = f"[all]({test_prefix}-differing_screens.html)"
test_img = f'<img src="{test_prefix}-test_diff.png"/>'
main_diff = f"[main]({test_prefix}-master_index.html)"
main_screens = f"[screens]({test_prefix}-master_diff.html)"
main_screens = f"[all]({test_prefix}-master_diff.html)"
main_img = f'<img src="{test_prefix}-main_diff.png"/>'
cell = f"{img} {test_diff}({test_screens}) {main_diff}({main_screens})"
cell = f"{job_img} {test_diff}({test_screens}) {test_img} {main_diff}({main_screens}) {main_img}"
row.append(cell)
print("|".join(row))

View File

@ -1,3 +1,4 @@
import shutil
from pathlib import Path
from typing import Any
@ -36,6 +37,15 @@ LEGACY_MODEL_NAMES = {
}
def get_status_icon(diff: bool) -> Path:
status_icon = "success-diff.png"
if diff:
status_icon = "failure-diff.png"
result = HERE / status_icon
assert result.exists()
return result
def generate_master_diff_report(
diff_tests: dict[TestCase, tuple[str, str]], base_dir: Path
) -> None:
@ -212,6 +222,8 @@ def _differing_screens_report(
i(testcase.id)
html.write(base_dir, doc, "master_diff.html")
status_icon = get_status_icon(unique_differing_screens)
shutil.copy(status_icon, base_dir / "main_diff.png")
def _get_unique_differing_screens(

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

View File

@ -26,7 +26,13 @@ from dominate.util import text
from ..common import FixturesType, TestCase, TestResult
from . import download, html
from .common import REPORTS_PATH, document, generate_master_diff_report, get_diff
from .common import (
REPORTS_PATH,
document,
generate_master_diff_report,
get_diff,
get_status_icon,
)
TESTREPORT_PATH = REPORTS_PATH / "test"
IMAGES_PATH = TESTREPORT_PATH / "images"
@ -240,6 +246,8 @@ def differing_screens() -> None:
i(ui_failure.test.id)
html.write(TESTREPORT_PATH, doc, "differing_screens.html")
status_icon = get_status_icon(recent_ui_failures)
shutil.copy(status_icon, TESTREPORT_PATH / "test_diff.png")
def _get_current_results() -> FixturesType: