fastlane-plugin-retry 1.1.8 → 1.2.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: db070c8bfe2d40ef344faa8e3daadcac036d68235f9b2b216a2c796417c73601
4
- data.tar.gz: b6092f6ca7def6d1dad63b4e7e0b96efbf8b63e60e7dd7bb47400f1ade073554
3
+ metadata.gz: 418e52a88ee32b5176755eb84ddd0abbdbdd87ba8666311f3f48bf14c4c1f3f7
4
+ data.tar.gz: 10ec5b6dbaac8d0e2ec4e7fad3ea598b60c7359ff0172eebf988762174f47db6
5
5
  SHA512:
6
- metadata.gz: 1d18601a4305af4c3b5a990664d5ccd7bcbe19f2a706b8a7a5c6569e2b0470330acc08eac28fc7588b578e40315f6842b79df9a4a70168749309d74bb4df1beb
7
- data.tar.gz: 2cd5294f93f439e39b226821dcf07a0122f93860f846acad37edd9bfc9e1c54fcd0a252900fcf29318f17d5c6635a13fbabfe4c32765f2184e306b265820e80a
6
+ metadata.gz: cb2320f9007d18b329295ebf8a91eec1e5149849f148bae4b75dd1e0e9489bd75c0f34dcaf6f7d973c1829e347b82bba249127031b6a80ae1595c0befea212f1
7
+ data.tar.gz: 0bd5c60648445920af94a21edd3c212c7015155bc0c318c19719fb69de9163a7d3cff7c4450fad37664ea9994ca7925afad9a5a74d40524b708968f5a1af4acc
data/README.md CHANGED
@@ -2,41 +2,49 @@
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-retry)
4
4
 
