Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby 3.0] fix failing CI checks by supporting open-uri on Ruby 2.4 #18405

Merged
merged 4 commits into from
Mar 18, 2021

Conversation

ainame
Copy link
Contributor

@ainame ainame commented Mar 17, 2021

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

Prior to this PR, I fixed deprecation warnings around the usage of open-uri in #18395 (as a part of #17931). However the alternative URI.open isn't supported on Ruby 2.4 apparently馃槩 So this PR is adding a helper method that chose either URI.open or URI.parse(...).open depending on Ruby version.

Description

It's a simple helper method. I added tests to make sure all of the Ruby versions we support can perform FastlaneCore::Helper.open_uri.

Testing Steps

It's done by RSpec.

@google-cla google-cla bot added the cla: yes label Mar 17, 2021
@ainame ainame changed the title [Ruby 3.0] Fix failing CI checks by supporting open-uri on Ruby 2.4 [Ruby 3.0] fix failing CI checks by supporting open-uri on Ruby 2.4 Mar 17, 2021
@ainame ainame requested a review from joshdholtz March 17, 2021 04:34
# URI.open added by `require 'open-uri'` is not available in Ruby 2.4. This helper lets you open a URI
# by choosing appropriate interface to do so depending on Ruby version. This helper is subject to be removed
# when fastlane drops Ruby 2.4 support.
def self.open_uri(*rest, &block)
Copy link
Member

Choose a reason for hiding this comment

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

Sweeeeet dependency isolation 鉂わ笍

end

it 'performs URI.open with block' do
is_called_block = false
Copy link
Member

Choose a reason for hiding this comment

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

Maybe is_block_called or did_call_block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did_call_block reminds me UIKit's convention 馃槀 Will change it to the former one.

fastlane_core/spec/helper_spec.rb Show resolved Hide resolved
@ainame
Copy link
Contributor Author

ainame commented Mar 17, 2021

It turned out that unit tests failed actually but the PR was marked as "All checks have passed" due to the issue I fixed in https://github.com/fastlane/fastlane/pull/18398馃槀 The PR to replace Kernel.open didn't include the fix for CI. The timing was bad 馃檲

Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>
@rogerluan
Copy link
Member

There are many ways to fix that timing issue :) we could enforce all PRs to contain the latest master before being mergeable (via GitHub branch settings), or also configure CI to run "PR builds" which merge master into the branch (locally only, in CI) before running checks 馃槃

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

This is 馃敟 Thanks fo fixing this so quickly 鉂わ笍

@joshdholtz joshdholtz merged commit ad3e51c into fastlane:master Mar 18, 2021
@ainame ainame deleted the open-uri-helper branch March 18, 2021 09:50
@ainame
Copy link
Contributor Author

ainame commented Mar 18, 2021

There are many ways to fix that timing issue :) we could enforce all PRs to contain the latest master before being mergeable (via GitHub branch settings), or also configure CI to run "PR builds" which merge master into the branch (locally only, in CI) before running checks 馃槃

In this case, only the former one could solve this issue as the PR was created before the fix goes into the master branch but the solution would need help from auto-merge tools in order to start adopting馃檪

@fastlane-bot
Copy link

Hey @ainame 馃憢

Thank you for your contribution to fastlane and congrats on getting this pull request merged 馃帀
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 馃憤
We'll notify you once we shipped a new release with your changes 馃殌

@fastlane-bot
Copy link

Congratulations! 馃帀 This was released as part of fastlane 2.179.0 馃殌

@fastlane fastlane locked and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants