ci(translate-changelog): verify the translation instead of trusting it - #109
Open
duckhawk wants to merge 1 commit into
Open
ci(translate-changelog): verify the translation instead of trusting it#109duckhawk wants to merge 1 commit into
duckhawk wants to merge 1 commit into
Conversation
deep_translator returns the source string on some backend failures instead of
raising, and the job swallowed that: every line got one attempt, an exception or
a silent passthrough fell back to the Russian text, and the job still exited 0.
The result shipped release changelogs that say 'Changes:' and then list them in
Russian -- 34 of 49 bullets in the last batch of 15 storage-module changelogs,
with only the modules whose bullets were short coming out fully English.
Now every line is retried up to three times with a backoff, a result that still
holds Cyrillic counts as a failure just like an exception, and if any line is
still untranslated the job fails and commits nothing. A red job is better than a
changelog nobody notices is in the wrong language.
Two more things the same failure exposed:
- The English file was generated once and never again ('if eng_path.exists():
sys.exit(0)'), so editing the .ru.yml afterwards silently left the .yml stale,
and the only hint was the misleading 'No Russian changelog to translate (or
English already exists).' An existing .yml is now left alone when it holds no
Cyrillic (a good or hand-written translation) and regenerated when it does.
- Re-running the job died with '! [rejected] ... (non-fast-forward)' because the
branch already carried the translate commit from the first run. The push now
rebases onto the remote branch first, which drops an identical commit as empty
and makes the re-run a no-op.
The files to translate now come from the diff of the last commit (piped in on
stdin) instead of 'whatever v*.ru.yml has the highest version in the directory'.
Verified against a stub backend: flaky-then-ok retries produce a clean file, an
existing clean .yml is untouched, a Cyrillic-tainted .yml is regenerated, a
backend that never translates exits 1, and an empty stdin still falls back to
the directory glob.
Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
Open
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes
templates/Translate_Changelog.gitlab-ci.ymlverify its own output instead oftrusting the translator:
Cyrillic counts as a failure exactly like an exception does;
CHANGELOG/<ver>.ymlis left alone when it holds no Cyrillic (a good orhand-written translation) and regenerated when it does;
of a
non-fast-forwardfailure;v*.ru.ymlhas the highest version in the directory".Why do we need it, and what problem does it solve?
deep_translatorreturns the source string on some backend failures instead of raising,and the job swallowed that: one attempt per line,
except Exception: translated = content,exit 0. So the "English" changelog could ship Russian text under an English
Changes:header, with a green pipeline and an auto-created MR.
That is not theoretical. In the last batch of 15 storage-module changelogs (2026-08-20)
34 of 49 bullets stayed Russian; only the two modules whose bullets happened to be
short (snapshot-controller, sds-elastic) came out fully English. Example of what got
committed and MR'd:
Two more defects surfaced while trying to recover from it:
if eng_path.exists(): sys.exit(0)), sofixing the
.ru.ymlafterwards never refreshed the.yml, and the only hint in the logwas the misleading
No Russian changelog to translate (or English already exists).from the first run, so the retry died with
! [rejected] … (non-fast-forward).What is the expected result?
A changelog branch either gets a fully English
.ymlor a redtranslate-changelogjobthat names the lines it could not translate — never a silently half-Russian release
changelog. Re-running the job on a branch that already has the translation is a no-op, and
a hand-written
.ymlis never clobbered.Verified against a stub backend (no network): flaky-then-ok retries produce a clean file; an
existing clean
.ymlis untouched; a Cyrillic-tainted.ymlis regenerated; a backend thatnever translates exits 1 without committing; empty stdin still falls back to the directory
glob. The template is also YAML-valid (
yaml.safe_load) and the inline Python compiles(
py_compile).Checklist