Class: Fastlane::Actions::TryScanAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/try_scan/actions/try_scan_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



75
76
77
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 75

def self.authors
  ["Alexey Alter-Pesotskiy"]
end

.available_optionsObject



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 83

def self.available_options
  scan_options = ScanAction.available_options.reject { |config| i[output_types].include?(config.key) }
  scan_options + [
    FastlaneCore::ConfigItem.new(
      key: :try_count,
      env_name: "FL_TRY_SCAN_TRY_COUNT",
      description: "The number of times to retry running tests via scan",
      type: Integer,
      is_string: false,
      default_value: 1
    )
  ]
end

.categoryObject



97
98
99
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 97

def self.category
  :testing
end

.coerce_destination_to_array(params) ⇒ Object



36
37
38
39
40
41
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 36

def self.coerce_destination_to_array(params)
  destination = params[:destination] || Scan.config[:destination] || []
  unless destination.kind_of?(Array)
    params[:destination] = Scan.config[:destination] = [destination]
  end
end

.descriptionObject

Documentation #



71
72
73
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 71

def self.description
  "Simple way to retry your scan action"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 101

def self.is_supported?(platform)
  [:ios].include?(platform)
end

.prepare_for_testing(params) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 18

def self.prepare_for_testing(params)
  warn_of_xcode11_result_bundle_incompatability(params)
  use_scanfile_to_override_settings(params.values)
  turn_off_concurrent_workers(params.values)
  prepare_scan_config(params.values)
  coerce_destination_to_array(params)
end

.prepare_scan_config(scan_options) ⇒ Object



60
61
62
63
64
65
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 60

def self.prepare_scan_config(scan_options)
  Scan.config ||= FastlaneCore::Configuration.create(
    Fastlane::Actions::ScanAction.available_options,
    FastlaneScanHelper.scan_options_from_try_scan_options(scan_options)
  )
end

.run(params) ⇒ Object



11
12
13
14
15
16
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 11

def self.run(params)
  prepare_for_testing(params)
  success = TryScanManager::Runner.new(params.values).run

  raise FastlaneCore::UI.test_failure!('Tests have failed') if params[:fail_build] && !success
end

.scan_optionsObject



79
80
81
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 79

def self.scan_options
  ScanAction.available_options.reject { |config| i[output_types].include?(config.key) }
end

.turn_off_concurrent_workers(scan_options) ⇒ Object



43
44
45
46
47
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 43

def self.turn_off_concurrent_workers(scan_options)
  if Gem::Version.new(Fastlane::VERSION) >= Gem::Version.new('2.142.0')
    scan_options.delete(:concurrent_workers) if scan_options[:concurrent_workers].to_i > 0
  end
end

.use_scanfile_to_override_settings(scan_options) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 49

def self.use_scanfile_to_override_settings(scan_options)
  overridden_options = FastlaneScanHelper.options_from_configuration_file(
    FastlaneScanHelper.scan_options_from_try_scan_options(scan_options)
  )

  unless overridden_options.empty?
    FastlaneCore::UI.important("Scanfile found: overriding try_scan options with it's values.")
    overridden_options.each { |key, val| scan_options[key] = val }
  end
end

.warn_of_xcode11_result_bundle_incompatability(params) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/fastlane/plugin/try_scan/actions/try_scan_action.rb', line 26

def self.warn_of_xcode11_result_bundle_incompatability(params)
  if FastlaneCore::Helper.xcode_at_least?('11.0.0')
    if params[:result_bundle]
      FastlaneCore::UI.important('As of Xcode 11, test_result bundles created in the output directory are actually symbolic links to an xcresult bundle')
    end
  elsif params[:output_types]&.include?('xcresult')
    FastlaneCore::UI.important("The 'xcresult' :output_type is only supported for Xcode 11 and greater. You are using #{FastlaneCore::Helper.xcode_version}.")
  end
end