danger-xcode_summary 0.1.4 → 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/.rubocop.yml +3 -0
- data/Gemfile.lock +4 -5
- data/README.md +10 -0
- data/danger-xcode_summary.gemspec +2 -0
- data/lib/xcode_summary/gem_version.rb +1 -1
- data/lib/xcode_summary/plugin.rb +67 -19
- data/spec/xcode_summary_spec.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fea9e12b00a58261fd0f841b76b7228395f4257f
|
4
|
+
data.tar.gz: 721e083c3336c8d53cdec149bf9de450fa57a439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90588b0811d839b2c0a1b2d084742ff23ca4da1dc9f4a94128a18ad21f571ccc78c5a2725b0e51e84652303bbf4e67a3857741f757f6601f7b75a38deb66225a
|
7
|
+
data.tar.gz: 8bdb96a869ea5944cdf8e3fba78827a1f30dcd6b4eb23ef1505d573ed948f7e6d842bb586ae2b0b235c83b03331d4c58d036e2fe345d649d777f5e3e42006265
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-xcode_summary (0.
|
4
|
+
danger-xcode_summary (0.2.0)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -16,10 +16,9 @@ GEM
|
|
16
16
|
nap
|
17
17
|
open4 (~> 1.3)
|
18
18
|
coderay (1.1.1)
|
19
|
-
colored (1.2)
|
20
19
|
colored2 (3.1.2)
|
21
|
-
cork (0.
|
22
|
-
|
20
|
+
cork (0.3.0)
|
21
|
+
colored2 (~> 3.1)
|
23
22
|
danger (4.3.3)
|
24
23
|
claide (~> 1.0)
|
25
24
|
claide-plugins (>= 0.9.2)
|
@@ -131,4 +130,4 @@ DEPENDENCIES
|
|
131
130
|
yard
|
132
131
|
|
133
132
|
BUNDLED WITH
|
134
|
-
1.14.
|
133
|
+
1.14.6
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[](LICENSE.txt)
|
4
4
|
[](https://badge.fury.io/rb/danger-xcode_summary)
|
5
5
|
[](https://travis-ci.org/diogot/danger-xcode_summary)
|
6
|
+
[](https://dependencyci.com/github/diogot/danger-xcode_summary)
|
6
7
|
|
7
8
|
A [Danger](http://danger.systems) plugin that shows all build errors, warnings and unit tests results generated from `xcodebuild`.
|
8
9
|
|
@@ -104,6 +105,15 @@ xcode_summary.ignored_files = '**/Pods/**'
|
|
104
105
|
xcode_summary.report 'xcodebuild.json'
|
105
106
|
```
|
106
107
|
|
108
|
+
You can use `inline_mode`.
|
109
|
+
When this value is enabled, each warnings and errors are commented on each lines.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# Comment on each lines
|
113
|
+
xcode_summary.inline_mode = true
|
114
|
+
xcode_summary.report 'xcodebuild.json'
|
115
|
+
```
|
116
|
+
|
107
117
|
## License
|
108
118
|
|
109
119
|
danger-xcode_summary is released under the MIT license. See [LICENSE.txt](LICENSE.txt) for details.
|
data/lib/xcode_summary/plugin.rb
CHANGED
@@ -18,6 +18,9 @@ module Danger
|
|
18
18
|
# @tags xcode, xcodebuild, format
|
19
19
|
#
|
20
20
|
class DangerXcodeSummary < Plugin
|
21
|
+
Location = Struct.new(:file_name, :file_path, :line)
|
22
|
+
Result = Struct.new(:message, :location)
|
23
|
+
|
21
24
|
# The project root, which will be used to make the paths relative.
|
22
25
|
# Defaults to `pwd`.
|
23
26
|
# @param [String] value
|
@@ -44,6 +47,12 @@ module Danger
|
|
44
47
|
# @return [Boolean]
|
45
48
|
attr_accessor :test_summary
|
46
49
|
|
50
|
+
# Defines if using inline comment or not.
|
51
|
+
# Defaults to `false`.
|
52
|
+
# @param [Boolean] value
|
53
|
+
# @return [Boolean]
|
54
|
+
attr_accessor :inline_mode
|
55
|
+
|
47
56
|
def project_root
|
48
57
|
root = @project_root || Dir.pwd
|
49
58
|
root += '/' unless root.end_with? '/'
|
@@ -59,7 +68,11 @@ module Danger
|
|
59
68
|
end
|
60
69
|
|
61
70
|
def test_summary
|
62
|
-
@test_summary
|
71
|
+
@test_summary.nil? ? true : @test_summary
|
72
|
+
end
|
73
|
+
|
74
|
+
def inline_mode
|
75
|
+
@inline_mode || false
|
63
76
|
end
|
64
77
|
|
65
78
|
# Reads a file with JSON Xcode summary and reports it.
|
@@ -79,8 +92,20 @@ module Danger
|
|
79
92
|
|
80
93
|
def format_summary(xcode_summary)
|
81
94
|
messages(xcode_summary).each { |s| message(s, sticky: sticky_summary) }
|
82
|
-
warnings(xcode_summary).each
|
83
|
-
|
95
|
+
warnings(xcode_summary).each do |result|
|
96
|
+
if inline_mode && result.location
|
97
|
+
warn(result.message, sticky: false, file: result.location.file_name, line: result.location.line)
|
98
|
+
else
|
99
|
+
warn(result.message, sticky: false)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
errors(xcode_summary).each do |result|
|
103
|
+
if inline_mode && result.location
|
104
|
+
fail(result.message, sticky: false, file: result.location.file_name, line: result.location.line)
|
105
|
+
else
|
106
|
+
fail(result.message, sticky: false)
|
107
|
+
end
|
108
|
+
end
|
84
109
|
end
|
85
110
|
|
86
111
|
def messages(xcode_summary)
|
@@ -95,21 +120,46 @@ module Danger
|
|
95
120
|
|
96
121
|
def warnings(xcode_summary)
|
97
122
|
[
|
98
|
-
xcode_summary
|
99
|
-
xcode_summary
|
100
|
-
xcode_summary.fetch(:compile_warnings, {}).map
|
101
|
-
|
123
|
+
xcode_summary.fetch(:warnings, []).map { |message| Result.new(message, nil) },
|
124
|
+
xcode_summary.fetch(:ld_warnings, []).map { |message| Result.new(message, nil) },
|
125
|
+
xcode_summary.fetch(:compile_warnings, {}).map do |h|
|
126
|
+
Result.new(format_compile_warning(h), parse_location(h))
|
127
|
+
end
|
128
|
+
].flatten.uniq.compact.reject { |result| result.message.nil? }
|
102
129
|
end
|
103
130
|
|
104
131
|
def errors(xcode_summary)
|
105
132
|
[
|
106
133
|
xcode_summary[:errors],
|
107
|
-
xcode_summary.fetch(:compile_errors, {}).map
|
108
|
-
|
109
|
-
|
110
|
-
xcode_summary.fetch(:
|
111
|
-
|
112
|
-
|
134
|
+
xcode_summary.fetch(:compile_errors, {}).map do |h|
|
135
|
+
Result.new(format_compile_warning(h), parse_location(h))
|
136
|
+
end,
|
137
|
+
xcode_summary.fetch(:file_missing_errors, {}).map do |h|
|
138
|
+
Result.new(format_format_file_missing_error(h), parse_location(h))
|
139
|
+
end,
|
140
|
+
xcode_summary.fetch(:undefined_symbols_errors, {}).map do |h|
|
141
|
+
Result.new(format_undefined_symbols(h), nil)
|
142
|
+
end,
|
143
|
+
xcode_summary.fetch(:duplicate_symbols_errors, {}).map do |h|
|
144
|
+
Result.new(format_duplicate_symbols(h), nil)
|
145
|
+
end,
|
146
|
+
xcode_summary.fetch(:tests_failures, {}).map do |test_suite, failures|
|
147
|
+
failures.map do |failure|
|
148
|
+
Result.new(format_test_failure(test_suite, failure), parse_test_location(failure))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
].flatten.uniq.compact.reject { |result| result.message.nil? }
|
152
|
+
end
|
153
|
+
|
154
|
+
def parse_location(h)
|
155
|
+
file_path, line, _column = h[:file_path].split(':')
|
156
|
+
Location.new(h[:file_name], file_path, line.to_i)
|
157
|
+
end
|
158
|
+
|
159
|
+
def parse_test_location(failure)
|
160
|
+
path, line = failure[:file_path].split(':')
|
161
|
+
file_name = relative_path(path)
|
162
|
+
Location.new(file_name, path, line.to_i)
|
113
163
|
end
|
114
164
|
|
115
165
|
def format_path(path)
|
@@ -181,12 +231,10 @@ module Danger
|
|
181
231
|
"> #{h[:file_paths].map { |path| path.split('/').last }.join('<br /> ')}"
|
182
232
|
end
|
183
233
|
|
184
|
-
def format_test_failure(suite_name,
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
"**#{suite_name}**: #{f[:test_case]}, #{escape_reason(f[:reason])} <br /> #{path_link}"
|
189
|
-
end
|
234
|
+
def format_test_failure(suite_name, failure)
|
235
|
+
path = relative_path(failure[:file_path])
|
236
|
+
path_link = format_path(path)
|
237
|
+
"**#{suite_name}**: #{failure[:test_case]}, #{escape_reason(failure[:reason])} <br /> #{path_link}"
|
190
238
|
end
|
191
239
|
end
|
192
240
|
end
|
data/spec/xcode_summary_spec.rb
CHANGED
@@ -93,6 +93,40 @@ module Danger
|
|
93
93
|
# rubocop:enable LineLength
|
94
94
|
]
|
95
95
|
end
|
96
|
+
|
97
|
+
context 'with inline_mode' do
|
98
|
+
before do
|
99
|
+
@xcode_summary.inline_mode = true
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'asserts errors on the line' do
|
103
|
+
allow(@xcode_summary).to receive(:fail)
|
104
|
+
@xcode_summary.report('spec/fixtures/test_errors.json')
|
105
|
+
expect(@xcode_summary).to have_received(:fail).with(
|
106
|
+
instance_of(String),
|
107
|
+
sticky: false,
|
108
|
+
file: 'MyWeight/MyWeightTests/Tests.swift',
|
109
|
+
line: 86
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'asserts warning on the line' do
|
114
|
+
allow(@xcode_summary).to receive(:warn)
|
115
|
+
@xcode_summary.report('spec/fixtures/summary.json')
|
116
|
+
expect(@xcode_summary).to have_received(:warn).with(
|
117
|
+
instance_of(String),
|
118
|
+
sticky: false,
|
119
|
+
file: 'Bla.m',
|
120
|
+
line: 32
|
121
|
+
)
|
122
|
+
expect(@xcode_summary).to have_received(:warn).with(
|
123
|
+
instance_of(String),
|
124
|
+
sticky: false,
|
125
|
+
file: 'ISO8601DateFormatter.m',
|
126
|
+
line: 176
|
127
|
+
)
|
128
|
+
end
|
129
|
+
end
|
96
130
|
end
|
97
131
|
end
|
98
132
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-xcode_summary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diogo Tridapalli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04-
|
12
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: danger-plugin-api
|