trainer 0.1.3 → 0.2.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 +37 -8
- data/lib/trainer/options.rb +6 -2
- data/lib/trainer/test_parser.rb +23 -5
- data/lib/trainer/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9bd919dd0dc94df63dac316b75515bd599fa555
|
4
|
+
data.tar.gz: c7899ff83d99d07ed2c4a9afc10a1c1656dab42e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfcc1720af088d7285b8d8f53e323fb451148f814cd0df1c4acff9bf4ab0d5f84a757ad8c9902796f3c21e5e6e20875a958d4f0d96bf0b603e95e3a3bc8bb9c9
|
7
|
+
data.tar.gz: e00913b6fa064c578feb850816736498983970cddb406ff24c3a44e524fec737280d89e82c625f743e0635d2931ed38cdab7955c2c094f76d870ba8a897183e3
|
data/README.md
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
# trainer
|
2
2
|
|
3
|
+
[](https://twitter.com/KrauseFx)
|
4
|
+
[](https://github.com/KrauseFx/trainer/blob/master/LICENSE)
|
5
|
+
[](http://rubygems.org/gems/trainer)
|
6
|
+
|
3
7
|
This is an alternative approach to generate JUnit files for your CI (e.g. Jenkins) without parsing the `xcodebuild` output, but using the Xcode `plist` files instead.
|
4
8
|
|
5
|
-
|
9
|
+
Some Xcode versions has a known issue around not properly closing `stdout` ([Radar](https://openradar.appspot.com/27447948)), so you [can't use xcpretty](https://github.com/supermarin/xcpretty/issues/227).
|
10
|
+
|
11
|
+
`trainer` is a more robust and faster approach to generate JUnit reports for your CI system.
|
12
|
+
|
13
|
+
> By using `trainer`, the Twitter iOS code base now generates JUnit reports 10 times faster.
|
6
14
|
|
7
|
-
|
15
|
+
| [xcpretty](https://github.com/supermarin/xcpretty) | trainer
|
16
|
+
--------------------------|------------------------------|------------------------------
|
17
|
+
Prettify the `xcodebuild` output | :white_check_mark: | :no_entry_sign:
|
18
|
+
Generate JUnit reports | :white_check_mark: | :white_check_mark:
|
19
|
+
Generate HTML reports | :white_check_mark: | :no_entry_sign:
|
20
|
+
Works when the `xcodebuild` output format changed | :no_entry_sign: | :white_check_mark:
|
21
|
+
Show test execution duration | :white_check_mark: | :no_entry_sign:
|
22
|
+
Speed | :car: | :rocket:
|
23
|
+
|
24
|
+
[xcpretty](https://github.com/supermarin/xcpretty) is a great piece of software that is used across all [fastlane tools](https://fastlane.tools). `trainer` was built to have the minimum code to generate JUnit reports for your CI system.
|
8
25
|
|
9
26
|
## Use with [fastlane](https://fastlane.tools)
|
10
27
|
|
@@ -18,15 +35,25 @@ Now add the following to your `Fastfile`
|
|
18
35
|
|
19
36
|
```ruby
|
20
37
|
lane :test do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
38
|
+
begin
|
39
|
+
scan(workspace: "Themoji.xcworkspace", scheme: "ThemojiUITests", output_types: "")
|
40
|
+
rescue => ex
|
41
|
+
failure = ex
|
42
|
+
end
|
43
|
+
|
44
|
+
trainer(output_directory: "/tmp/fastlane_trainer/#{Time.now.to_i}")
|
45
|
+
raise failure if failure
|
25
46
|
end
|
26
47
|
```
|
27
48
|
|
28
49
|
This will generate the JUnit file in the temporary location `/tmp/fastlane_trainer/[time]`. You can specify any path you want, just make sure to have it clean for every run so that your CI system knows which one to pick.
|
29
50
|
|
51
|
+
If you use circle, use the following to automatically publish the JUnit reports
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
trainer(output_directory: (ENV["CIRCLE_TEST_REPORTS"] || "/tmp"))
|
55
|
+
```
|
56
|
+
|
30
57
|
For more information, check out the [fastlane plugin docs](fastlane-plugin-trainer#readme).
|
31
58
|
|
32
59
|
## Without [fastlane](https://fastlane.tools)
|
@@ -52,7 +79,7 @@ If you use `fastlane`, check out the official [fastlane plugin](fastlane-plugin-
|
|
52
79
|
|
53
80
|
```
|
54
81
|
cd [project]
|
55
|
-
scan --derived_data_path "
|
82
|
+
scan --derived_data_path "output_dir"
|
56
83
|
```
|
57
84
|
|
58
85
|
#### Convert the plist files to junit
|
@@ -77,7 +104,7 @@ trainer --help
|
|
77
104
|
|
78
105
|
To make it easier for you and your contributors to see the test failures, you should start using [danger](http://danger.systems) with the [danger-junit](https://github.com/orta/danger-junit) plugin
|
79
106
|
|
80
|
-

|
81
108
|
|
82
109
|
### Thanks
|
83
110
|
|
@@ -86,3 +113,5 @@ After the [lobbying of @steipete](https://twitter.com/steipete/status/7536621708
|
|
86
113
|
> How does Xcode Server parse the results?
|
87
114
|
|
88
115
|
I started investigating alternative approaches on how to parse test results.
|
116
|
+
|
117
|
+
For more information about the plist files that are being used, check out [Michele's blog post](http://michele.io/test-logs-in-xcode).
|
data/lib/trainer/options.rb
CHANGED
@@ -9,7 +9,11 @@ module Trainer
|
|
9
9
|
description: "Path to the directory that should be converted",
|
10
10
|
verify_block: proc do |value|
|
11
11
|
v = File.expand_path(value.to_s)
|
12
|
-
|
12
|
+
if v.end_with?(".plist")
|
13
|
+
UI.user_error!("Can't find file at path #{v}") unless File.exist?(v)
|
14
|
+
else
|
15
|
+
UI.user_error!("Path '#{v}' is not a directory or can't be found") unless File.directory?(v)
|
16
|
+
end
|
13
17
|
end),
|
14
18
|
FastlaneCore::ConfigItem.new(key: :extension,
|
15
19
|
short_option: "-e",
|
@@ -24,7 +28,7 @@ module Trainer
|
|
24
28
|
env_name: "TRAINER_OUTPUT_DIRECTORY",
|
25
29
|
default_value: nil,
|
26
30
|
optional: true,
|
27
|
-
description: "Directoy in which the xml files should be written to. Same directory as source by default")
|
31
|
+
description: "Directoy in which the xml files should be written to. Same directory as source by default")
|
28
32
|
]
|
29
33
|
end
|
30
34
|
end
|
data/lib/trainer/test_parser.rb
CHANGED
@@ -6,15 +6,24 @@ module Trainer
|
|
6
6
|
|
7
7
|
attr_accessor :raw_json
|
8
8
|
|
9
|
+
# Returns a hash with the path being the key, and the value
|
10
|
+
# defining if the tests were successful
|
9
11
|
def self.auto_convert(config)
|
12
|
+
FastlaneCore::PrintTable.print_values(config: config,
|
13
|
+
title: "Summary for trainer #{Trainer::VERSION}")
|
14
|
+
|
10
15
|
containing_dir = config[:path]
|
11
16
|
files = Dir["#{containing_dir}/**/Logs/Test/*TestSummaries.plist"]
|
12
17
|
files += Dir["#{containing_dir}/Test/*TestSummaries.plist"]
|
13
18
|
files += Dir["#{containing_dir}/*TestSummaries.plist"]
|
19
|
+
files += Dir[containing_dir] if containing_dir.end_with?(".plist") # if it's the exact path to a plist file
|
14
20
|
|
15
|
-
|
21
|
+
if files.empty?
|
22
|
+
UI.user_error!("No test result files found in directory '#{containing_dir}', make sure the file name ends with 'TestSummaries.plist'")
|
23
|
+
end
|
16
24
|
|
17
|
-
|
25
|
+
return_hash = {}
|
26
|
+
files.each do |path|
|
18
27
|
if config[:output_directory]
|
19
28
|
FileUtils.mkdir_p(config[:output_directory])
|
20
29
|
filename = File.basename(path).gsub(".plist", config[:extension])
|
@@ -23,10 +32,13 @@ module Trainer
|
|
23
32
|
to_path = path.gsub(".plist", config[:extension])
|
24
33
|
end
|
25
34
|
|
26
|
-
|
35
|
+
tp = Trainer::TestParser.new(path)
|
36
|
+
File.write(to_path, tp.to_junit)
|
27
37
|
puts "Successfully generated '#{to_path}'"
|
28
|
-
|
38
|
+
|
39
|
+
return_hash[to_path] = tp.tests_successful?
|
29
40
|
end
|
41
|
+
return_hash
|
30
42
|
end
|
31
43
|
|
32
44
|
def initialize(path)
|
@@ -46,11 +58,17 @@ module Trainer
|
|
46
58
|
JunitGenerator.new(self.data).generate
|
47
59
|
end
|
48
60
|
|
61
|
+
# @return [Bool] were all tests successful? Is false if at least one test failed
|
62
|
+
def tests_successful?
|
63
|
+
self.data.collect { |a| a[:number_of_failures] }.all? { |a| a == 0 }
|
64
|
+
end
|
65
|
+
|
49
66
|
private
|
50
67
|
|
51
68
|
def ensure_file_valid!
|
52
69
|
format_version = self.raw_json["FormatVersion"]
|
53
|
-
|
70
|
+
supported_versions = ["1.1", "1.2"]
|
71
|
+
UI.user_error!("Format version '#{format_version}' is not supported, must be #{supported_versions.join(', ')}") unless supported_versions.include?(format_version)
|
54
72
|
end
|
55
73
|
|
56
74
|
# Convert the Hashes and Arrays in something more useful
|
data/lib/trainer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trainer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.50.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.0.0
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.50.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.0.0
|
@@ -158,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
160
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.5.1
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: Convert xcodebuild plist files to JUnit reports
|
165
165
|
test_files: []
|
166
|
-
has_rdoc:
|