-
Notifications
You must be signed in to change notification settings - Fork 9
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
Allow auto-addition of tools:ignore="UnusedResources"
when merging Android strings
#354
Conversation
@mokagio CI seems to fail on this error, which is not relateed to the changes from this PR, but rather on the helper to find duplicated strings that we recently merged:
No idea why it would fail in this PR (and on my Mac)… but didn't in your PR adding that helper and those specs in the first place… See also my comment on #342 (comment) Can I let you take a closer look during the week? (I'll be AFK until next Tuesday) |
Ended up tackling this on my own today via #357 |
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.
LGTM 👍
Once the unit tests fix from #357 will land in this PR, CI will be green and this will be merge-able.
@AliSoftware since I didn't get to address the test failure and the current merge conflicts are due to my work with #356, I'd be happy to return the favor and solve them here. Let me know.
lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb
Outdated
Show resolved
Hide resolved
spec/an_localize_libs_action_spec.rb
Outdated
# Please consider expanding this test if you'll find yourself working on its | ||
# action. |
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'm glad to see you took on my suggestion to expand the test 🙇♂️
|
Co-authored-by: Gio Lodi <giovanni.lodi42@gmail.com>
e8e6435
to
ba4a46c
Compare
Change of plans, I ended up doing the conflict resolution myself as it was otherwise blocking me to move forward with working on #358 (which had to be built on top of this one to avoid conflicts between the 2 PRs making different improvements but on the same action and specs) |
|
||
expected = [ | ||
'<string name="override-true" content_override="true">from app override-true</string>', | ||
'', '', # FIXME: Current implementation adds empty lines; we should get rid of those at some point |
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 will actually already be addressed by #358 (which builds on top of this PR) 🎉
This PR adds the ability for the
an_localize_libs
action (which mergesstrings.xml
files from libraries into the main one in order to send their strings to translation) to automatically addtools:ignore="UnusedResources"
to the merged strings when appropriate. — as discussed in Slack and Zoom with @ParaskP7Merging strings from binary libraries
When merging
strings.xml
files from binary dependencies (typically precompiled and downloaded from S3), since the linter is unable to detect when a string it sees merged in the app'sstrings.xml
is used in the binary library we pulled it from, we need to addtools:ignore="UnusedResources"
to that merged string, to ensure lint won't complain about it.Merging strings from local modules
When merging
strings.xml
files from local modules (likeimage-editor
orWordPress-Editor
), because we currently have thecheckDependencies true
option enabled for lint in theWordPress/build.gradle
, that means that running lint on the WordPress project will detect when strings merged in thestrings.xml
of the app that are in fact used by the module, and will then not consider them unused.So for that case, the linter complaining that a string merged from one of our local module is unused would be a genuine warning that would indeed warrant manual investigation(†)
Thus, for those local modules, and at least as long as we have
checkDependencies true
set, we should NOT make our tooling addtools:ignore="UnusedResources"
automatically for all the strings merged from those modules.(†) A warning in such a case would not always necessarily mean that the string is indeed unused and could be deleted blindly from that module without priori investigation, because that module could itself declare that string… to override the value of one of its transitive dependency… so we should still investigate such cases manually, and decide to either delete the genuinely unused string from the module, or add
tools:ignore="UnusedResources"
to that string manually if we consider it's expected.Solution
This PR allows the caller of
an_localize_libs
to specify, for each lib, if it should add thetools:ignore="UnusedResources"
attribute automatically when merging the libs' strings or not — via the newadd_ignore_attr: true
option.The implementation made
an_localize_libs
smart enough to also support cases where atools:ignore
attribute would already exist on the string being merged, either in the app'sstrings.xml
or in the lib's one, and merge theUnusedResources
value with the existing value of the attribute.To Test
expected = […]
values I used in each of the unit test would indeed correspond to what we really expect from such a merge and configuration of the actionbundle exec rspec
passes (this one is already run by CI, so checking that CI is green should be enough)