mirror of
https://github.com/trezor/trezor-firmware.git
synced 2026-02-20 00:33:30 +01:00
ci(core): generate per-language UI diffs
[no changelog]
This commit is contained in:
63
ci/make_pull_comment.py
Normal file
63
ci/make_pull_comment.py
Normal file
@@ -0,0 +1,63 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
(RUN_ID, LANGS_JSON) = sys.argv[1:]
|
||||
MAIN, *EXTRA = json.loads(LANGS_JSON)
|
||||
|
||||
REPORT_URL = f"https://data.trezor.io/dev/firmware/ui_report/{RUN_ID}"
|
||||
CI_RUN_URL = f"https://github.com/trezor/trezor-firmware/actions/runs/{RUN_ID}"
|
||||
TEST_TYPES = ["device_test", "click_test", "persistence_test"]
|
||||
MODELS = [
|
||||
"T2T1",
|
||||
"T3B1",
|
||||
"T3T1",
|
||||
"T3W1",
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
# a special marker for finding this comment (via CI)
|
||||
print("<!-- ui-comment-Core -->")
|
||||
print_table(MAIN)
|
||||
if EXTRA:
|
||||
print("\n<details>\n<summary>Translations</summary>")
|
||||
for lang in sorted(EXTRA):
|
||||
print_table(lang)
|
||||
print("\n</details>")
|
||||
|
||||
print(f"\nLatest CI run: [{RUN_ID}]({CI_RUN_URL})")
|
||||
|
||||
|
||||
def print_table(lang):
|
||||
main = f"[main]({REPORT_URL}/{lang}_index.html)"
|
||||
screens = f"[screens]({REPORT_URL}/{lang}_diff.html)"
|
||||
print(f"\n# `{lang}` {main}({screens})\n")
|
||||
|
||||
# Currently, persistence_test is not running with translations
|
||||
test_types = TEST_TYPES if lang == "en" else TEST_TYPES[:-1]
|
||||
|
||||
header = ["model"] + test_types
|
||||
print("|".join(header))
|
||||
print("|".join(["-"] * len(header)))
|
||||
|
||||
for model in MODELS:
|
||||
row = [f"{model}"]
|
||||
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" />'
|
||||
|
||||
test_diff = f"[test]({test_prefix}-index.html)"
|
||||
test_screens = f"[screens]({test_prefix}-differing_screens.html)"
|
||||
|
||||
main_diff = f"[main]({test_prefix}-master_index.html)"
|
||||
main_screens = f"[screens]({test_prefix}-master_diff.html)"
|
||||
|
||||
cell = f"{img} {test_diff}({test_screens}) {main_diff}({main_screens})"
|
||||
row.append(cell)
|
||||
|
||||
print("|".join(row))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
56
ci/make_summary_htmls.py
Normal file
56
ci/make_summary_htmls.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
(SUFFIX, LANGS_JSON, TARGET) = sys.argv[1:]
|
||||
|
||||
LANGS = json.loads(LANGS_JSON)
|
||||
for lang in LANGS:
|
||||
HTML = rf"""<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Master index</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>T2T1</h1>
|
||||
<include src="T2T1-{lang}-core_device_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T2T1-{lang}-core_click_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T2T1-{lang}-core_persistence_test-master_{SUFFIX}.html"></include>
|
||||
|
||||
<h1>T3B1</h1>
|
||||
<include src="T3B1-{lang}-core_device_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T3B1-{lang}-core_click_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T3B1-{lang}-core_persistence_test-master_{SUFFIX}.html"></include>
|
||||
|
||||
<h1>T3T1</h1>
|
||||
<include src="T3T1-{lang}-core_device_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T3T1-{lang}-core_click_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T3T1-{lang}-core_persistence_test-master_{SUFFIX}.html"></include>
|
||||
|
||||
<h1>T3W1</h1>
|
||||
<include src="T3W1-{lang}-core_device_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T3W1-{lang}-core_click_test-master_{SUFFIX}.html"></include>
|
||||
<include src="T3W1-{lang}-core_persistence_test-master_{SUFFIX}.html"></include>
|
||||
|
||||
<script>
|
||||
(() => {{
|
||||
const includes = document.getElementsByTagName('include');
|
||||
[].forEach.call(includes, i => {{
|
||||
let filePath = i.getAttribute('src');
|
||||
fetch(filePath).then(file => {{
|
||||
file.text().then(content => {{
|
||||
i.insertAdjacentHTML('afterend', content);
|
||||
i.remove();
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
with open(f"{TARGET}/{lang}_{SUFFIX}.html", "w") as f:
|
||||
f.write(HTML)
|
||||
Reference in New Issue
Block a user