-
Notifications
You must be signed in to change notification settings - Fork 8
Add api_url parameter to create_release_backmerge_pull_request
#641
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
62eb6eb to
c18308c
Compare
| FastlaneCore::ConfigItem.new(key: :api_url, | ||
| description: 'The GitHub API URL to use for creating the pull request. Primarily used when working with GitHub Enterprise instances', | ||
| optional: true, | ||
| type: String), |
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 wonder if it'd make more sense to reference the ConfigItem from the original create_pull_request action, filtering on the parameters we want to just forward, instead of duplicating them (and tiehr optional. description, type,…) ourselves?
i.e.
FORWARDED_PARAM_KEYS = %i[api_token api_bearer repo labels api_url assignees reviewers team_reviewers].freeze
def self.available_options
forwarded_params = Fastlane::Actions::CreatePullRequestAction.available_options.select do |opt|
FORWARDED_PARAM_KEYS.include?(opt.key)
end
[
*forwarded_params,
# Then here only add the params that are specific to our `create_release_backmerge_pull_request` action
# that are not directly forwarded to `create_pull_request`
FastlaneCore::ConfigItem.new(key: :source_branch,
…And then when we call the create_pull_request in the implementation of our action, we can inject the forwarded params by constructing a hash of fwd_params = FORWARDED_PARAMS_KEYS.to_h { |k| [k, params[k] } then inject it in create_pull_request(title: …, body: …, **fwd_params)
wdyt?
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 liked the idea and implemented it... but then the tests started to fail mysteriously due to an additional call to git rev-parse --abbrev-ref HEAD, and some default values also failed (i.e. nil vs. []) 😓 so this is something to consider when implementing this pattern. Eventually I got it working, though! Updated on 21adece.
|
💡 While we're fixing this action, it'd be nice if, when we push the intermediate branch on line L123/R126 ( This would especially be useful not only to note if new commits have been pushed on remote but not on local etc… but also so that the local working copy can detect when the remote branch has been deleted (i.e. the PR has been merged) when the |
7c6b226 to
079709b
Compare
Good idea 👍 Updated on 4795969. |
|
@iangmaia Another fix we need to do (and test, probably using some live example not just specs) is wrapping the call to the Another solution is for the caller to use |
Isn't |
Yes, which is the path in which fastlane is expecting your See this section in the doc which explains it all To my rough understanding, this is also why
Is it convoluted implementation and logic? Yes, definitievly… but that's what you get when there's lots of legacy and you don't want to break millions of codebases by changing that suddenly 😅 |
…termediate_branch_created_callback`
Ahh, TIL 😅 Thanks a lot for the details, it all makes sense now 👍 this is the kind of implementation detail I never got into before with Fastlane (or only end up seeing add-hoc when this kind of issue arises).
💯 I've just pushed daff906. |
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 via https://github.tumblr.net/Tumblr/ios/pull/29539/files, after:
- Creating a dummy
release/100.0branch - Making its
Gemfilepoint to this branch of therelease-toolkit, - removing the
ENV[…]workaround we had for the API URL, and adding theapi_url:parameter to the action call instead - Tweaking the code called in the
intermediate_branch_created_callbackblock to force a dummy change (so we have something to commit) then calling thegit_commitaction from it - Finally, run
bundle exec fastlane backmerge_release_branch
And I was able to confirm that:
- The
api_urlparameter was properly forwarded and allowed to create the PR on our private GH:E instance - The
merge/release-100.0-into-developintermediate branch was set up to track the remote branch after it being pushed to the remote - The call to
git_commitaction worked, without erroring with "not a git repo" as it was before.
🎉
CHANGELOG.md with the extra stuff that this PR fixes (in addition to the item you initially created the PR for).
| - Make fastlane log actions as collapsible groups in Buildkite. [#638] | ||
| - Add `api_url` parameter to `create_release_backmerge_pull_request` to support GitHub Enterprise. [#641] | ||
|
|
||
| ### Bug Fixes |
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.
You should also add an entry under ### Bug Fixes to mention that the calling another fastlane action from the intermediate_branch_created_callback proc now behaves correctly.
CHANGELOG.md
Outdated
| ### New Features | ||
|
|
||
| - Make fastlane log actions as collapsible groups in Buildkite. [#638] | ||
| - Add `api_url` parameter to `create_release_backmerge_pull_request` to support GitHub Enterprise. [#641] |
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.
Could be worth mentioning (probably in the same list item) that the intermediate branch that action creates is also now tracking the remote branch?
What does it do?
Currently, the action
create_release_backmerge_pull_requestdoes not take anapi_urlto forward to Fastlane'screate_pull_requestaction.api_urlis required when dealing with GitHub Enterprise.This PR adds the
api_urlparameter.Checklist before requesting a review
bundle exec rubocopto test for code style violations and recommendations.specs/*_spec.rb) if applicable.bundle exec rspecto run the whole test suite and ensure all your tests pass.CHANGELOG.mdfile to describe your changes under the appropriate existing###subsection of the existing## Trunksection.MIGRATION.mdfile to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.