Skip to content

Conversation

@mokagio
Copy link
Contributor

@mokagio mokagio commented Nov 18, 2022

Extracts the script developed in wordpress-mobile/WordPress-iOS#19553 to this plugin so it can be used across multiple repos and iterated upon in isolation.

See wordpress-mobile/WordPress-iOS#19624 for a live demo of the happy behavior and wordpress-mobile/WordPress-iOS#19544 for when it catches errors.

Comment on lines +3 to +4
# Attempts to generate the frozen `.strings` file to gets sent to GlotPress
# after a new release code freeze.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Attempts to generate the frozen `.strings` file to gets sent to GlotPress
# after a new release code freeze.
# Attempts to generate the frozen `.strings` file—which usually gets sent to GlotPress
# after a new release code freeze—to catch potential warnings early on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does genstrings emit warnings? Or errors only? The manpage has no mentions of "error" and only one of "warnings", yet the output we filter for is error:. 🤔

Suggested change
# Attempts to generate the frozen `.strings` file to gets sent to GlotPress
# after a new release code freeze.
# Attempts to generate the frozen `.strings` file—which usually gets sent to GlotPress
# after a new release code freeze—to catch potential errors early on.

I'm mostly asking because, if it does also print warnings, it might be useful to catch them too (and treat them as errors if possible).

Copy link
Contributor

Choose a reason for hiding this comment

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

That is a very good question… that I don't have the answer to 😅

Comment on lines +8 to +9
# The strings generation happens via Fastlane, so we need to install the
# Ruby gems.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's me again with my arguments against that 80-columns thing 😄

I'm not against splitting comments into multiple lines if they are really long (like on line 3-4), but this really starts to look odd to me when we start doing that just for line-wrapping… a single word or two.

I don't have a strict and explicit rule about this though, but instinctively I think that my unconscious reasoning is, if a comment would be close to fit on a single line, and wrapping it at 80 cols would lead to the 2nd line be less than, say 20% of the width of the first line, that feels too unbalanced and odd-looking to me?
So for example, I'm fine with your case on lines 13-14, but find this wrapping on line 8-9 or the one for 19-20 to be a bit unnecessary? 🤷

Anyway, it's just a hot take, nothing blocking, sorry for the rant 😅

mokagio and others added 3 commits November 19, 2022 15:39
These changes had already been discussed in
wordpress-mobile/WordPress-iOS#19553 and applied
in the test PR used for it, but I forgot to cherry pick them back on the
original one.

Once I copied the script over to this project, I did it from the branch
without the improvements.
@mokagio mokagio enabled auto-merge (squash) November 21, 2022 11:23
And argument(s), too.

See conversation with @AliSoftware here
#36 (comment)

You might notice the duplicated `| tee $LOGS` call. I considered DRYing
the code by assigning `bundle exec fastlane ...` to a variable, e.g.
`CMD`, and then do `$CMD | tee $LOGS`, but decided to keep the
duplication because it's minimal and keeps the code, IMHO, clearer.
@mokagio mokagio requested a review from AliSoftware November 23, 2022 18:13
@AliSoftware AliSoftware disabled auto-merge November 23, 2022 18:52
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Left a small nit about good practices around overuse of cat, but not a blocker.
Disabled auto-merge though just in case you want to address it (or not) before merging.

Comment on lines +47 to +49
cat $LOGS \
| sed -ne 's/\[.*\].*genstrings: error: /- /p' \
| sed -e $'s/\x1b\[[0-9;]*m//g' \
Copy link
Contributor

Choose a reason for hiding this comment

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

💄 Nitpick: cat $LOGS | sed -ne $CMD creates two shell processes (one for cat then one for sed) so it's usually a better practice to use sed -ne $CMD $LOGS to use a single shell process (and let sed do the file reading directly, instead of cat doing the file IO and sed doing stdin-piping) instead 🙃

I'm actually kinda surprised that shellcheck didn't automatically suggest you that (is it does warn for similar cases of unnecessary uses of cat) 🤷

Suggested change
cat $LOGS \
| sed -ne 's/\[.*\].*genstrings: error: /- /p' \
| sed -e $'s/\x1b\[[0-9;]*m//g' \
sed -ne 's/\[.*\].*genstrings: error: /- /p' $LOGS \
| sed -e $'s/\x1b\[[0-9;]*m//g' \

(PS: If we want to go even further, I think you could also collapse the to sed invocations into a single invocation with a unified sed command/script doing the replacements all at once… but I'm not convinced that will lead to something super readable, so I'm ok to keep those separate)

@mokagio mokagio merged commit 29a00ae into trunk Nov 24, 2022
@mokagio mokagio deleted the mokagio/genstring-in-ci branch November 24, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants