-
Notifications
You must be signed in to change notification settings - Fork 121
[Tooling] Improve new_hotfix_release lane to work when there's no release tag
#16364
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
Conversation
fastlane/Fastfile
Outdated
| Fastlane::Helper::GitHelper.create_branch("release/#{version}", from: previous_version) | ||
| UI.success("Done! New hotfix branch is: #{git_branch}") | ||
| UI.message("Creating hotfix branch from '#{base_ref_for_hotfix}'...") | ||
| Fastlane::Helper::GitHelper.create_branch("release/#{version}", from: base_ref_for_hotfix) |
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.
💡 Add a sh('git', 'fetch', 'origin', base_ref_for_hotfix) call before the create_branch call to make sure that the remote base we're creating the branch from is fetched in the local working copy beforehand.
Otherwise there's a risk that the release/x.y previous branch exists on the remote but hasn't been fetched into the local working copy yet, which will make the create_branch fail. Not sure that will ever happen, but better safe than sorry?
(See my similar comment on other similar PRs in other repos)
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.
Just to mention it here, I've implemented fetching base_ref before creating the branch in all repos (here in 701debb).
c1e8ee9 to
701debb
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.
Tested a few scenarios locally. I didn't take screenshots because of the many logs lines.
I also compared this code with that of other PRs that @AliSoftware previously approved.
The Prototype Build failure in the checks is obviously unrelated and we can ignore it. FWIW, it's a time out on the cleanup stage.
|
@AliSoftware I've implemented the last change we discussed about ensuring the hotfix branch doesn't exist on 458e13d . |
458e13d to
1a9b7f0
Compare
AliSoftware
left a comment
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.
Tested all 4 scenarios (invalid hotfix version number, neither tag nor release branch, no tag but a release branch, tag present) and all worked as expected.
Left a small nit but approving to unblock.
| # Check tags | ||
| UI.user_error!("Version #{version} already exists! Abort!") if git_tag_exists(tag: version) | ||
| UI.user_error!("Version #{previous_version} is not tagged! A hotfix branch cannot be created.") unless git_tag_exists(tag: previous_version) | ||
| UI.user_error!("Version '#{version}' already exists on the remote! Abort!") if git_tag_exists(tag: version, remote: 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.
Nit: wouldn't it make more sense to test this sooner in the lane (e.g. line 422)?
Related to AINFRA-1518
Description
This PR aims to add more robustness and require less manual intervention to the hotfix creation lane
new_hotfix_release.We have observed that sometimes it is possible that the release has been finalized but a release tag isn't present yet for some reason (likely due to the fact that the release hasn't been published yet), so release managers will get an error and require manual intervention.
This PR changes the code so that, if no release tag is present, we start the hotfix branch based on the corresponding release branch.
Testing instructions
These are some test scenarios that can be simulated:
30.6instead of30.6.1(error)To test it, you can create test branches / tags (⚠️ delete them later or, even better, use this technique of pointing your working copy’s ⚠️ ) and run
originremote to a local bare repo insteadbundle exec fastlane new_hotfix_release skip_confirm:false version:"$VERSION"and then answernoafter the prompt so that the lane execution stops and check the printed values.For example:
release/30.6(which doesn't exist and has no corresponding tag for that version)bundle exec fastlane new_hotfix_release skip_confirm:false version:30.6.1release/30.6branch instead of trying to use a tag. It should print: