-
Notifications
You must be signed in to change notification settings - Fork 687
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
ci(translation-tests): verify reproducibility of gettext machine objects #6953
Conversation
aaebd0b
to
71774a7
Compare
From freedomofpress/securedrop-client#1666, from which "verify-mo.py" has been copied verbatim. The "verify-mo" Make target is largely the same, except for some fancy (but temporary) "find" footwork to put "i18n_tool.py"'s outputs where "verify-mo.py" expects them.
66c1f83
to
f5b02f7
Compare
Adapted from freedomofpress/securedrop-client@6fcd4dd. Here we do treat "make verify-mo" as a linter, to avoid running it (over n languages) n times in each of n "translation-tests" jobs.
When typing[1] exc_type as Optional[type[BaseException]], there seems to be no way around "TypeError: 'type' object is not subscriptable" in our current Python 3.8, even using __future__.annotations. [1]: https://adamj.eu/tech/2021/07/04/python-type-hints-how-to-type-a-context-manager/
f5b02f7
to
6d3f427
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great, @cfm! No requested changes from me on the code, and the test plan checks out. I think this is all set.
- CI passes, especially
lint
. -
make verify-mo
succeeds locally. - If you change a random
install_files/ansible-base/roles/tails-config/templates/*.po
file,make verify-mo
fails and highlights the change (because the "original".mo
file for that language now differs from the recompiled one). - If you
pip3 uninstall diffoscope
,make verify-mo
fails with asubprocess.CalledProcessError
for return code127
.
Thanks, @nathandyer! |
@@ -94,6 +94,13 @@ jobs: | |||
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" securedrop/bin/dev-shell \ | |||
bash -c "/opt/venvs/securedrop-app-code/bin/pip3 install --require-hashes -r requirements/python3/develop-requirements.txt && make -C .. lint" | |||
|
|||
- run: | |||
name: Check that translation machine objects are reproducible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be its own step? Can it not be part of the make lint
target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd originally assumed it would be a step in translation-tests
. But it doesn't benefit from translation-tests
's parallelism, since we might as well verify all languages at once, not just supported languages one at a time.
The lint
job seemed like the next best logical place. But I take make lint
itself to be analogous to spellcheck for human-modified files, not machine-generated ones. And I don't see any benefit to running make verify-mo
locally at all. I resisted the temptation to move it into its own job altogether. ;-)
Would you prefer to see this run somewhere else? See also some extra CI bits in #6954.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fast enough that the overhead of re-installing the pip dependencies takes more time than actually running the verification script. I think merging into lint is probably the right option, I'll roll that into my upcoming PR.
Philosophically, I think it doesn't matter what is being linted/tested, rather it's that "lint" is all the fast tools that just analyze code while "test" is slower stuff that does execution, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me!
Status
Ready for review
Description of Changes
securedrop-client
to keep these scripts in sync: chore: makeverify-mo.py
compatible withsecuredrop
securedrop-client#1668i18n_tool.py
#6917Testing
Just like freedomofpress/securedro-client#1666:
lint
.make verify-mo
succeeds locally.install_files/ansible-base/roles/tails-config/templates/*.po
file,make verify-mo
fails and highlights the change (because the "original".mo
file for that language now differs from the recompiled one).pip3 uninstall diffoscope
,make verify-mo
fails with asubprocess.CalledProcessError
for return code127
.Deployment
CI-only; no deployment considerations.