fastlane-plugin-try_scan 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 674d55524df14f5d8442d245b9d6bac1c076db872a47528b9e3c469e6c641fdc
4
- data.tar.gz: 6a948848f0c9114bb2b35eccbad122e6c242867f2ad55c5a402918cf6127d732
3
+ metadata.gz: 12d650730323d7c47cfcf510d28238dd5e4864bb4cf169e65139d14c909c33a0
4
+ data.tar.gz: c5fceb554ef538e90917244e5ef303b79102289908aedd005e53a1b0a4d056d8
5
5
  SHA512:
6
- metadata.gz: b5c673c0d2738041016915e1028c1f78b2954c0bb8b8344e284703f4a99c4cfbfde4ecd0fc73f5740856731b1cc3fda528998580b015b1f031100e093b223292
7
- data.tar.gz: e69f6713be6793ae96a559aaabbf0932b545430955dc070b8abdf7916d6f092598dfa5ca7ccf8414cc6583918c0f2ee6937906a377d66b131b8c1bc133d2c6ca
6
+ metadata.gz: 0eaea36a94853fb1c5ba8eec440ba5329744c671c1970f6edc36df3db69cadb647e64023b3abfbcdf327b30813d69bef6b70566b2951323f6f0afd98574d9888
7
+ data.tar.gz: 3bdfc6aede5d51e8ba1ae4089fc17be7e2cd6aa7ada7e0a09e696dfbf9412e001559d9341a7ee5ad659ae737460c00d7511e5064457416b06035fe3b356708e8
@@ -2,6 +2,7 @@ module Fastlane
2
2
  module Actions
3
3
 
4
4
  require 'json'
5
+ require 'nokogiri'
5
6
  require 'fastlane/actions/scan'
6
7
  require_relative '../helper/scan_helper'
7
8
  require_relative '../helper/try_scan_runner'
@@ -90,7 +91,7 @@ module Fastlane
90
91
  description: "The number of times to retry running tests via scan",
91
92
  type: Integer,
92
93
  is_string: false,
93
- default_value: 0
94
+ default_value: 1
94
95
  )
95
96
  ]
96
97
  end
@@ -88,18 +88,6 @@ module TryScanManager
88
88
  end
89
89
  end
90
90
  end
91
-
92
- def self.update_xctestrun_after_build(scan_options)
93
- xctestrun_files = Dir.glob("#{Scan.config[:derived_data_path]}/Build/Products/*.xctestrun")
94
- FastlaneCore::UI.verbose("After building, found xctestrun files #{xctestrun_files} (choosing 1st)")
95
- scan_options[:xctestrun] = xctestrun_files.first
96
- end
97
-
98
- def self.remove_preexisting_xctestrun_files
99
- xctestrun_files = Dir.glob("#{Scan.config[:derived_data_path]}/Build/Products/*.xctestrun")
100
- FastlaneCore::UI.verbose("Before building, removing pre-existing xctestrun files: #{xctestrun_files}")
101
- FileUtils.rm_rf(xctestrun_files)
102
- end
103
91
  end
104
92
  end
105
93
  end
@@ -10,18 +10,26 @@ module TryScanManager
10
10
  def run
11
11
  update_scan_config
12
12
  print_summary
13
- attempt = 1
13
+ @attempt = 1
14
14
  begin
15
- warn_of_performing_attempts(attempt)
15
+ warn_of_performing_attempts
16
16
  clear_preexisting_data
17
17
  Scan::Runner.new.run
18
+ print_parallel_scan_result
18
19
  return true
19
- rescue FastlaneCore::Interface::FastlaneBuildFailure, FastlaneCore::Interface::FastlaneTestFailure => _
20
- update_scan_reports(attempt)
21
- return false if attempt > @options[:try_count]
20
+ rescue FastlaneCore::Interface::FastlaneTestFailure => _
21
+ failed_tests = extract_failed_tests
22
+ print_parallel_scan_result(failed_tests_count: failed_tests.size)
23
+ update_scan_junit_report
24
+ return false if @attempt >= @options[:try_count]
25
+
26
+ @attempt += 1
27
+ update_scan_options(failed_tests)
28
+ retry
29
+ rescue FastlaneCore::Interface::FastlaneBuildFailure => _
30
+ return false if @attempt >= @options[:try_count]
22
31
 
23
- attempt += 1
24
- update_scan_options
32
+ @attempt += 1
25
33
  retry
26
34
  end
27
35
  end
@@ -32,7 +40,7 @@ module TryScanManager
32
40
  output_types << 'junit'
33
41
  Scan.config[:output_types] = output_types.join(',')
34
42
  end
35
- @options[:try_count] = 0 if @options[:try_count] < 0
43
+ @options[:try_count] = 1 if @options[:try_count] < 1
36
44
  end
37
45
 
38
46
  def print_summary
@@ -51,8 +59,8 @@ module TryScanManager
51
59
  )
52
60
  end
53
61
 
54
- def warn_of_performing_attempts(attempt)
55
- FastlaneCore::UI.important("TryScan shot №#{attempt}\n")
62
+ def warn_of_performing_attempts
63
+ FastlaneCore::UI.important("TryScan: Getting started #{ordinalized_attempt} shot\n")
56
64
  end
57
65
 
58
66
  def clear_preexisting_data
@@ -62,15 +70,34 @@ module TryScanManager
62
70
  FastlaneScanHelper.remove_report_files
63
71
  end
64
72
 
65
- def update_scan_reports(attempt)
66
- merge_junit_reports if attempt != 1 && !parallel_running?
73
+ def print_parallel_scan_result(failed_tests_count: 0)
74
+ return unless parallel_running?
75
+
76
+ FastlaneCore::UI.important("TryScan: result after #{ordinalized_attempt} shot 👇")
77
+ FastlaneCore::PrintTable.print_values(
78
+ config: {"Number of tests" => tests_count_from_xcresult_report, "Number of failures" => failed_tests_count},
79
+ title: "Test Results"
80
+ )
67
81
  end
68
82
 
69
- def update_scan_options
83
+ def ordinalized_attempt
84
+ case @attempt
85
+ when 1
86
+ "#{@attempt}st"
87
+ when 2
88
+ "#{@attempt}nd"
89
+ when 3
90
+ "#{@attempt}rd"
91
+ else
92
+ "#{@attempt}th"
93
+ end
94
+ end
95
+
96
+ def update_scan_options(failed_tests)
70
97
  scan_options = @options.select { |key, _|
71
98
  FastlaneScanHelper.valid_scan_keys.include?(key)
72
99
  }.merge(plugin_scan_options)
73
- scan_options[:only_testing] = extract_failed_tests
100
+ scan_options[:only_testing] = failed_tests
74
101
  scan_options[:skip_build] = true
75
102
  scan_options[:test_without_building] = true
76
103
  scan_options[:build_for_testing] = false
@@ -99,9 +126,9 @@ module TryScanManager
99
126
 
100
127
  def extract_failed_tests
101
128
  if parallel_running?
102
- extract_failed_tests_from_xcresult_report
129
+ failed_tests_from_xcresult_report
103
130
  else
104
- extract_failed_tests_from_junit_report
131
+ failed_tests_from_junit_report
105
132
  end
106
133
  end
107
134
 
@@ -111,7 +138,7 @@ module TryScanManager
111
138
  (@options[:xcargs] && (@options[:xcargs] =~ /-parallel-testing-enabled(=|\s+)YES/ || @options[:xcargs].split('-destination').size > 2))
112
139
  end
113
140
 
114
- def extract_failed_tests_from_junit_report
141
+ def failed_tests_from_junit_report
115
142
  report = junit_report
116
143
  suite_name = report.xpath('testsuites/@name').to_s.split('.')[0]
117
144
  test_cases = report.xpath('//testcase')
@@ -123,7 +150,6 @@ module TryScanManager
123
150
  test_name = test_case.xpath('@name')
124
151
  only_testing << "#{suite_name}/#{test_class}/#{test_name}"
125
152
  end
126
- FastlaneCore::UI.verbose("Extracted tests to retry: #{only_testing}")
127
153
  only_testing
128
154
  end
129
155
 
@@ -139,7 +165,9 @@ module TryScanManager
139
165
  @cached_junit_report
140
166
  end
141
167
 
142
- def merge_junit_reports
168
+ def update_scan_junit_report
169
+ return if @attempt == 1 || parallel_running?
170
+
143
171
  old_junit_report = junit_report(cached: true)
144
172
  new_junit_report = junit_report(cached: false)
145
173
 
@@ -169,7 +197,7 @@ module TryScanManager
169
197
  JSON.parse(`xcrun xcresulttool get --format json --path #{xcresult_report_files.first}`)
170
198
  end
171
199
 
172
- def extract_failed_tests_from_xcresult_report
200
+ def failed_tests_from_xcresult_report
173
201
  only_testing = []
174
202
  parse_xcresult_report['issues']['testFailureSummaries']['_values'].each do |failed_test|
175
203
  suite_name = failed_test['producingTarget']['_value']
@@ -177,8 +205,11 @@ module TryScanManager
177
205
  test_name = failed_test['testCaseName']['_value'].split('.')[1].split('(').first
178
206
  only_testing << "#{suite_name}/#{test_class}/#{test_name}"
179
207
  end
180
- FastlaneCore::UI.verbose("Extracted tests to retry: #{only_testing}")
181
208
  only_testing
182
209
  end
210
+
211
+ def tests_count_from_xcresult_report
212
+ parse_xcresult_report['metrics']['testsCount']['_value']
213
+ end
183
214
  end
184
215
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TryScan
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-try_scan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Alter-Pesotskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: pry
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +150,6 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: nokogiri
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: fastlane
141
155
  requirement: !ruby/object:Gem::Requirement