Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firmware translations #3206

Merged
merged 23 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ba852c9
feat(all): implement translations into Trezor
grdddj Aug 11, 2023
25de933
chore(common): deprecate `language` fields in ApplySettings, ResetDev…
matejcik Jan 31, 2024
10e9439
chore(python): deprecate language setting in apply_settings / reset /…
matejcik Jan 31, 2024
9c03141
refactor(core/rust): move InputStream to its own module
matejcik Jan 15, 2024
93fa277
feat(core/rust): add trezorcrypto bindings
matejcik Jan 22, 2024
a20f524
refactor(core/rust): move iter_into_array to micropython::utils
matejcik Jan 17, 2024
c6160e8
chore(core/rust): move illustration outside src/ tree
matejcik Jan 15, 2024
3f2f98e
docs(core/rust): improve safety comments in buffer.rs
matejcik Jan 15, 2024
04aae11
feat(common): provide some useful paths for the mako templates
matejcik Jan 19, 2024
7860e98
feat(core/rust): add Map::is_empty()
matejcik Jan 19, 2024
67fca70
fix(crypto): add missing header for size_t
matejcik Jan 24, 2024
05c1d91
feat(core/rust): add const Obj::small_int
matejcik Jan 24, 2024
a0c3c57
fix(python): fix model enum aliases
matejcik Jan 24, 2024
931fb4b
chore(python): drop source support for Python 3.6 and 3.7
matejcik Jan 25, 2024
0e07447
build: fix top-level `make gen`
matejcik Jan 25, 2024
28c81da
feat(python): add cosi.sign_with_privkeys
matejcik Jan 31, 2024
6b15446
chore(common): remove useless proto imports
matejcik Feb 2, 2024
582c44c
feat(core/rust): introduce SimpleTypeObj
matejcik Feb 5, 2024
1df2520
fix(core/rust): convert Qstr type to representation that matches C code
matejcik Feb 6, 2024
2c73522
feat(core/rust): expose attrtuple to Rust
matejcik Feb 6, 2024
48315f1
refactor(core/rust): decouple Connect screen from bootloader theme
matejcik Feb 7, 2024
6218bed
refactor(core/rust): reuse the same component for "waiting for host" …
matejcik Feb 7, 2024
df3d1c6
chore(core): add changelog entry for translations
grdddj Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ include:
- ci/build.yml
- ci/test.yml
- ci/test-hw.yml
- ci/test-nonenglish.yml
- ci/posttest.yml
- ci/deploy.yml
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ vendorheader: ## generate vendor header
vendorheader_check: ## check that vendor header is up to date
./core/embed/vendorheader/generate.sh --quiet --check

gen: mocks icons templates protobuf ci_docs vendorheader solana_templates ## regenerate auto-generated files from sources
gen: templates mocks icons protobuf ci_docs vendorheader solana_templates ## regenerate auto-generated files from sources

gen_check: mocks_check icons_check templates_check protobuf_check ci_docs_check vendorheader_check solana_templates_check ## check validity of auto-generated files
gen_check: templates_check mocks_check icons_check protobuf_check ci_docs_check vendorheader_check solana_templates_check ## check validity of auto-generated files
38 changes: 38 additions & 0 deletions ci/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,44 @@ ui tests fixtures deploy:
tags:
- deploy

