fastlane-plugin-merge_junit_report 0.1.4 → 0.5.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
  SHA1:
3
- metadata.gz: 8bbbb02ced1f7b5b9e5d51e5a2f6e4504875fd7d
4
- data.tar.gz: ac250548d6f8c9e1e6005e5dbee8f5beb5bb464e
3
+ metadata.gz: 11462ea5f79cfb8824fb59ac15182895d76c8163
4
+ data.tar.gz: 2b7366c5564d7402b33c1e8728eb1992c6b5e5bc
5
5
  SHA512:
6
- metadata.gz: a81d42dd0372f79480e918f6ad4474c227b8c35d1025465699e645254eca215ec4d67e6fe6aabcbd55ce57dd299b2b882615e8dc274708e6d3294bcaa6be934c
7
- data.tar.gz: d35db005a95c5ab593047d4ee103927a8f0e9a9f12b04ef18c8ff26d703e9d2dc33772d983b02dff58dd444dd359d7de089525bd64d608e496a49a0529b12b06
6
+ metadata.gz: ef934752fa6ec1b3ec9099432676bd3c5db987c6097050ef0064a031c3a31bcb2a3f87a5beaa08cdf098c4db218cce9d0f7a74e99a27b2f4da5d716590e7cb5f
7
+ data.tar.gz: e374fba30aaf923e3a822437da9b95726ce3636650d711bea099bcf8329620591337b8775fbe783c42d9b215442138e58145a6d3838c020a666507624bfca256
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![Gem](https://badge.fury.io/rb/fastlane-plugin-merge_junit_report.svg)](https://badge.fury.io/rb/fastlane-plugin-merge_junit_report)
4
4
  [![Build Status](https://travis-ci.org/dyang/merge_junit_report.svg?branch=master)](https://travis-ci.org/dyang/merge_junit_report)
5
+ [![Code Climate](https://codeclimate.com/github/dyang/merge_junit_report/badges/gpa.svg)](https://codeclimate.com/github/dyang/merge_junit_report)
6
+ [![Test Coverage](https://codeclimate.com/github/dyang/merge_junit_report/badges/coverage.svg)](https://codeclimate.com/github/dyang/merge_junit_report/coverage)
5
7
 
6
8
  ## Getting Started
7
9
 
@@ -13,14 +15,24 @@ fastlane add_plugin merge_junit_report
13
15
 
14
16
  ## About merge_junit_report
15
17
 
16
- Merges multiple Junit reports into one.
18
+ Merge_junit_report is a [Fastlane](https://fastlane.tools/) plugin that merges multiple junit reports into one single report. It's primarily designed to be used in conjunction with another Fastlane plugin [fastlane-plugin-setup_fragile_tests_for_rescan](https://github.com/lyndsey-ferguson/fastlane_plugins/tree/master/fastlane-plugin-setup_fragile_tests_for_rescan) so that one can rerun flaky tests on CI server and aggregate the results.
19
+
20
+ This plugin can be used in the following way:
21
+
22
+ ```RUBY
23
+ merge_junit_report(
24
+ input_files: ['/run0/report.xml', '/run1/report.xml', '/run2/report.xml']],
25
+ output_file: 'output/report.xml'
26
+ )
27
+ ```
28
+
29
+ * `input_files` contains an array of junit report paths to merge from
30
+ * `output_file` is the path to the final merged report. Optional.
17
31
 
18
32
  ## Example
19
33
 
20
34
  Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
21
35
 
22
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
23
-
24
36
  ## Run tests for this plugin
25
37
 
26
38
  To run both the tests, and code style validation, run
@@ -29,11 +41,6 @@ To run both the tests, and code style validation, run
29
41
  rake
30
42
  ```
31
43
 
32
- To automatically fix many of the styling issues, use
33
- ```
34
- rubocop -a
35
- ```
36
-
37
44
  ## Issues and Feedback
38
45
 
39
46
  For any other issues and feedback about this plugin, please submit it to this repository.
@@ -1,7 +1,7 @@
1
1
  require 'fastlane_core'
2
2
  require 'fastlane/plugin/merge_junit_report/version'
3
3
  require 'fastlane/plugin/merge_junit_report/merger'
4
- require 'nokogiri'
4
+ require 'rexml/document'
5
5
 
6
6
  module Fastlane
7
7
  module MergeJunitReport
@@ -10,49 +10,44 @@ module Fastlane
10
10
  )
11
11
  input_files = params[:input_files]
12
12
 
13
- xml_docs = input_files.map { |file| Nokogiri::XML(File.open(file))}
13
+ xml_docs = input_files.map { |file| REXML::Document.new(File.new(file)) }
14
14
  merger = Fastlane::Plugin::MergeJunitReport::Merger.new(xml_docs)
15
15
  merged = merger.merge
16
16
 
17
17
  # write to output_file
18
18
  output_file = File.absolute_path(params[:output_file])
19
19
  FileUtils.mkdir_p(File.dirname(output_file))
20
- File.write(output_file, merged.to_xml)
21
-
20
+ File.open(output_file, 'w') { |f| merged.write(f, 2) }
22
21
  UI.success("Reports merged to #{output_file} successfully")
23
22
  end
24
23
 
25
24
  def self.description
26
- "Provides the ability to merge multiple junit reports into one"
25
+ 'Provides the ability to merge multiple junit reports into one'
27
26
  end
28
27
 
29
28
  def self.authors
30
- ["Derek Yang"]
31
- end
32
-
33
- def self.return_value
34
- # If your method provides a return value, you can describe here what it does
29
+ ['Derek Yang']
35
30
  end
36
31
 
37
32
  def self.available_options
38
33
  [
39
34
  FastlaneCore::ConfigItem.new(key: :input_files,
40
- env_name: "MERGE_JUNIT_REPORT_INPUT_FILES",
41
- description: "A list of junit report files to merge from",
42
- optional: false,
43
- type: Array,
44
- verify_block: proc do |input_files|
45
- UI.user_error!("No input files!") if input_files.length < 1
46
- input_files.each { |input_file|
47
- UI.user_error!("File not found: #{input_file}") if !File.file?(input_file)
48
- }
49
- end),
35
+ env_name: 'MERGE_JUNIT_REPORT_INPUT_FILES',
36
+ description: 'A list of junit report files to merge from',
37
+ optional: false,
38
+ type: Array,
39
+ verify_block: proc do |input_files|
40
+ UI.user_error!('No input files!') if input_files.empty?
41
+ input_files.each do |input_file|
42
+ UI.user_error!("File not found: #{input_file}") unless File.file?(input_file)
43
+ end
44
+ end),
50
45
  FastlaneCore::ConfigItem.new(key: :output_file,
51
- env_name: "MERGE_JUNIT_REPORT_OUTPUT_FILE",
52
- description: "The output file where all input files will be merged into",
53
- optional: true,
54
- default_value: "result.xml",
55
- type: String)
46
+ env_name: 'MERGE_JUNIT_REPORT_OUTPUT_FILE',
47
+ description: 'The output file where all input files will be merged into',
48
+ optional: true,
49
+ default_value: 'result.xml',
50
+ type: String)
56
51
  ]
57
52
  end
58
53
 
@@ -65,14 +60,9 @@ module Fastlane
65
60
  ]
66
61
  end
67
62
 
68
- def self.is_supported?(platform)
69
- # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
70
- # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
71
- #
72
- # [:ios, :mac, :android].include?(platform)
63
+ def self.is_supported?(_platform)
73
64
  true
74
65
  end
75
-
76
66
  end
77
67
  end
78
68
  end
@@ -5,7 +5,7 @@ module Fastlane
5
5
  # as `Helper::MergeJunitReportHelper.your_method`
6
6
  #
7
7
  def self.show_message
8
- UI.message("Hello from the merge_junit_report plugin helper!")
8
+ UI.message('Hello from the merge_junit_report plugin helper!')
9
9
  end
10
10
  end
11
11
  end
@@ -1,60 +1,63 @@
1
1
  module Fastlane
2
- module Plugin
3
- module MergeJunitReport
4
- class Merger
5
- def initialize(reports)
6
- @reports = reports
7
- end
2
+ module Plugin
3
+ module MergeJunitReport
4
+ # Merge several junit reports into one single report
5
+ class Merger
6
+ # Initializes an instance of Merger
7
+ # @param [Array<REXML::Document>] junit reports the junit reports to merge from
8
+ # @return [Merger]
9
+ def initialize(reports)
10
+ @reports = reports
11
+ end
8
12
 
9
- def merge
10
- baseline = @reports.first
13
+ # Merges reports passed in via constructor
14
+ # @return [REXML::Document] merged junit report
15
+ def merge
16
+ baseline = @reports.first
17
+ @reports.drop(1).each do |report|
18
+ report.elements.each('//testsuite') do |suite_to_merge|
19
+ suite_name = suite_to_merge.attributes['name']
20
+ baseline_suite = REXML::XPath.first(baseline, "//testsuite[@name='#{suite_name}']")
11
21
 
12
- @reports.drop(1).each { |report|
13
- report.xpath('//testsuite').each { |suite_to_merge|
14
- suite_name = suite_to_merge.attr('name')
15
- baseline_suite = baseline.xpath("//testsuite[@name='#{suite_name}']")
16
-
17
- if baseline_suite
18
- suite_to_merge.xpath('testcase').each { |case_to_merge|
19
- classname = case_to_merge.attr('classname')
20
- name = case_to_merge.attr('name')
21
- baseline_case = baseline_suite.at_xpath("testcase[@name='#{name}' and @classname='#{classname}']")
22
- if baseline_case
23
- baseline_case.swap(case_to_merge.to_xml)
24
- end
25
- }
26
- end
27
- }
28
- }
29
-
30
- recalculate_failures(baseline)
31
- baseline
32
- end
22
+ next unless baseline_suite
23
+ suite_to_merge.elements.each('testcase') do |case_to_merge|
24
+ classname = case_to_merge.attributes['classname']
25
+ name = case_to_merge.attributes['name']
26
+ baseline_case = REXML::XPath.first(baseline_suite, "testcase[@name='#{name}' and @classname='#{classname}']")
27
+ # Replace baseline_case with case_to_merge
28
+ if baseline_case
29
+ baseline_case.parent.insert_after(baseline_case, case_to_merge)
30
+ baseline_case.parent.delete_element(baseline_case)
31
+ end
32
+ end
33
+ end
34
+ end
33
35
 
34
- def recalculate_failures(baseline)
35
- total_failures = 0
36
- baseline.xpath('//testsuite').each { |suite|
37
- failures = 0
38
- suite.xpath('testcase').each { |testcase|
39
- failures += 1 if testcase.xpath('failure').size > 0
40
- }
41
- remove_or_update_failures(failures, suite)
42
- total_failures += failures
43
- }
44
- remove_or_update_failures(total_failures, baseline.at_xpath('/testsuites'))
45
- end
36
+ recalculate_failures(baseline)
37
+ baseline
38
+ end
46
39
 
47
- def remove_or_update_failures(failures, node)
48
- if failures == 0
49
- node.remove_attribute('failures')
50
- else
51
- node['failures'] = failures.to_s
52
- end
53
- end
40
+ def recalculate_failures(baseline)
41
+ total_failures = 0
42
+ baseline.elements.each('//testsuite') do |suite|
43
+ failures = 0
44
+ suite.elements.each('testcase') { |testcase| failures += 1 unless REXML::XPath.match(testcase, 'failure').empty? }
45
+ remove_or_update_failures(failures, suite)
46
+ total_failures += failures
47
+ end
48
+ remove_or_update_failures(total_failures, REXML::XPath.first(baseline, '/testsuites'))
49
+ end
54
50
 
55
- private :recalculate_failures, :remove_or_update_failures
56
-
57
- end
58
- end
59
- end
51
+ def remove_or_update_failures(failures, node)
52
+ if failures.zero?
53
+ node.delete_attribute('failures')
54
+ else
55
+ node.attributes['failures'] = failures.to_s
56
+ end
57
+ end
58
+
59
+ private :recalculate_failures, :remove_or_update_failures
60
+ end
61
+ end
62
+ end
60
63
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module MergeJunitReport
3
- VERSION = "0.1.4"
3
+ VERSION = '0.5.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-merge_junit_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Yang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-04-17 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
13
  - !ruby/object:Gem::Dependency
28
14
  name: pry
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: 2.14.2
111
97
  - !ruby/object:Gem::Dependency
112
- name: equivalent-xml
98
+ name: simplecov
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -122,6 +108,20 @@ dependencies:
122
108
  - - ">="
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: codeclimate-test-reporter
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.0.0
125
125
  description:
126
126
  email: yanghada@gmail.com
127
127
  executables: []