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

ci(translation-tests): verify reproducibility of gettext machine objects #6953

Merged
merged 4 commits into from
Sep 28, 2023

Conversation

cfm
Copy link
Member

@cfm cfm commented Sep 27, 2023

Status

Ready for review

Description of Changes

Testing

Just like freedomofpress/securedro-client#1666:

  • 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 a subprocess.CalledProcessError for return code 127.

Deployment

CI-only; no deployment considerations.

@cfm cfm force-pushed the i18n-verify-mos branch 3 times, most recently from aaebd0b to 71774a7 Compare September 27, 2023 22:50
cfm added 2 commits September 27, 2023 17:00
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.
@cfm cfm force-pushed the i18n-verify-mos branch 4 times, most recently from 66c1f83 to f5b02f7 Compare September 28, 2023 02:10
cfm added 2 commits September 27, 2023 19:20
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/
@cfm cfm marked this pull request as ready for review September 28, 2023 02:28
@cfm cfm requested a review from a team as a code owner September 28, 2023 02:28
@cfm cfm requested a review from nathandyer September 28, 2023 02:28
@cfm cfm added this to the SecureDrop 2.7.0 milestone Sep 28, 2023
Copy link
Contributor

@nathandyer nathandyer left a 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 a subprocess.CalledProcessError for return code 127.

@cfm cfm merged commit 2b25283 into develop Sep 28, 2023
@cfm
Copy link
Member Author

cfm commented Sep 28, 2023

Thanks, @nathandyer!

@cfm cfm mentioned this pull request Sep 29, 2023
41 tasks
@@ -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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

@legoktm legoktm deleted the i18n-verify-mos branch October 3, 2023 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants