CI: Add i18n verification step (#69384)

* Add i18n verification step

* Add check for extracted translations

* Run extract

* Add newline for pseudo

* Format JSON output with prettier

* Print file diff

* Actually run make drone

* Only deo git diff on locales

* Update error message

* Verify that step fails on dynamic phrases

* Verify that it passes when fixed

* Verify that dynamic phrase fails, for real this time

* Extract error messages

* Change echo

* Fix string format

* Try double escaping

* Escape for Drone substitution

* Update character escape

* Remove dynamic phrase

* Verify multiple keys

* Remove double keys

* Readd en locale because of reasons

* Undo changes

* Format lint_frontend.star

* Update error message

* Update .drone.yml

* Add quotes for echo

* Verify fail to extract

* Fix diff stat command

* Reset footer changes
This commit is contained in:
Tobias Skarhed
2023-06-06 09:29:04 +02:00
committed by GitHub
parent c46395ad88
commit 134839d701
4 changed files with 61 additions and 5 deletions
@@ -7,6 +7,7 @@ load(
"enterprise_setup_step",
"identify_runner_step",
"lint_frontend_step",
"verify_i18n_step",
"yarn_install_step",
)
load(
@@ -28,6 +29,7 @@ def lint_frontend_pipeline(trigger, ver_mode):
init_steps = []
lint_step = lint_frontend_step()
i18n_step = verify_i18n_step()
if ver_mode == "pr":
# In pull requests, attempt to clone grafana enterprise.
@@ -42,6 +44,7 @@ def lint_frontend_pipeline(trigger, ver_mode):
]
test_steps = [
lint_step,
i18n_step,
]
return pipeline(
+24 -1
View File
@@ -775,11 +775,34 @@ def lint_frontend_step():
"commands": [
"yarn run prettier:check",
"yarn run lint",
"yarn run i18n:compile", # TODO: right place for this?
"yarn run typecheck",
],
}
def verify_i18n_step():
extract_error_message = "\nExtraction failed. Make sure that you have no dynamic translation phrases, such as 't(\\`preferences.theme.\\$${themeID}\\`, themeName)' and that no translation key is used twice. Search the output for '[warning]' to find the offending file."
uncommited_error_message = "\nTranslation extraction has not been committed. Please run 'yarn i18n:extract', commit the changes and push again."
return {
"name": "verify-i18n",
"image": build_image,
"depends_on": [
"yarn-install",
],
"commands": [
"yarn run i18n:extract || (echo \"{}\" && false)".format(extract_error_message),
# Verify that translation extraction has been committed
'''
file_diff=$(git diff --dirstat public/locales)
if [ -n "$file_diff" ]; then
echo $file_diff
echo "{}"
exit 1
fi
'''.format(uncommited_error_message),
"yarn run i18n:compile",
],
}
def test_a11y_frontend_step(ver_mode, port = 3001):
"""Runs automated accessiblity tests against the frontend.