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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Xcode 8 hung-up by making Helper.backticks retriable #6000

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Style/AndOr:
Metrics/ClassLength:
Max: 320

Metrics/ModuleLength:
Max: 130

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Expand Down
1 change: 1 addition & 0 deletions fastlane_core/fastlane_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'plist', '~> 3.1' # needed for parsing provisioning profiles
spec.add_dependency 'terminal-table', '~> 1.4.5' # options summary
spec.add_dependency 'gh_inspector', '>= 1.0.1', '< 2.0.0' # search for issues on GitHub when something goes wrong
spec.add_dependency 'retriable', '~> 2.1' # simple DSL to retry failed code blocks

spec.add_dependency 'credentials_manager', '>= 0.16.0', '< 1.0.0' # fastlane password manager

Expand Down
33 changes: 28 additions & 5 deletions fastlane_core/lib/fastlane_core/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,34 @@ def self.log

# Runs a given command using backticks (`)
# and prints them out using the UI.command method
def self.backticks(command, print: true)
UI.command(command) if print
result = `#{command}`
UI.command_output(result) if print
return result
def self.backticks(command, print: true, retriable_options: {})
require 'retriable'
Copy link
Member

Choose a reason for hiding this comment

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

I'd love to keep the old code, and only use the new one if retriable_options is passed. Something like a big if else in the beginning of the method

Copy link
Member

Choose a reason for hiding this comment

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

Let's wait for @mfurtak's opinion first on if we want to add the dependency, before updating the PR, sorry for chiming it like this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, Thanks 😇

tries = retriable_options[:tries] || 1
timeout = retriable_options[:timeout] || 3600
on_retry = proc do |exception, try, elapsed_time, next_interval|
if try < tries
UI.important("#{exception.class}: '#{exception.message}' - #{try} tries in #{elapsed_time} seconds and #{next_interval.to_i} seconds until the next try.")
end
end

options = {
on: Timeout::Error,
tries: tries,
timeout: timeout,
base_interval: 0,
on_retry: on_retry
}

begin
Retriable.retriable(options) do
UI.command(command) if print
result = `#{command}`
UI.command_output(result) if print
return result
end
rescue
UI.user_error!("Failed to execute: #{command}")
end
end

# @return true if the currently running program is a unit test
Expand Down
9 changes: 8 additions & 1 deletion fastlane_core/lib/fastlane_core/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,14 @@ def build_xcodebuild_showbuildsettings_command
def build_settings(key: nil, optional: true)
unless @build_settings
command = build_xcodebuild_showbuildsettings_command
@build_settings = Helper.backticks(command, print: false)
# Workaround for Xcode 8 problem:
# `xcodebuild -showBuildSettings` will hang up sometimes
# By retrying with specific timeout, this problem can be avoided
options = {
tries: (ENV['FASTLANE_XCODEBUILD_SETTINGS_TRIES'] || 3).to_i,
timeout: (ENV['FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT'] || 10).to_i
}
@build_settings = Helper.backticks(command, print: false, retriable_options: options)
end

begin
Expand Down