ui tests fixtures deploy nonenglish:
stage: deploy
variables:
DEPLOY_PATH: "${DEPLOY_BASE_DIR}/ui_tests/"
BUCKET: "data.trezor.io"
GIT_SUBMODULE_STRATEGY: "none"
only:
- schedules # nightly build
- /translations/ # translations branches
before_script: [] # no poetry
interruptible: false
needs:
- core click test czech
- core device test czech
- core device R test czech
- core click R test czech
- core click test german
- core device test german
- core device R test german
- core click R test german
- core click test french
- core device test french
- core device R test french
- core click R test french
- core click test spanish
- core device test spanish
- core device R test spanish
- core click R test spanish
mmilata marked this conversation as resolved.
Show resolved Hide resolved
script:
- echo "Deploying to $DEPLOY_PATH"
- rsync --delete -va ci/ui_test_records/* "$DEPLOY_PATH"
- source ${AWS_DEPLOY_DATA}
- aws s3 sync $DEPLOY_PATH s3://$BUCKET/dev/firmware/ui_tests
# This "hack" is needed because aws does not have an easy option to generate autoindex. We fetch the one autogenerated by nginx on local server.
- wget https://firmware.corp.sldev.cz/ui_tests/ -O index.html && aws s3 cp index.html s3://$BUCKET/dev/firmware/ui_tests/
tags:
- deploy

# sync to aws

sync emulators to aws:
Expand Down
166 changes: 166 additions & 0 deletions ci/make_nonenglish_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
from __future__ import annotations

import re
from dataclasses import dataclass
from pathlib import Path
from typing import Callable

HERE = Path(__file__).resolve().parent

TEST_FILE = HERE / "test-nonenglish.yml"

LANGS = {
"cs": "czech",
"fr": "french",
"de": "german",
"es": "spanish",
}

MODELS = ["T", "R"]


@dataclass
class Replacement:
start: str
end: str
replacement: str


def replace_content_between_markers(
file_path: Path | str, replacements: list[Replacement]
) -> None:
with open(file_path, "r") as file:
content = file.read()

for replace in replacements:
pattern = rf"({replace.start}.*?{replace.end})"
content = re.sub(
pattern,
f"{replace.start}\n{replace.replacement}\n{replace.end}",
content,
flags=re.DOTALL,
)

with open(file_path, "w") as file:
file.write(content)


def get_device_test(lang: str, model: str) -> str:
lang_long = LANGS[lang]

model_or_empty = f" {model}" if model != "T" else ""
model_needs_or_empty = f" {model}" if model != "T" else ""

return f"""\
core device{model_or_empty} test {lang_long}:
stage: test
<<: *gitlab_caching
needs:
- core unix frozen{model_needs_or_empty} debug build
variables:
TREZOR_PROFILING: "1" # so that we get coverage data
TREZOR_MODEL: "{model}"
MULTICORE: "4" # more could interfere with other jobs
TEST_LANG: "{lang}" # {lang_long}
only:
- schedules # nightly build
- /translations/ # translations branches
script:
- $NIX_SHELL --run "poetry run make -C core test_emu_ui_multicore | ts -s"
after_script:
- mv core/src/.coverage.* core # there will be more coverage files (one per core)
- mv tests/ui_tests/reports/test/ test_ui_report
- $NIX_SHELL --run "poetry run python ci/prepare_ui_artifacts.py | ts -s"
- diff -u tests/ui_tests/fixtures.json tests/ui_tests/fixtures.suggestion.json
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
paths:
- ci/ui_test_records/
- test_ui_report
- tests/ui_tests/screens/
- tests/ui_tests/fixtures.suggestion.json
- tests/ui_tests/fixtures.results.json
- tests/junit.xml
- tests/trezor.log
- core/.coverage.*
when: always
expire_in: 1 week
reports:
junit: tests/junit.xml
"""


def get_click_test(lang: str, model: str) -> str:
lang_long = LANGS[lang]

model_or_empty = f" {model}" if model != "T" else ""
model_needs_or_empty = f" {model}" if model != "T" else ""

return f"""\
core click{model_or_empty} test {lang_long}:
stage: test
<<: *gitlab_caching
needs:
- core unix frozen{model_needs_or_empty} debug build
variables:
TREZOR_PROFILING: "1" # so that we get coverage data
TREZOR_MODEL: "{model}"
TEST_LANG: "{lang}" # {lang_long}
only:
- schedules # nightly build
- /translations/ # translations branches
script:
- $NIX_SHELL --run "poetry run make -C core test_emu_click_ui | ts -s"
after_script:
- mv core/src/.coverage core/.coverage.test_click
- mv tests/ui_tests/reports/test/ test_ui_report
- $NIX_SHELL --run "poetry run python ci/prepare_ui_artifacts.py | ts -s"
- diff -u tests/ui_tests/fixtures.json tests/ui_tests/fixtures.suggestion.json
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
paths:
- ci/ui_test_records/
- test_ui_report
- tests/ui_tests/screens/
- tests/ui_tests/fixtures.suggestion.json
- tests/ui_tests/fixtures.results.json
- tests/trezor.log
- tests/junit.xml
- core/.coverage.*
reports:
junit: tests/junit.xml
expire_in: 1 week
when: always
"""


def get_all_tests_text(func: Callable[[str, str], str]) -> str:
text = ""
for model in MODELS:
for lang in LANGS:
content = func(lang, model)
text += content + "\n"
return text


def fill_device_tests() -> None:
replacement = Replacement(
start=r"##START_DEVICE_TESTS",
end=r"##END_DEVICE_TESTS",
replacement=get_all_tests_text(get_device_test),
)
replace_content_between_markers(TEST_FILE, [replacement])


def fill_click_tests() -> None:
replacement = Replacement(
start=r"##START_CLICK_TESTS",
end=r"##END_CLICK_TESTS",
replacement=get_all_tests_text(get_click_test),
)
replace_content_between_markers(TEST_FILE, [replacement])


if __name__ == "__main__":
fill_device_tests()
fill_click_tests()
1 change: 1 addition & 0 deletions ci/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ stdenvNoCC.mkDerivation ({
bash
bloaty # for binsize
check
crowdin-cli # for translations
curl # for connect tests
editorconfig-checker
gcc-arm-embedded
Expand Down
Loading
Loading