Class: Fastlane::Actions::ScanAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/scan.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorObject



51
52
53
# File 'lib/fastlane/actions/scan.rb', line 51

def self.author
  "KrauseFx"
end

.available_optionsObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/actions/scan.rb', line 55

def self.available_options
  require 'scan'

  FastlaneCore::CommanderGenerator.new.generate(Scan::Options.available_options) + [
    FastlaneCore::ConfigItem.new(key: :fail_build,
                                 env_name: "SCAN_FAIL_BUILD",
                                 description: "Should this step stop the build if the tests fail? Set this to false if you're using trainer",
                                 default_value: true)
  ]
end

.categoryObject



87
88
89
# File 'lib/fastlane/actions/scan.rb', line 87

def self.category
  :testing
end

.descriptionObject



43
44
45
# File 'lib/fastlane/actions/scan.rb', line 43

def self.description
  "Easily run tests of your iOS app using _scan_"
end

.detailsObject



47
48
49
# File 'lib/fastlane/actions/scan.rb', line 47

def self.details
  "More information: https://github.com/fastlane/fastlane/tree/master/scan"
end

.example_codeObject



76
77
78
79
80
81
82
83
84
85
# File 'lib/fastlane/actions/scan.rb', line 76

def self.example_code
  [
    'scan',
    'scan(
      workspace: "App.xcworkspace",
      scheme: "MyTests",
      clean: false
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/fastlane/actions/scan.rb', line 66

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

.run(values) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/actions/scan.rb', line 10

def self.run(values)
  require 'scan'

  begin
    destination = values[:destination] # save destination value which can be later overridden
    Scan.config = values # we set this here to auto-detect missing values, which we need later on
    unless values[:derived_data_path].to_s.empty?
      plist_files_before = test_summary_filenames(values[:derived_data_path])
    end

    FastlaneCore::UpdateChecker.start_looking_for_update('scan') unless Helper.is_test?

    values[:destination] = destination # restore destination value
    Scan::Manager.new.work(values)

    return true
  rescue => ex
    if values[:fail_build]
      raise ex
    end
  ensure
    unless values[:derived_data_path].to_s.empty?
      Actions.lane_context[SharedValues::SCAN_DERIVED_DATA_PATH] = values[:derived_data_path]
      plist_files_after = test_summary_filenames(values[:derived_data_path])
      all_test_summaries = (plist_files_after - plist_files_before)
      Actions.lane_context[SharedValues::SCAN_GENERATED_PLIST_FILES] = all_test_summaries
      Actions.lane_context[SharedValues::SCAN_GENERATED_PLIST_FILE] = all_test_summaries.last
    end

    FastlaneCore::UpdateChecker.show_update_status('scan', Scan::VERSION)
  end
end

.test_summary_filenames(derived_data_path) ⇒ Object



72
73
74
# File 'lib/fastlane/actions/scan.rb', line 72

def self.test_summary_filenames(derived_data_path)
  Dir["#{derived_data_path}/**/Logs/Test/*TestSummaries.plist"]
end