-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Run genstrings in CI to validate LocalizedString usages
#19553
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/bin/bash -eu | ||
|
|
||
| echo "--- :rubygems: Setting up Gems" | ||
| install_gems | ||
|
|
||
| echo "--- :cocoapods: Setting up Pods" | ||
| install_cocoapods | ||
|
|
||
| echo "--- :writing_hand: Copy Files" | ||
| mkdir -pv ~/.configure/wordpress-ios/secrets | ||
| cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env | ||
|
|
||
| echo "--- Lint Localized Strings Format" | ||
| LOGS=logs.txt | ||
| set +e | ||
| set -o pipefail | ||
| bundle exec fastlane generate_strings_file_for_glotpress skip_commit:true | tee $LOGS | ||
| EXIT_CODE=$? | ||
| set -e | ||
|
|
||
| echo $EXIT_CODE | ||
|
|
||
| if [[ $EXIT_CODE -ne 0 ]]; then | ||
| # Strings generation finished with errors, extract the errors in an easy-to-find section | ||
| echo "--- Report genstrings errors" | ||
| ERRORS=errors.txt | ||
| echo "Found errors when trying to run \`genstrings\` to generate the \`.strings\` files from \`*LocalizedStrings\` calls:" | tee $ERRORS | ||
| echo '' >> $ERRORS | ||
| # Print the errors inline. | ||
| # | ||
| # Notice the second `sed` call that removes the ANSI escape sequences that | ||
| # Fastlane uses to color the output. | ||
| grep -e "\[.*\].*genstrings:" $LOGS \ | ||
| | sed -e 's/\[.*\].*genstrings: error: /- /' \ | ||
AliSoftware marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| | sed -e $'s/\x1b\[[0-9;]*m//g' \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about moving this one
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, without that filter, we get a double match for one of the errors. Take the colored output in the following screenshots: When run through the code without the ANSI color RegEx, it returns As far as I can tell, the reason is because of different terminators between the errors printed in line and the ones at the end of the Fastlane execution. With You can see that the second I'm sure there's a RegEx we can write to work around all this, but it sounds like we'd be hitting the diminishing return threshold.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yeah, I see. Tricky. Nice catch. Let's keep the filter to remove ANSI code early in the command like you did then. Besides, even if we managed to keep the colors while still properly removing duplicates, I don't think there's any case where those error lines use multiple styles (e.g. multiple colors / boldness / … within the line to emphasis some words), and instead all the lines seems to all be in a single style each… either all red or all purple. So we wouldn't end up benefit from keeping the coloring much (and even if we wanted those to appear red in the the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tbh, the nicer solution would probably be to have
And then parse that file to detect and extract the genstrings warnings, without those parsed logs being cluttered by other fastlane logs. Only drawback I see from that is that the plugin command (that this script would be turned into) would have to rely on you not only have a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mokagio How do you want to go forward with this PR?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AliSoftware thanks for asking.
It's, sort of, the best of both worlds. We have something that works and we can ship ASAP, then we can iterate from a centralized place. I say "sort of", because if we go down the path of updating the toolkit, we either use a default value for the log files or we'd have to update all the clients again. Still, give this has the possibility of preventing some issue, I'd say let's ship as is ASAP to get more coverage, then improve on the setup. |
||
| | sort \ | ||
| | uniq \ | ||
| | tee -a $ERRORS | ||
| # Annotate the build with the errors | ||
| cat $ERRORS | buildkite-agent annotate --style error --context genstrings | ||
| fi | ||
|
|
||
| exit $EXIT_CODE | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,3 +123,10 @@ steps: | |
| plugins: *common_plugins | ||
| agents: | ||
| queue: "android" | ||
| # Runs the `.strings` generation automation to ensure all the | ||
| # `LocalizedString` calls in the code can be correctly parsed by Apple's | ||
| # `genstrings`. | ||
| - label: "Lint Localized Strings Format" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not feeling super inspired here tbh… Maybe |
||
| command: .buildkite/commands/lint-localized-strings-format.sh | ||
| plugins: *common_plugins | ||
| env: *common_env | ||


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 line made me go down a rabbit hole thinking about whether we can optimize how we generate the pods cache further #19551.