danger-xcode_summary 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7f4af287c0370b31f01a690b01e813461929e52ab57fce3285aa66bcaff49c4
4
- data.tar.gz: ed22370ea6a8c18a4fe031ab7b8dac06654ddbc31a45862d7232520b4b98955e
3
+ metadata.gz: 7f25343e3fe6e71f252e63e5874c5663ebf9b51ee797891a152cd7e2af4d1ebc
4
+ data.tar.gz: 22b537f085e5d3c7665b84de1b9eca6b1209fb718149470fd3cf7a1bf6a23bd9
5
5
  SHA512:
6
- metadata.gz: 6fb83b4b61b89603f5b4075c67039cabcf1221defda9106583ac9b569be141fcc7cbb33475f4369eaca4c77eabd86868a9ae99cd891ee2a820764de805fcf6b9
7
- data.tar.gz: b8ce24b92d313924532bf56626f4493cd8a1e2a9fa57beaeea66ac50cc08b40a5e5ed09c2aa8721bcce6d18a71d33820e777584e98a368517ed4d888fdea821b
6
+ metadata.gz: 2110fe068bad96009dd912161fa6ef43eeda1e05ba47453ef81b07cc2821c4c0455b3b3d0ef91cb593fc3df166669e55a602a20a4bc6d34905f070571bae31d0
7
+ data.tar.gz: 071fcaecbf8488ce2b59efdc02eb778d2230283c97de53117155232c5ab8ad2f7bc0c14e4f749bd0d0f4648a8a115f3a4040ab28b2bebf83693ebc71be5d6bae
@@ -29,8 +29,8 @@ jobs:
29
29
  - name: Set up Ruby
30
30
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
31
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
- # uses: ruby/setup-ruby@v1
33
- uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
32
+ uses: ruby/setup-ruby@v1
33
+ # uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
34
34
  with:
35
35
  ruby-version: ${{ matrix.ruby-version }}
36
36
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
data/.rubocop.yml CHANGED
@@ -24,7 +24,7 @@ Style/ClassAndModuleChildren:
24
24
  Enabled: false
25
25
 
26
26
  Metrics/AbcSize:
27
- Max: 60
27
+ Max: 66
28
28
 
29
29
  # The %w might be confusing for new users
30
30
  Style/WordArray:
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-xcode_summary (1.3.0)
4
+ danger-xcode_summary (1.4.0)
5
5
  danger-plugin-api (~> 1.0)
6
- xcresult (~> 0.2)
6
+ xcresult (~> 0.2.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- ast (2.4.2)
14
- base64 (0.2.0)
11
+ addressable (2.8.7)
12
+ public_suffix (>= 2.0.2, < 7.0)
13
+ ast (2.4.3)
14
+ base64 (0.3.0)
15
15
  claide (1.1.0)
16
16
  claide-plugins (0.9.2)
17
17
  cork
@@ -21,7 +21,8 @@ GEM
21
21
  colored2 (3.1.2)
22
22
  cork (0.3.0)
23
23
  colored2 (~> 3.1)
24
- danger (9.4.3)
24
+ danger (9.5.1)
25
+ base64 (~> 0.2)
25
26
  claide (~> 1.0)
26
27
  claide-plugins (>= 0.9.2)
27
28
  colored2 (~> 3.1)
@@ -31,29 +32,33 @@ GEM
31
32
  git (~> 1.13)
32
33
  kramdown (~> 2.3)
33
34
  kramdown-parser-gfm (~> 1.0)
34
- no_proxy_fix
35
35
  octokit (>= 4.0)
36
+ pstore (~> 0.1)
36
37
  terminal-table (>= 1, < 4)
37
38
  danger-plugin-api (1.0.0)
38
39
  danger (> 2.0)
39
- diff-lcs (1.5.1)
40
- faraday (2.9.0)
41
- faraday-net_http (>= 2.0, < 3.2)
40
+ diff-lcs (1.6.2)
41
+ faraday (2.13.1)
42
+ faraday-net_http (>= 2.0, < 3.5)
43
+ json
44
+ logger
42
45
  faraday-http-cache (2.5.1)
43
46
  faraday (>= 0.8)
44
- faraday-net_http (3.1.0)
45
- net-http
46
- ffi (1.16.3)
47
+ faraday-net_http (3.4.1)
48
+ net-http (>= 0.5.0)
49
+ ffi (1.17.2)
47
50
  formatador (1.1.0)
48
51
  git (1.19.1)
49
52
  addressable (~> 2.8)
50
53
  rchardet (~> 1.8)
51
- guard (2.18.1)
54
+ guard (2.19.1)
52
55
  formatador (>= 0.2.4)
53
56
  listen (>= 2.7, < 4.0)
57
+ logger (~> 1.6)
54
58
  lumberjack (>= 1.0.12, < 2.0)
55
59
  nenv (~> 0.1)
56
60
  notiffany (~> 0.0)
61
+ ostruct (~> 0.6)
57
62
  pry (>= 0.13.0)
58
63
  shellany (~> 0.0)
59
64
  thor (>= 0.18.1)
@@ -62,85 +67,90 @@ GEM
62
67
  guard (~> 2.1)
63
68
  guard-compat (~> 1.1)
64
69
  rspec (>= 2.99.0, < 4.0)
65
- json (2.7.1)
66
- kramdown (2.4.0)
67
- rexml
70
+ json (2.12.2)
71
+ kramdown (2.5.1)
72
+ rexml (>= 3.3.9)
68
73
  kramdown-parser-gfm (1.1.0)
69
74
  kramdown (~> 2.0)
70
- language_server-protocol (3.17.0.3)
71
- listen (3.8.0)
75
+ language_server-protocol (3.17.0.5)
76
+ lint_roller (1.1.0)
77
+ listen (3.9.0)
72
78
  rb-fsevent (~> 0.10, >= 0.10.3)
73
79
  rb-inotify (~> 0.9, >= 0.9.10)
80
+ logger (1.7.0)
74
81
  lumberjack (1.2.10)
75
- method_source (1.0.0)
82
+ method_source (1.1.0)
76
83
  nap (1.1.0)
77
84
  nenv (0.3.0)
78
- net-http (0.4.1)
85
+ net-http (0.6.0)
79
86
  uri
80
- no_proxy_fix (0.1.2)
81
87
  notiffany (0.1.3)
82
88
  nenv (~> 0.1)
83
89
  shellany (~> 0.0)
84
- octokit (8.1.0)
85
- base64
90
+ octokit (10.0.0)
86
91
  faraday (>= 1, < 3)
87
92
  sawyer (~> 0.9)
88
93
  open4 (1.3.4)
89
- parallel (1.24.0)
90
- parser (3.3.0.5)
94
+ ostruct (0.6.1)
95
+ parallel (1.27.0)
96
+ parser (3.3.8.0)
91
97
  ast (~> 2.4.1)
92
98
  racc
93
- pry (0.14.2)
99
+ prism (1.4.0)
100
+ pry (0.15.2)
94
101
  coderay (~> 1.1)
95
102
  method_source (~> 1.0)
96
- public_suffix (5.0.4)
97
- racc (1.7.3)
103
+ pstore (0.2.0)
104
+ public_suffix (6.0.2)
105
+ racc (1.8.1)
98
106
  rainbow (3.1.1)
99
- rake (13.1.0)
107
+ rake (13.3.0)
100
108
  rb-fsevent (0.11.2)
101
- rb-inotify (0.10.1)
109
+ rb-inotify (0.11.1)
102
110
  ffi (~> 1.0)
103
- rchardet (1.8.0)
104
- regexp_parser (2.9.0)
105
- rexml (3.2.6)
106
- rspec (3.13.0)
111
+ rchardet (1.9.0)
112
+ regexp_parser (2.10.0)
113
+ rexml (3.4.1)
114
+ rspec (3.13.1)
107
115
  rspec-core (~> 3.13.0)
108
116
  rspec-expectations (~> 3.13.0)
109
117
  rspec-mocks (~> 3.13.0)
110
- rspec-core (3.13.0)
118
+ rspec-core (3.13.4)
111
119
  rspec-support (~> 3.13.0)
112
- rspec-expectations (3.13.0)
120
+ rspec-expectations (3.13.5)
113
121
  diff-lcs (>= 1.2.0, < 2.0)
114
122
  rspec-support (~> 3.13.0)
115
- rspec-mocks (3.13.0)
123
+ rspec-mocks (3.13.5)
116
124
  diff-lcs (>= 1.2.0, < 2.0)
117
125
  rspec-support (~> 3.13.0)
118
- rspec-support (3.13.0)
119
- rubocop (1.60.2)
126
+ rspec-support (3.13.4)
127
+ rubocop (1.76.1)
120
128
  json (~> 2.3)
121
- language_server-protocol (>= 3.17.0)
129
+ language_server-protocol (~> 3.17.0.2)
130
+ lint_roller (~> 1.1.0)
122
131
  parallel (~> 1.10)
123
132
  parser (>= 3.3.0.2)
124
133
  rainbow (>= 2.2.2, < 4.0)
125
- regexp_parser (>= 1.8, < 3.0)
126
- rexml (>= 3.2.5, < 4.0)
127
- rubocop-ast (>= 1.30.0, < 2.0)
134
+ regexp_parser (>= 2.9.3, < 3.0)
135
+ rubocop-ast (>= 1.45.0, < 2.0)
128
136
  ruby-progressbar (~> 1.7)
129
- unicode-display_width (>= 2.4.0, < 3.0)
130
- rubocop-ast (1.30.0)
131
- parser (>= 3.2.1.0)
137
+ unicode-display_width (>= 2.4.0, < 4.0)
138
+ rubocop-ast (1.45.1)
139
+ parser (>= 3.3.7.2)
140
+ prism (~> 1.4)
132
141
  ruby-progressbar (1.13.0)
133
142
  sawyer (0.9.2)
134
143
  addressable (>= 2.3.5)
135
144
  faraday (>= 0.17.3, < 3)
136
145
  shellany (0.0.1)
137
- terminal-table (3.0.2)
138
- unicode-display_width (>= 1.1.1, < 3)
139
- thor (1.3.0)
140
- unicode-display_width (2.5.0)
141
- uri (0.13.0)
142
- xcresult (0.2.1)
143
- yard (0.9.34)
146
+ terminal-table (1.6.0)
147
+ thor (1.3.2)
148
+ unicode-display_width (3.1.4)
149
+ unicode-emoji (~> 4.0, >= 4.0.4)
150
+ unicode-emoji (4.0.4)
151
+ uri (1.0.3)
152
+ xcresult (0.2.2)
153
+ yard (0.9.37)
144
154
 
145
155
  PLATFORMS
146
156
  ruby
data/README.md CHANGED
@@ -107,6 +107,10 @@ xcode_summary.ignored_results { |result|
107
107
  }
108
108
 
109
109
  xcode_summary.report 'MyApp.xcresult'
110
+
111
+ # When `true`, collapses parallelized test runs of the same target into one line.
112
+ # Defaults to `false`.
113
+ xcode_summary.collapse_parallelized_tests = true
110
114
  ```
111
115
 
112
116
  You can use `ignores_warnings` to supress warnings and shows only errors.
@@ -3,7 +3,7 @@
3
3
  lib = File.expand_path('lib', __dir__)
4
4
 
5
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
- require 'xcode_summary/gem_version.rb'
6
+ require 'xcode_summary/gem_version'
7
7
 
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'danger-xcode_summary'
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.required_ruby_version = ">= 2.4.0"
24
+ spec.required_ruby_version = '>= 2.4.0'
25
25
 
26
- spec.add_dependency 'xcresult', '~> 0.2'
27
- spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
26
+ spec.add_dependency 'danger-plugin-api', '~> 1.0'
27
+ spec.add_dependency 'xcresult', '~> 0.2.2'
28
28
 
29
29
  # General ruby development
30
30
  spec.add_development_dependency 'bundler', '>= 2.2.10'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XcodeSummary
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
  end
@@ -82,6 +82,12 @@ module Danger
82
82
  # @return [Boolean]
83
83
  attr_accessor :strict
84
84
 
85
+ # Defines if parallelized test runs from the same target should be collapsed into one message.
86
+ # Defaults to `false`
87
+ # @param [Boolean] value
88
+ # @return [Boolean]
89
+ attr_accessor :collapse_parallelized_tests
90
+
85
91
  # rubocop:disable Lint/DuplicateMethods
86
92
  def project_root
87
93
  root = @project_root || Dir.pwd
@@ -106,7 +112,7 @@ module Danger
106
112
  end
107
113
 
108
114
  def test_summary
109
- @test_summary.nil? ? true : @test_summary
115
+ @test_summary.nil? || @test_summary
110
116
  end
111
117
 
112
118
  def inline_mode
@@ -118,7 +124,11 @@ module Danger
118
124
  end
119
125
 
120
126
  def strict
121
- @strict.nil? ? true : @strict
127
+ @strict.nil? || @strict
128
+ end
129
+
130
+ def collapse_parallelized_tests
131
+ @collapse_parallelized_tests || false
122
132
  end
123
133
 
124
134
  # Pick a Dangerfile plugin for a chosen request_source and cache it
@@ -211,26 +221,63 @@ module Danger
211
221
 
212
222
  def messages(xcode_summary)
213
223
  if test_summary
214
- test_messages = xcode_summary.action_test_plan_summaries.map do |test_plan_summaries|
224
+ test_runs = xcode_summary.action_test_plan_summaries.map do |test_plan_summaries|
215
225
  test_plan_summaries.summaries.map do |summary|
216
226
  summary.testable_summaries.map do |test_summary|
217
227
  test_summary.tests.filter_map do |action_test_object|
218
228
  if action_test_object.instance_of? XCResult::ActionTestSummaryGroup
219
229
  subtests = action_test_object.all_subtests
220
230
  subtests_duration = subtests.map(&:duration).sum
221
- test_text_infix = subtests.count == 1 ? 'test' : 'tests'
231
+
222
232
  failed_tests_count = subtests.reject { |test| test.test_status == 'Success' }.count
223
233
  expected_failed_tests_count = subtests.select { |test| test.test_status == 'Expected Failure' }.count
224
234
 
225
- "#{test_summary.target_name}: Executed #{subtests.count} #{test_text_infix}, " \
226
- "with #{failed_tests_count} failures (#{expected_failed_tests_count} expected) in " \
227
- "#{subtests_duration.round(3)} (#{action_test_object.duration.round(3)}) seconds"
235
+ {
236
+ target_name: test_summary.target_name,
237
+ test_count: subtests.count,
238
+ failed_tests_count: failed_tests_count,
239
+ expected_failed_tests_count: expected_failed_tests_count,
240
+ tests_duration: subtests_duration,
241
+ action_duration: action_test_object.duration
242
+ }
228
243
  end
229
244
  end
230
245
  end
231
246
  end
232
247
  end
233
- test_messages.flatten.uniq.compact.map(&:strip)
248
+
249
+ flattened_test_runs = test_runs.flatten.uniq.compact
250
+
251
+ if collapse_parallelized_tests
252
+ test_runs_by_target = flattened_test_runs.group_by { |test_run| test_run[:target_name] }
253
+ flattened_test_runs = test_runs_by_target.map do |target_name, test_runs|
254
+ test_runs.reduce do |acc, test_run|
255
+ acc.merge(
256
+ test_count: acc[:test_count] + test_run[:test_count],
257
+ failed_tests_count: acc[:failed_tests_count] + test_run[:failed_tests_count],
258
+ expected_failed_tests_count: acc[:expected_failed_tests_count] + test_run[:expected_failed_tests_count],
259
+ tests_duration: acc[:tests_duration] + test_run[:tests_duration],
260
+ action_duration: acc[:action_duration] + test_run[:action_duration]
261
+ )
262
+ end
263
+ end
264
+ end
265
+
266
+ test_messages = flattened_test_runs.map do |test_run|
267
+ target_name = test_run[:target_name]
268
+ test_count = test_run[:test_count]
269
+ failed_tests_count = test_run[:failed_tests_count]
270
+ expected_failed_tests_count = test_run[:expected_failed_tests_count]
271
+ subtests_duration = test_run[:tests_duration]
272
+ action_duration = test_run[:action_duration]
273
+ test_text_infix = test_count == 1 ? 'test' : 'tests'
274
+
275
+ "#{target_name}: Executed #{test_count} #{test_text_infix}, " \
276
+ "with #{failed_tests_count} failures (#{expected_failed_tests_count} expected) in " \
277
+ "#{subtests_duration.round(3)} (#{action_duration.round(3)}) seconds"
278
+ end
279
+
280
+ test_messages.map(&:strip)
234
281
  else
235
282
  []
236
283
  end
data/spec/spec_helper.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'pathname'
4
4
  ROOT = Pathname.new(File.expand_path('..', __dir__))
5
- $LOAD_PATH.unshift("#{ROOT}lib".to_s)
6
- $LOAD_PATH.unshift("#{ROOT}spec".to_s)
5
+ $LOAD_PATH.unshift("#{ROOT}lib")
6
+ $LOAD_PATH.unshift("#{ROOT}spec")
7
7
 
8
8
  require 'bundler/setup'
9
9
  require 'pry'
@@ -30,7 +30,6 @@ end
30
30
  # it comes with an extra function `.string` which will
31
31
  # strip all ANSI colours from the string.
32
32
 
33
- # rubocop:disable Lint/NestedMethodDefinition
34
33
  def testing_ui
35
34
  @output = StringIO.new
36
35
  def @output.winsize
@@ -43,7 +42,6 @@ def testing_ui
43
42
  end
44
43
  cork
45
44
  end
46
- # rubocop:enable Lint/NestedMethodDefinition
47
45
 
48
46
  # Example environment (ENV) that would come from
49
47
  # running a PR on TravisCI
@@ -257,6 +257,60 @@ module Danger
257
257
  expect(result).to eq '{"warnings":21,"errors":3}'
258
258
  end
259
259
  end
260
+
261
+ context 'with collapse_parallelized_tests' do
262
+ context 'enabled' do
263
+ before do
264
+ @xcode_summary.collapse_parallelized_tests = true
265
+ end
266
+
267
+ it 'collapses test runs from the same target' do
268
+ # Allow for message receiving testing
269
+ allow(@xcode_summary).to receive(:message).and_call_original
270
+ @xcode_summary.report('spec/fixtures/swiftlint.xcresult')
271
+
272
+ # Ensure that the plugin received a call to message with the combined test results
273
+ expect(@xcode_summary).to have_received(:message).with(/SwiftLintFrameworkTests: Executed .* tests/m, sticky: false)
274
+
275
+ # The standard test case should only show one message per target, even with parallelized tests
276
+ expect(@dangerfile.status_report[:messages].length).to eq(1)
277
+ end
278
+ end
279
+
280
+ context 'disabled' do
281
+ before do
282
+ @xcode_summary.collapse_parallelized_tests = false
283
+ end
284
+
285
+ it 'shows individual test runs for each target' do
286
+ @xcode_summary.report('spec/fixtures/swiftlint.xcresult')
287
+
288
+ # We know from the existing tests that the standard behavior should match
289
+ # the test in the "summary" context, with one test run per message
290
+ expect(@dangerfile.status_report[:messages]).to eq [
291
+ 'SwiftLintFrameworkTests: Executed 540 tests, with 1 failures (0 expected) in 114.029 (27.922) seconds'
292
+ ]
293
+ end
294
+ end
295
+
296
+ context 'with default value' do
297
+ it 'defaults to disabled behavior' do
298
+ # Don't set collapse_parallelized_tests to test the default
299
+ # Reset any test_summary setting to ensure clean state
300
+ @xcode_summary.test_summary = true
301
+
302
+ @xcode_summary.report('spec/fixtures/swiftlint.xcresult')
303
+
304
+ # Default should match the disabled behavior
305
+ expect(@dangerfile.status_report[:messages]).to eq [
306
+ 'SwiftLintFrameworkTests: Executed 540 tests, with 1 failures (0 expected) in 114.029 (27.922) seconds'
307
+ ]
308
+
309
+ # Verify the default value is false
310
+ expect(@xcode_summary.collapse_parallelized_tests).to eq(false)
311
+ end
312
+ end
313
+ end
260
314
  end
261
315
  end
262
316
 
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: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diogo Tridapalli
@@ -9,36 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-14 00:00:00.000000000 Z
12
+ date: 2025-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: xcresult
15
+ name: danger-plugin-api
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0.2'
20
+ version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0.2'
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: danger-plugin-api
29
+ name: xcresult
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.0'
34
+ version: 0.2.2
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.0'
41
+ version: 0.2.2
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement