fastlane-plugin-merge_junit_report 0.1.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -8
- data/lib/fastlane/plugin/merge_junit_report.rb +1 -1
- data/lib/fastlane/plugin/merge_junit_report/actions/merge_junit_report_action.rb +20 -30
- data/lib/fastlane/plugin/merge_junit_report/helper/merge_junit_report_helper.rb +1 -1
- data/lib/fastlane/plugin/merge_junit_report/merger.rb +56 -53
- data/lib/fastlane/plugin/merge_junit_report/version.rb +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11462ea5f79cfb8824fb59ac15182895d76c8163
|
4
|
+
data.tar.gz: 2b7366c5564d7402b33c1e8728eb1992c6b5e5bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef934752fa6ec1b3ec9099432676bd3c5db987c6097050ef0064a031c3a31bcb2a3f87a5beaa08cdf098c4db218cce9d0f7a74e99a27b2f4da5d716590e7cb5f
|
7
|
+
data.tar.gz: e374fba30aaf923e3a822437da9b95726ce3636650d711bea099bcf8329620591337b8775fbe783c42d9b215442138e58145a6d3838c020a666507624bfca256
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/fastlane-plugin-merge_junit_report)
|
4
4
|
[](https://travis-ci.org/dyang/merge_junit_report)
|
5
|
+
[](https://codeclimate.com/github/dyang/merge_junit_report)
|
6
|
+
[](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
|
-
|
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.
|
@@ -10,49 +10,44 @@ module Fastlane
|
|
10
10
|
)
|
11
11
|
input_files = params[:input_files]
|
12
12
|
|
13
|
-
xml_docs = input_files.map { |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.
|
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
|
-
|
25
|
+
'Provides the ability to merge multiple junit reports into one'
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.authors
|
30
|
-
[
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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?(
|
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
|
@@ -1,60 +1,63 @@
|
|
1
1
|
module Fastlane
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
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.
|
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-
|
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:
|
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: []
|