5
- Retries failed XCUITest test cases.
5
+ A fastlane plugin that automatically retries failed XCUITest test cases. This plugin is loosely based off [lyndsey-ferguson's fastlane-plugin-test_center](https://github.com/lyndsey-ferguson/fastlane-plugin-test_center) plugin, which uses JUnit reports instead of PList to generate a simple HTML report.
6
6
 
7
- This plugin is available in the [Ruby Gems directory](https://rubygems.org/gems/fastlane-plugin-retry).
7
+ This plugin works with the following logic:
8
+ 1) Run the whole test suite once
9
+ 2) Parse the generated .plist results to obtain a list of the failed tests
10
+ 3) Retry the failed tests an 'x' number of times (see below for how to specify the number of retries) and generate a .plist report for each retry run
11
+ 4) Merge all .plist reports together to generate one final .plist report
12
+
13
+ Tip: You can then use the final .plist report with the [XCHtmlReport plugin](https://github.com/TitouanVanBelle/XCTestHTMLReport) to generate a very beautiful HTML report including screenshots and console logs! See the sample fastfile for usage.
8
14
 
15
+ This plugin is available in the [Ruby Gems directory](https://rubygems.org/gems/fastlane-plugin-retry).
9
16
 
10
17
  ## Installation
11
18
 
12
19
  This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-retry`, add it to your project by running:
13
20
 
14
- ```bash
21
+ ```
15
22
  fastlane add_plugin retry
23
+ ```
24
+ Check that the command above generated a Pluginfile in your project's fastlane folder. The Pluginfile should contain the following text:
25
+ ```
26
+ gem 'fastlane-plugin-retry', '~> 1.0', '>= 1.0.5'
27
+ ```
28
+ Add the following line to your project's Gemfile:
29
+ ```
30
+ plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
31
+ eval_gemfile(plugins_path) if File.exist?(plugins_path)
32
+ ```
33
+ Finally, run the following command to install the plugin files to your project's Bundler folder.
34
+ ```
16
35
  bundle install
17
36
  ```
18
37
 
19
-
20
38
  ## Usage
21
39
 
40
+ See the sample fastfile for how to configure your project's fastfile. Once you have configured your fastfile, use the following command to run your tests with retry (you can change the number of tries and the device).
22
41
  ```
23
- multi_scan(
24
- workspace: File.absolute_path('../xxxxxx.xcworkspace'),
25
- scheme: 'xxxxxx',
26
- try_count: options[:tries],
27
- result_bundle: result_bundle_path,
28
- output_directory: result_bundle_path,
29
- destination: options[:devices],
30
- xctestrun: xctestrun_path,
31
- test_without_building: true
32
- )
33
-
34
- sh("/usr/local/bin/xchtmlreport -r [location of the .plist generated by multi_scan]")
42
+ bundle exec fastlane run_tests_with_retry tries:3 devices:"platform=iOS Simulator,name=iPhone 8,OS=11.4"
35
43
  ```
36
44
 
37
45
  ## Issues and Feedback
38
46
 
39
- For any other issues and feedback about this plugin, please submit it to this repository or Slack message to @gloria.
47
+ For any other issues and feedback about this plugin, please submit it to this repository.
40
48
 
41
49
  ## Troubleshooting
42
50
 
@@ -8,16 +8,19 @@ module Fastlane
8
8
 
9
9
  def self.run(params)
10
10
  report_filepaths = params[:reports]
11
+ # If no retries are required return the results
11
12
  if report_filepaths.size == 1
12
13
  FileUtils.cp(report_filepaths[0], params[:collated_report])
13
14
  else
14
15
  target_report = File.open(report_filepaths.shift) {|f| Nokogiri::XML(f)}
15
16
  reports = report_filepaths.map { |report_filepath| Nokogiri::XML(Nokogiri::PList(open(report_filepath)).to_plist) }
17
+ # Clean each retry report and merge it into the first report
16
18
  reports.each do |retry_report|
17
19
  retry_report = clean_report(retry_report.to_s)
18
20
  mergeLists(target_report, retry_report, params)
19
21
  end
20
22
  end
23
+ # Merge screenshots and console logs from all retry runs
21
24
  merge_assets(params[:assets], params[:collated_report] + "/Attachments")
22
25
  merge_logs(params[:logs], params[:collated_report] + "/")
23
26
  end
@@ -30,6 +33,7 @@ module Fastlane
30
33
  retried_tests = retry_report.xpath("//key[contains(.,'TestSummaryGUID')]/..")
31
34
  current_node = retried_tests.shift
32
35
  while (current_node != nil)
36
+ # For each retried test, get the corresponding node of data from the retried report and merge it into the base report
33
37
  testName = get_test_name(current_node)
34
38
  matching_node = target_report.at_xpath("//string[contains(.,'#{testName}')]/..")
35
39
  if (!matching_node.nil?)
@@ -51,6 +55,7 @@ module Fastlane
51
55
 
52
56
  # Cleans formatting of report
53
57
  def self.clean_report(report)
58
+ # Removes unescaped <> characters which cause the final .plist to become unreadable
54
59
  report = report.gsub("<XCAccessibilityElement:/>0x", " XCAccessibilityElement ")
55
60
  report = report.gsub("<XCAccessibilityElement:></XCAccessibilityElement:>", " XCAccessibilityElement ")
56
61
  report = Nokogiri::XML(report)
@@ -19,6 +19,7 @@ module Fastlane
19
19
 
20
20
  begin
21
21
  try_count += 1
22
+ UI.header("Test Attempt: #{try_count}")
22
23
  scan_options = config_with_retry(scan_options, try_count)
23
24
  config = FastlaneCore::Configuration.create(Fastlane::Actions::ScanAction.available_options, scan_options)
24
25
  Fastlane::Actions::ScanAction.run(config)
@@ -30,6 +31,12 @@ module Fastlane
30
31
  scan_options[:only_testing] = failed_tests
31
32
  retry
32
33
  end
34
+ rescue FastlaneCore::Interface::FastlaneCommonException => e
35
+ UI.important("Probably encountered an environment failure: #{e}")
36
+ if try_count < params[:try_count]
37
+ UI.important("Retrying the last run from the beginning.")
38
+ retry
39
+ end
33
40
  end
34
41
  merge_reports(scan_options, final_report_path)
35
42
  end
@@ -38,8 +45,10 @@ module Fastlane
38
45
  def self.parse_failures(plist, scheme_name)
39
46
  failures = Array.new
40
47
  target_report = File.open(plist) {|f| Nokogiri::XML(f)}
48
+ # Get the names of all the failed tests from the specified report
41
49
  failed = target_report.xpath("//key[contains(.,'Failure')]/../key[contains(.,'TestIdentifier')]/following-sibling::string[contains(.,'()') and contains (., '/')]")
42
50
  failed.each do |test_name|
51
+ # Reformat the test name to be usable by the xcodebuild 'only_testing' flag
43
52
  failures << ("#{scheme_name}/" + test_name.to_s.split('(')[0].split('>')[1])
44
53
  end
45
54
  failures
@@ -47,6 +56,7 @@ module Fastlane
47
56
 
48
57
  # Merge results from all retries
49
58
  def self.merge_reports(scan_options, final_report_path)
59
+ UI.header("Merging Reports")
50
60
  folder = get_folder_root(scan_options[:output_directory])
51
61
  report_files = Dir.glob("#{folder}*/**/action_TestSummaries.plist").sort
52
62
  asset_files = Dir.glob("#{folder}*/**/Attachments")
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Retry
3
- VERSION = "1.1.8"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gmgchow