-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Ruby 3.0] Replace obsolete URI.escape with alternatives #18646
Conversation
08183ac
to
3b86635
Compare
3b86635
to
7a3c71f
Compare
! cat ~/test-reports/ruby_warnings.txt | grep -E "warning:\s.*(deprecated).*$" && echo "No deprecation message found." | ||
! cat ~/test-reports/ruby_warnings.txt | grep -E "warning:\s.*(obsolete).*$" && echo "No obsolete message found." |
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 covers "UI.escape is obsolete" message and 3rd party dependencies nowπ
@@ -237,7 +237,7 @@ | |||
<div class="app-screenshot-row"> | |||
|
|||
<% screenshots.each_with_index do |screenshot, index| %> | |||
<a href="<%= URI.escape(screenshot.path) %>" target="_blank"><img class="app-screenshot" src="<%= render_relative_path(@export_path, URI.escape(screenshot.path)) %>" title="Screenshot #<%=index%> for <%=language%>"></a> | |||
<a href="<%= render_relative_path(@export_path, Addressable::URI.encode(screenshot.path)) %>" target="_blank"><img class="app-screenshot" src="<%= render_relative_path(@export_path, Addressable::URI.encode(screenshot.path)) %>" title="Screenshot #<%=index%> for <%=language%>"></a> |
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 link was actually brokenπ
I fixed it by adding render_relative_path
5ede484
to
6fd103e
Compare
6fd103e
to
2dce790
Compare
name: brew update if needed # temporary solution for this https://discuss.circleci.com/t/macos-image-users-homebrew-brownout-2021-04-26/39872/2 | ||
command: | | ||
# if the version is not 3.x.x, try brew update | ||
ruby -e 'exit(1) if `brew -v` =~ /2\.\d+\.\d+/' ||\ | ||
brew update || \ | ||
# if brew update fails due to shallow clone, try unshallowing and then brew update again | ||
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow && \ | ||
brew update |
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.
https://discuss.circleci.com/t/macos-image-users-homebrew-brownout-2021-04-26/39872/2
Apparently, CircleCI provides both old and new macOS images so that some builds succeed with Homebrew v3 others fails with Homebrew v2π This way brew update
will be called only when a build picks up an old macOS image that has Homebrew v2. This can fall back to unshallow command when the initial attempt of brew update
fails.
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 is insane π Love it β€οΈ
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 explanation of the rationale behind your decisions in the PR description πͺ
LGTM! π
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π great work as always! You rock!β€οΈ
Thank you both! |
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.
π₯ as always! Thank you π₯°
name: brew update if needed # temporary solution for this https://discuss.circleci.com/t/macos-image-users-homebrew-brownout-2021-04-26/39872/2 | ||
command: | | ||
# if the version is not 3.x.x, try brew update | ||
ruby -e 'exit(1) if `brew -v` =~ /2\.\d+\.\d+/' ||\ | ||
brew update || \ | ||
# if brew update fails due to shallow clone, try unshallowing and then brew update again | ||
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow && \ | ||
brew update |
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 is insane π Love it β€οΈ
Congratulations! π This was released as part of fastlane 2.183.0 π |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validMotivation and Context
As per #17931, I've been working on Ruby 3.0 support. Prior to this, I've fixed most deprecation warnings from Ruby 2.7 #18021. It now prevents PRs from making new warnings by checking them in CircleCI.
fastlane/.circleci/config.yml
Lines 106 to 111 in 72ff4fc
However, there is still another type of deprecation warning introduced in Ruby 1.9;
warning: URI.escape is obsolete
. This message bypassed the above checkπ I recognised this warning before but didn't knowURI.escape
was finally removed in Ruby 3.0 until I run fastlane on Ruby 3.0, which became possible after #18599.This PR replace
URI.escape
with some alternatives. Some of them were fixed in this PR previously #16409 but it had some defects that the PR changed results. This PR also restores previous results.You can read some history in blog posts; for example
https://docs.knapsackpro.com/2020/uri-escape-is-obsolete-percent-encoding-your-query-string
Description
There's no 100% equivalent to
URI.escape
. So we need to use alternatives case by case.URI.encode_www_form_component
- can be used where you encode a part of URI query parameterURI.encode_www_form
- can be used with query parameters in Array on HashCGI.escape
- similar toURI.encode_www_form_component
but it follows CGI's specAddressable::URI.encode
- is 3rd party dependency (we've already adopted) but is the closest option toURI.escape
I applied 1 for places where we process query parameters and 3 for the rest of URLs and file paths.
Note that there is different behaviour between
URI.escape
andURI.encode_www_form_component
especially for whitespaces. WhileURI.escape
andAddressable::URI.escape
can work well for file paths including whitespaces,URI.encode_www_form_component
is only effective for "query parameters" really.These are examples of differences among those APIs (except for
CGI.escape
).Testing Steps
We can test the followings -
deliver
command with HTML preview (See if screenshots are correctly shown and linked)fastlane frameit download_frames
Fastfile
belowURI.escape
but changed it toURI.encode_www_form_component
, which seems wrong.Addressable::URI.encode
would be better 5e864f8#diff-cbec5511af30c2da21c2488e6f8baff4eabe4745fb5d01755aa506836b4db920R310-R313Fastfile
Result - exportOption.plist (See if the URLs are escaped correctly)
We can't really test them and might be good to consider deprecation/removalπ
https://play.google.com/apps/publish/delegatePrivateApp?service_account=&continueUrl=
https://developers.google.com/android/work/play/custom-app-api/get-started#retrieve_the_developer_account_id