fastlane/lib/fastlane/runner.rb in fastlane-2.62.0.beta.20171016010004 vs fastlane/lib/fastlane/runner.rb in fastlane-2.62.0.beta.20171017010003
- old
+ new
@@ -195,11 +195,14 @@
Actions.execute_action("Switch to #{pretty.join(' ')} lane") {} # log the action
UI.message "Cruising over to lane '#{pretty.join(' ')}' 🚖"
# Actually switch lane now
self.current_lane = new_lane
- collector.did_launch_action(:lane_switch)
+
+ launch_context = FastlaneCore::ActionLaunchContext.context_for_action_name('lane_switch', args: ARGV)
+ FastlaneCore.session.action_launched(launch_context: launch_context)
+
result = block.call(parameters.first || {}) # to always pass a hash
self.current_lane = original_lane
# after blocks are only called if no exception was raised before
# Call the platform specific after block and then the general one
@@ -216,15 +219,16 @@
if custom_dir.nil?
custom_dir ||= "." if Helper.test?
custom_dir ||= ".."
end
- collector.did_launch_action(method_sym)
-
verify_supported_os(method_sym, class_ref)
begin
+ launch_context = FastlaneCore::ActionLaunchContext.context_for_action_name(method_sym.to_s, args: ARGV)
+ FastlaneCore.session.action_launched(launch_context: launch_context)
+
Dir.chdir(custom_dir) do # go up from the fastlane folder, to the project folder
# If another action is calling this action, we shouldn't show it in the summary
# (see https://github.com/fastlane/fastlane/issues/4546)
action_name = from_action ? nil : class_ref.step_text
Actions.execute_action(action_name) do
@@ -247,30 +251,42 @@
puts class_ref.deprecated_notes.to_s.deprecated if class_ref.deprecated_notes
puts "==========================================\n".deprecated
end
class_ref.runner = self # needed to call another action form an action
- class_ref.run(arguments)
+ return_value = class_ref.run(arguments)
+
+ action_completed(method_sym.to_s, status: FastlaneCore::ActionCompletionStatus::SUCCESS)
+
+ return return_value
end
end
rescue Interrupt => e
raise e # reraise the interruption to avoid logging this as a crash
rescue FastlaneCore::Interface::FastlaneCommonException => e # these are exceptions that we dont count as crashes
raise e
rescue FastlaneCore::Interface::FastlaneError => e # user_error!
FastlaneCore::CrashReporter.report_crash(exception: e)
- collector.did_raise_error(method_sym) if e.fastlane_should_report_metrics?
+ action_completed(method_sym.to_s, status: FastlaneCore::ActionCompletionStatus::USER_ERROR, exception: e)
raise e
rescue Exception => e # rubocop:disable Lint/RescueException
# high chance this is actually FastlaneCore::Interface::FastlaneCrash, but can be anything else
# Catches all exceptions, since some plugins might use system exits to get out
FastlaneCore::CrashReporter.report_crash(exception: e)
- collector.did_crash(method_sym) if e.fastlane_should_report_metrics?
+
+ action_completed(method_sym.to_s, status: FastlaneCore::ActionCompletionStatus::FAILED, exception: e)
raise e
end
end
+ def action_completed(action_name, status: nil, exception: nil)
+ if exception.nil? || exception.fastlane_should_report_metrics?
+ action_completion_context = FastlaneCore::ActionCompletionContext.context_for_action_name(action_name, args: ARGV, status: status)
+ FastlaneCore.session.action_completed(completion_context: action_completion_context)
+ end
+ end
+
def execute_flow_block(block, current_platform, lane, parameters)
# Call the platform specific block and default back to the general one
block[current_platform].call(lane, parameters) if block[current_platform] && current_platform
block[nil].call(lane, parameters) if block[nil]
end
@@ -283,18 +299,9 @@
unless class_ref.is_supported?(platform)
UI.important("Action '#{name}' isn't known to support operating system '#{platform}'.")
end
end
end
- end
-
- def collector
- @collector ||= ActionCollector.new
- end
-
- # Fastfile was finished executing
- def did_finish
- collector.did_finish
end
# Called internally to setup the runner object
#