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

Add Weblate screenshot uploader tool #5450

Merged
merged 3 commits into from Aug 19, 2020
Merged

Add Weblate screenshot uploader tool #5450

merged 3 commits into from Aug 19, 2020

Conversation

eloquence
Copy link
Member

@eloquence eloquence commented Aug 13, 2020

Uploads all page layout test results via Weblate's API, updating existing screenshots as appropriate.

Status

Ready for review. Towards #3959 (resolves it once we complete a single run in production).

Description of Changes

This is done as a standalone Python script, with the upload portion written as a WeblateUploader class that is as generic as possible, in case it is useful for others solving this problem in other contexts.

Includes documentation for SecureDrop maintainers, and built-in help.

Test plan

  • Ensure unrestricted access to the Weblate sandbox (infra team).
  • Manually delete all screenshots in the sandbox.
  • Obtain a sandbox API token and export it to an environment variable WEBLATE_API_TOKEN
  • Export the sandbox URL to WEBLATE_BASE_URL
  • Generate the screenshots in English via LOCALES=en_US make translation-test
  • Run the tool via securedrop/upload-screenshots.py
  • Observe that a total of 55 screenshots are newly created by checking the count via /api/screenshots/ (the API has a convenient web UI you can use for this)
  • Delete some screenshots, and modify another screenshot in a way that you'll be able to later recognize.
  • Run the tool again.
  • Observe that the screenshots you deleted are re-uploaded, and that the screenshot you modified was modified.

Copy link
Contributor

@rmol rmol left a comment

Choose a reason for hiding this comment

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

This looks fine to me. I think we can probably even handle updates without rewriting in Python.

securedrop/bin/upload-screenshots Outdated Show resolved Hide resolved
@eloquence eloquence moved this from Ready for Review to In Development in SecureDrop Team Board Aug 17, 2020
Uploads all page layout test results via Weblate's API, replacing
existing screenshots as appropriate by matching filenames against
canonicalized titles.
@eloquence eloquence changed the title Add simple Weblate screenshot uploader tool Add Weblate screenshot uploader tool Aug 18, 2020
@eloquence eloquence marked this pull request as ready for review August 18, 2020 04:25
@eloquence eloquence moved this from In Development to Ready for Review in SecureDrop Team Board Aug 18, 2020
@eloquence
Copy link
Member Author

The script is now rewritten in Python, and also handles the updating of existing screenshots. Looking forward to review & perhaps running in prod soon. :)

@rmol rmol moved this from Ready for Review to Under Review in SecureDrop Team Board Aug 18, 2020
rmol
rmol previously approved these changes Aug 18, 2020
Copy link
Contributor

@rmol rmol left a comment

Choose a reason for hiding this comment

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

This works perfectly. I made a couple of suggestions but am approving without requesting the changes. If you want to make them, I'm happy to rereview.

  • Ensure unrestricted access to the Weblate sandbox (infra team).
  • Manually delete all screenshots in the sandbox.
  • Obtain a sandbox API token and export it to an environment variable WEBLATE_TOKEN
  • Export the sandbox URL to SANDBOX_URL
  • Generate the screenshots in English via LOCALES=en_US make translation-test
  • Run the tool via securedrop/upload-screenshots.py --token $WEBLATE_TOKEN --baseURL $SANDBOX_URL
  • Observe that a total of 55 screenshots are newly created by checking the count via /api/screenshots/ (the API has a convenient web UI you can use for this)
  • Delete some screenshots, and modify another screenshot in a way that you'll be able to later recognize.
  • Run the tool again.
  • Observe that the screenshots you deleted are re-uploaded, and that the screenshot you modified was modified.

securedrop/upload-screenshots.py Outdated Show resolved Hide resolved
securedrop/upload-screenshots.py Outdated Show resolved Hide resolved
securedrop/upload-screenshots.py Outdated Show resolved Hide resolved
@rmol rmol merged commit 89103e1 into develop Aug 19, 2020
SecureDrop Team Board automation moved this from Under Review to Done Aug 19, 2020
@rmol rmol deleted the 3959-weblate-uploader branch August 19, 2020 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants