fastlane-plugin-try_scan 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 674d55524df14f5d8442d245b9d6bac1c076db872a47528b9e3c469e6c641fdc
|
4
|
+
data.tar.gz: 6a948848f0c9114bb2b35eccbad122e6c242867f2ad55c5a402918cf6127d732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c673c0d2738041016915e1028c1f78b2954c0bb8b8344e284703f4a99c4cfbfde4ecd0fc73f5740856731b1cc3fda528998580b015b1f031100e093b223292
|
7
|
+
data.tar.gz: e69f6713be6793ae96a559aaabbf0932b545430955dc070b8abdf7916d6f092598dfa5ca7ccf8414cc6583918c0f2ee6937906a377d66b131b8c1bc133d2c6ca
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## Getting Started
|
6
6
|
|
7
|
-
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `try_scan`, add it to your project by running:
|
8
8
|
|
9
9
|
```bash
|
10
10
|
fastlane add_plugin try_scan
|
@@ -12,27 +12,16 @@ fastlane add_plugin try_scan
|
|
12
12
|
|
13
13
|
## About try_scan
|
14
14
|
|
15
|
-
Simple way to retry your scan action
|
15
|
+
Simple way to retry your scan action 🚀
|
16
16
|
|
17
|
-
|
17
|
+
## Usage
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
## Run tests for this plugin
|
26
|
-
|
27
|
-
To run both the tests, and code style validation, run
|
28
|
-
|
29
|
-
```
|
30
|
-
rake
|
31
|
-
```
|
32
|
-
|
33
|
-
To automatically fix many of the styling issues, use
|
34
|
-
```
|
35
|
-
rubocop -a
|
19
|
+
```ruby
|
20
|
+
try_scan(
|
21
|
+
workspace: "Example.xcworkspace",
|
22
|
+
devices: ["iPhone 6s", "iPad Air"],
|
23
|
+
try_count: 3
|
24
|
+
)
|
36
25
|
```
|
37
26
|
|
38
27
|
## Issues and Feedback
|
@@ -43,10 +32,6 @@ For any other issues and feedback about this plugin, please submit it to this re
|
|
43
32
|
|
44
33
|
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
45
34
|
|
46
|
-
## Using _fastlane_ Plugins
|
47
|
-
|
48
|
-
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
49
|
-
|
50
35
|
## About _fastlane_
|
51
36
|
|
52
37
|
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Fastlane
|
2
2
|
module Actions
|
3
3
|
|
4
|
+
require 'json'
|
4
5
|
require 'fastlane/actions/scan'
|
5
6
|
require_relative '../helper/scan_helper'
|
6
7
|
require_relative '../helper/try_scan_runner'
|
@@ -89,7 +90,7 @@ module Fastlane
|
|
89
90
|
description: "The number of times to retry running tests via scan",
|
90
91
|
type: Integer,
|
91
92
|
is_string: false,
|
92
|
-
default_value:
|
93
|
+
default_value: 0
|
93
94
|
)
|
94
95
|
]
|
95
96
|
end
|
@@ -5,7 +5,6 @@ module TryScanManager
|
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@options = options
|
8
|
-
warn_of_try_scan_option
|
9
8
|
end
|
10
9
|
|
11
10
|
def run
|
@@ -18,7 +17,7 @@ module TryScanManager
|
|
18
17
|
Scan::Runner.new.run
|
19
18
|
return true
|
20
19
|
rescue FastlaneCore::Interface::FastlaneBuildFailure, FastlaneCore::Interface::FastlaneTestFailure => _
|
21
|
-
|
20
|
+
update_scan_reports(attempt)
|
22
21
|
return false if attempt > @options[:try_count]
|
23
22
|
|
24
23
|
attempt += 1
|
@@ -28,7 +27,12 @@ module TryScanManager
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def update_scan_config
|
31
|
-
|
30
|
+
if !Scan.config[:output_types].include?('junit') && !parallel_running?
|
31
|
+
output_types = Scan.config[:output_types].split(',')
|
32
|
+
output_types << 'junit'
|
33
|
+
Scan.config[:output_types] = output_types.join(',')
|
34
|
+
end
|
35
|
+
@options[:try_count] = 0 if @options[:try_count] < 0
|
32
36
|
end
|
33
37
|
|
34
38
|
def print_summary
|
@@ -51,13 +55,6 @@ module TryScanManager
|
|
51
55
|
FastlaneCore::UI.important("TryScan shot №#{attempt}\n")
|
52
56
|
end
|
53
57
|
|
54
|
-
def warn_of_try_scan_option
|
55
|
-
if @options[:try_count] <= 0
|
56
|
-
FastlaneCore::UI.important(":try_count can't be less than or equal to zero. Setting a default value equal to `1`")
|
57
|
-
@options[:try_count] = 1
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
58
|
def clear_preexisting_data
|
62
59
|
FastlaneScanHelper.remove_preexisting_simulator_logs(@options)
|
63
60
|
FastlaneScanHelper.remove_preexisting_test_result_bundles(@options)
|
@@ -65,8 +62,14 @@ module TryScanManager
|
|
65
62
|
FastlaneScanHelper.remove_report_files
|
66
63
|
end
|
67
64
|
|
65
|
+
def update_scan_reports(attempt)
|
66
|
+
merge_junit_reports if attempt != 1 && !parallel_running?
|
67
|
+
end
|
68
|
+
|
68
69
|
def update_scan_options
|
69
|
-
scan_options = @options.select { |key, _|
|
70
|
+
scan_options = @options.select { |key, _|
|
71
|
+
FastlaneScanHelper.valid_scan_keys.include?(key)
|
72
|
+
}.merge(plugin_scan_options)
|
70
73
|
scan_options[:only_testing] = extract_failed_tests
|
71
74
|
scan_options[:skip_build] = true
|
72
75
|
scan_options[:test_without_building] = true
|
@@ -91,11 +94,24 @@ module TryScanManager
|
|
91
94
|
FastlaneCore::UI.important('Disabling -quiet as failing tests cannot be found with it enabled.')
|
92
95
|
xcargs.gsub!('-quiet', '')
|
93
96
|
end
|
94
|
-
|
95
|
-
@options.select { |k,v| FastlaneScanHelper.valid_scan_keys.include?(k) }.merge({ xcargs: "#{xcargs} -parallel-testing-enabled NO " })
|
97
|
+
@options.select { |key, _| FastlaneScanHelper.valid_scan_keys.include?(key) }.merge({ xcargs: xcargs })
|
96
98
|
end
|
97
99
|
|
98
100
|
def extract_failed_tests
|
101
|
+
if parallel_running?
|
102
|
+
extract_failed_tests_from_xcresult_report
|
103
|
+
else
|
104
|
+
extract_failed_tests_from_junit_report
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def parallel_running?
|
109
|
+
return @options[:concurrent_workers].to_i > 0 ||
|
110
|
+
(@options[:devices] && @options[:devices].size > 1) ||
|
111
|
+
(@options[:xcargs] && (@options[:xcargs] =~ /-parallel-testing-enabled(=|\s+)YES/ || @options[:xcargs].split('-destination').size > 2))
|
112
|
+
end
|
113
|
+
|
114
|
+
def extract_failed_tests_from_junit_report
|
99
115
|
report = junit_report
|
100
116
|
suite_name = report.xpath('testsuites/@name').to_s.split('.')[0]
|
101
117
|
test_cases = report.xpath('//testcase')
|
@@ -107,6 +123,7 @@ module TryScanManager
|
|
107
123
|
test_name = test_case.xpath('@name')
|
108
124
|
only_testing << "#{suite_name}/#{test_class}/#{test_name}"
|
109
125
|
end
|
126
|
+
FastlaneCore::UI.verbose("Extracted tests to retry: #{only_testing}")
|
110
127
|
only_testing
|
111
128
|
end
|
112
129
|
|
@@ -141,5 +158,27 @@ module TryScanManager
|
|
141
158
|
|
142
159
|
File.open(@junit_report_path, "w+") { |f| f.write(old_junit_report.to_xml) }
|
143
160
|
end
|
161
|
+
|
162
|
+
def parse_xcresult_report
|
163
|
+
report_options = FastlaneScanHelper.report_options
|
164
|
+
output_directory = report_options.instance_variable_get(:@output_directory)
|
165
|
+
xcresult_report_files = Dir["#{output_directory}/*.xcresult"]
|
166
|
+
raise FastlaneCore::UI.test_failure!('There are no xcresult reports to parse') if xcresult_report_files.empty?
|
167
|
+
|
168
|
+
FastlaneCore::UI.verbose("Parsing xcresult report by path: '#{xcresult_report_files.first}'")
|
169
|
+
JSON.parse(`xcrun xcresulttool get --format json --path #{xcresult_report_files.first}`)
|
170
|
+
end
|
171
|
+
|
172
|
+
def extract_failed_tests_from_xcresult_report
|
173
|
+
only_testing = []
|
174
|
+
parse_xcresult_report['issues']['testFailureSummaries']['_values'].each do |failed_test|
|
175
|
+
suite_name = failed_test['producingTarget']['_value']
|
176
|
+
test_class = failed_test['testCaseName']['_value'].split('.').first
|
177
|
+
test_name = failed_test['testCaseName']['_value'].split('.')[1].split('(').first
|
178
|
+
only_testing << "#{suite_name}/#{test_class}/#{test_name}"
|
179
|
+
end
|
180
|
+
FastlaneCore::UI.verbose("Extracted tests to retry: #{only_testing}")
|
181
|
+
only_testing
|
182
|
+
end
|
144
183
|
end
|
145
184
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-try_scan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|