-
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
[Tooling/Cleanup] Cleanup git helpers #206
Conversation
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.
A few nitpicks for your consideration and one very minor actual fix.
Action.sh("./gradlew", validate_translation_command) | ||
|
||
res_dir = File.join(ENV["PROJECT_ROOT_FOLDER"], ENV["PROJECT_NAME"], "src", "main", "res") | ||
Fastlane::Helper::GitHelper.commit(message: "Update translations", files: res_dir, push: true) |
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.
👍
Action.sh("cd #{ENV["PROJECT_ROOT_FOLDER"]}#{ENV["PROJECT_NAME"]} && git add ./build.gradle") | ||
Action.sh("git commit -m \"Bump version number\"") | ||
Action.sh("git push origin HEAD") | ||
def self.commit_version_bump() |
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.
Nice cleanup!
# If `nil`, will cut the new branch from the current commit. Otherwise, will checkout that commit/branch/tag before cutting the branch. | ||
# @param [Bool] push If true, will also push the branch to `origin`, tracking the upstream branch with the local one. | ||
# | ||
def self.create_branch(branch_name, from: nil, push: true) |
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 like that this is now consolidated by its purpose, not it's use case – will definitely help reduce code and complexity!
@@ -7,7 +7,8 @@ def self.run(params) | |||
|
|||
itc_ver = Fastlane::Helper::Ios::VersionHelper.get_build_version() | |||
int_ver = Fastlane::Helper::Ios::VersionHelper.get_internal_version() unless ENV["INTERNAL_CONFIG_FILE"].nil? | |||
Fastlane::Helper::Ios::GitHelper.tag_build(itc_ver, int_ver) | |||
Fastlane::Helper::GitHelper.create_tag(itc_ver) | |||
Fastlane::Helper::GitHelper.create_tag(int_ver) unless int_ver.nil? |
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.
Nitpick, but I wonder if it'd make sense to group the itc_ver
and int_ver
stuff together and only have one conditional? Might make it easier for future readers?
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.
Probably something I will pick up when I tackle #203
Codecov Report
@@ Coverage Diff @@
## toolkit-cleanup #206 +/- ##
===================================================
+ Coverage 44.72% 45.04% +0.31%
===================================================
Files 93 93
Lines 4013 3947 -66
===================================================
- Hits 1795 1778 -17
+ Misses 2218 2169 -49
Continue to review full report at Codecov.
|
No idea why danger is suddenly failing in GitHub Actions?! 🧐 |
e34c727
to
237746d
Compare
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!
I opened this but then realise I don't have enough time for a thorough review right now. I just wanted to drop a not regarding "why not TDD?"
No worries. All the work you're doing is improving this foundational codebase and making it easy to add tests later 👍 In app development, I'd say "Maybe write a few UI tests? Even if they hit the production APIs they'll still give you a bit of trust that nothing major broke during the refactor" There could be a chance to do something similar here. Setup a test repo, install Fastlane, fetch this branch for the plugin, then write a few bash scripts that run the actions and check the how the repository changed. Now that I |
@mokagio I'm merging this to progress on my dependant PR chain but don't hesitate to git it a review even post-merge if want and have time, I can always address any feedback in another PR down the chain ;) |
This PR cleans up all the
ios_git_helper
+android_git_helper
+git_helper
methods: refactoring + YARD doc.Why?
How?
git_helper
commit(message:files:push:)
To Review and Test
That's the trickiest part. This is very hard to test and we don't have
rspec
for most of those methods (see "Why not TDD" below) either.The best we can do is:
bundle exec rspec
to ensure the existing tests still pass (even if there are not many tests covering the changes made there)be yard stats --list-undoc lib/fastlane/plugin/wpmreleasetoolkit/**/*git_helper.rb
to check that everything about git helpers is documented (only items that are undocumented should be theFastlane
,Fastlane::Helper
, andFastlane::Helper::[Ios|Android]
modules)bundle exec yard doc
to generate the doc, thenopen yard-doc/index.html
and inspect the documentation for the helpersPluginfile
to this branch and run a couple of actions (ideally the ones that would not risk having any side-effects) from an app repo to ensure those still work. Unfortunately, most of the actions and helpers impacted here do have side-effects, so that might be tricky…Notes
Please do thorough review 🙏
This PR should be ready to be reviewed, but I pondered about opening it as Draft or not because I didn't proof-read the whole thing after I finished everything.
This means that, for example, a review directly by reading diff in GitHub might not be enough to ensure that I didn't forget to update all call sites… Which is why I'd appreciate a more thorough review of those changes, especially about ensuring that the behavior of helper methods are still unchanged (e.g. a parameter previously expecting just the version number for creating the release branch, but now expecting the full branch name or
release: version
instead…), there are no call sites I forgot to update, and there's no syntax error (e.g. missing comma) that slipped through…(At some point I'd love to add rubocop to at least catch simple things like stupid syntax errors or a missing commas… but that's whole PR on its own…)
Work in Progress
Things that I will probably fix in a separate incremental PR (except if I get to address those before that Draft PR gets its final review…):
git_helpers
, especially the helper methods around metadata+localization, and the one helper method to commit files related to version bumps (which are different set of files depending on the platforms, but are still worth DRYing in a helper rather than moving in each action because there are multiple actions using them)update_metadata
methods (iOS+Android) and thelocalize_project
method (iOS) are still calling non-git-related code (invoking the script).Why not TDD?
I initially considered doing TDD and adding tests first, before refactoring. That's what tests are for after all.
Unfortunately, that ended up being very unproductive, given that the previous state of the code was really not easily testable and the amount of refactoring and thus the amount of methods (that I was gonna add tests for) that I was gonna delete, move and refactor entirely. That would have made any test written prior refactoring be obsolete by the end of it.
I know that it would have been ideal to write the tests prior to refactoring – that's the whole benefit of having tests after all – but that was too cumbersome to do, so I decided to keep the writing of the tests for a future PR addressing #193 .