Class: Fastlane::Actions::MultiScanAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::MultiScanAction
- Defined in:
- lib/fastlane/plugin/retry_tests/actions/multi_scan.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .scan_options ⇒ Object
Class Method Summary collapse
- .config_has_junit_report(config) ⇒ Object
- .config_with_junit_report(config) ⇒ Object
- .config_with_retry(config, count) ⇒ Object
- .get_folder_root(folder) ⇒ Object
- .junit_report_filename(config) ⇒ Object
- .junit_report_filepath(config) ⇒ Object
- .merge_reports(scan_options, final_report_path) ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
137 138 139 140 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 137 def self. #Adapted from the "fastlane-plugin-test_center" plugin by: ["lyndsey-ferguson/@lyndseydf"] end |
.available_options ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 124 def self. + [ FastlaneCore::ConfigItem.new( key: :try_count, env_name: "FL_MULTI_SCAN_TRY_COUNT", description: "The number of times to retry running tests via scan", type: Integer, is_string: false, default_value: 1 ) ] end |
.config_has_junit_report(config) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 58 def self.config_has_junit_report(config) output_types = config.fetch(:output_types, '').to_s.split(',') output_filenames = config.fetch(:output_files, '').to_s.split(',') output_type_file_count_match = output_types.size == output_filenames.size output_types.include?('junit') && (output_type_file_count_match || config[:custom_report_file_name].to_s.strip.length > 0) end |
.config_with_junit_report(config) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 78 def self.config_with_junit_report(config) return config if config_has_junit_report(config) if config[:output_types].to_s.strip.empty? || config[:custom_report_file_name] config[:custom_report_file_name] ||= 'report.xml' config[:output_types] = 'junit' elsif config[:output_types].strip == 'junit' && config[:output_files].to_s.strip.empty? config[:custom_report_file_name] ||= 'report.xml' elsif !config[:output_types].split(',').include?('junit') config[:output_types] << ',junit' config[:output_files] << ',report.xml' elsif config[:output_files].nil? config[:output_files] = config[:output_types].split(',').map { |type| "report.#{type}" }.join(',') end config end |
.config_with_retry(config, count) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 66 def self.config_with_retry(config, count) folder = get_folder_root(config[:result_bundle]) config[:result_bundle] = (folder + count.to_s) config[:output_directory] = (folder + count.to_s) config end |
.description ⇒ Object
112 113 114 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 112 def self.description "Uses scan to run Xcode tests a given number of times: only re-testing failing tests." end |
.details ⇒ Object
116 117 118 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 116 def self.details "Use this action to run your tests if you have fragile tests that fail sporadically." end |
.get_folder_root(folder) ⇒ Object
73 74 75 76 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 73 def self.get_folder_root(folder) folder = folder.gsub(/ *\d+$/, '') folder end |
.is_supported?(platform) ⇒ Boolean
142 143 144 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 142 def self.is_supported?(platform) platform == :ios end |
.junit_report_filename(config) ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 95 def self.junit_report_filename(config) report_filename = config[:custom_report_file_name] if report_filename.nil? junit_index = config[:output_types].split(',').find_index('junit') report_filename = config[:output_files].to_s.split(',')[junit_index] end report_filename end |
.junit_report_filepath(config) ⇒ Object
104 105 106 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 104 def self.junit_report_filepath(config) File.absolute_path(File.join(config[:output_directory], junit_report_filename(config))) end |
.merge_reports(scan_options, final_report_path) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 41 def self.merge_reports(, final_report_path) folder = get_folder_root([:output_directory]) report_files = Dir.glob("#{folder}*/#{[:scheme]}.test_result/1_Test/action_TestSummaries.plist") asset_files = Dir.glob("#{folder}*/#{[:scheme]}.test_result/1_Test/Attachments") log_files = Dir.glob("#{folder}*/#{[:scheme]}.test_result/1_Test/action.xcactivitylog") #Merge all reports, screenshots, and logs if there were retried tests if report_files.size > 1 other_action.collate_junit_reports( scheme: [:scheme], reports: report_files, collated_report: final_report_path, assets: asset_files, logs: log_files, ) end end |
.run(params) ⇒ Object
9 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 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 9 def self.run(params) try_count = 0 = params.values.reject { |k| k == :try_count } final_report_path = [:result_bundle] unless Helper.test? FastlaneCore::PrintTable.print_values( config: params._values.reject { |k, v| .key?(k) }, title: "Summary for multi_scan (test_center v#{Fastlane::TestCenter::VERSION})" ) end = config_with_junit_report() begin try_count += 1 = config_with_retry(, try_count) config = FastlaneCore::Configuration.create(Fastlane::Actions::ScanAction., ) Fastlane::Actions::ScanAction.run(config) rescue FastlaneCore::Interface::FastlaneTestFailure => e FastlaneCore::UI.verbose("Scan failed with error #{e}") #Retry for the specified number of times if there were failed tests if try_count < params[:try_count] report_filepath = junit_report_filepath() failed_tests = other_action.tests_from_junit(junit: report_filepath)[:failed] [:only_testing] = failed_tests.map(&:shellescape) retry end end merge_reports(, final_report_path) end |
.scan_options ⇒ Object
120 121 122 |
# File 'lib/fastlane/plugin/retry_tests/actions/multi_scan.rb', line 120 def self. ScanAction. end |