allure-report-publisher 1.5.0 → 1.6.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
  SHA256:
3
- metadata.gz: 07a7cbb97bb51a2b34c181118b0f3dab1e8f8dda56bb1f5e54bd9edbd8ef1dbc
4
- data.tar.gz: 415d123215bb47736b34c8db0357fd5582e47f0dd682b7591a96fb35bd045df3
3
+ metadata.gz: ee22a2a52b71b269de3fb6edd02c444b3bf6e553f051bd1e8b495f6cffbb2b80
4
+ data.tar.gz: e87c8cec9aa3c444cb7d2225d9cc401a9c7f39d0940ed5b57ca8a5d5a2368f77
5
5
  SHA512:
6
- metadata.gz: 1e49a526285c93956391579ed1f40583e28f92ecdb03032632277c7a747cc8ab7971df2ca2b6e92d9b3eafa566e209c42d5173211d77f6487b3a6c9436f81b33
7
- data.tar.gz: 26e2179fa6ad5037c0a9aad9b2c37ffd1d37d70af316cce9cc00cd7dc074eefe9819373ec4594a4507b130f72688298ca566682d6e6ea177a442015f3e56f235
6
+ metadata.gz: 472478dd1264503de2409b2eb6c2b9fb5239624aff499987d5741ca6ee3d22a9c7397dc85c1af3b9718b7fbfbbcfe1d842e48d1350452877041a40829f59bdc3
7
+ data.tar.gz: e24e932b8dd7d05e651dcb4622fd50381bde03f931547160918c6ff25b943f858b8e9f19291d5db7da2635d5926faf5fac2d43d33bf38c48d37c3cc77fd55b9b
data/README.md CHANGED
@@ -54,6 +54,7 @@ Options:
54
54
  --[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
55
55
  --[no-]color # Force color output
56
56
  --[no-]ignore-missing-results # Ignore missing allure results, default: false
57
+ --[no-]unresolved-discussion-on-failure # Add an unresolved discussion comment on test failure. GitLab only, default: false
57
58
  --[no-]debug # Print additional debug output, default: false
58
59
  --help, -h # Print this help
59
60
 
@@ -157,10 +158,14 @@ Following environment variables can override default CI values:
157
158
 
158
159
  Additional configuration is done via environment variables
159
160
 
161
+ ### Authentication
162
+
160
163
  Authentication for MR updates:
161
164
 
162
165
  - `GITLAB_AUTH_TOKEN`: gitlab access token with api access
163
166
 
167
+ ### CI values
168
+
164
169
  Following environment variables can override default CI values:
165
170
 
166
171
  - `ALLURE_JOB_NAME`: overrides default `CI_JOB_NAME` value which is used as name for report url section
@@ -171,6 +176,12 @@ In case merge request triggers a downstream pipeline yet you want to update orig
171
176
  - `ALLURE_MERGE_REQUEST_IID`: overrides default `CI_MERGE_REQUEST_IID` value
172
177
  - `ALLURE_COMMIT_SHA`: overrides default `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` or `CI_COMMIT_SHA` values
173
178
 
179
+ ### Summary comment behavior
180
+
181
+ If reporter is executed with options `--update-pr=comment` and `--unresolved-discussion-on-failure`, it's possible to additionally configure the unresolved discussion note:
182
+
183
+ - `ALLURE_FAILURE_ALERT_COMMENT`: comment added to create unresolved discussion note, default: `There are some test failures that need attention`
184
+
174
185
  # Development
175
186
 
176
187
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -60,6 +60,10 @@ module Publisher
60
60
  type: :boolean,
61
61
  default: false,
62
62
  desc: "Ignore missing allure results"
63
+ option :unresolved_discussion_on_failure,
64
+ type: :boolean,
65
+ default: false,
66
+ desc: "Add an unresolved discussion comment on test failure. GitLab only"
63
67
  option :debug,
64
68
  type: :boolean,
65
69
  default: false,
@@ -104,7 +108,8 @@ module Publisher
104
108
  :copy_latest,
105
109
  :update_pr,
106
110
  :collapse_summary,
107
- :summary_table_type
111
+ :summary_table_type,
112
+ :unresolved_discussion_on_failure
108
113
  )
109
114
  )
110
115
  end
@@ -54,6 +54,16 @@ module Publisher
54
54
  end
55
55
  end
56
56
 
57
+ # Return non empty environment variable value
58
+ #
59
+ # @param [String] name
60
+ # @return [String, nil]
61
+ def env(name)
62
+ return unless ENV[name] && !ENV[name].empty?
63
+
64
+ ENV[name]
65
+ end
66
+
57
67
  # Colorize string
58
68
  #
59
69
  # @param [String] message
@@ -23,6 +23,7 @@ module Publisher
23
23
  # @option args [Boolean] :update_pr
24
24
  # @option args [String] :summary_type
25
25
  # @option args [Boolean] :collapse_summay
26
+ # @option args [Boolean] :unresolved_discussion_on_failure
26
27
  # @option args [Symbol] :summary_table_type
27
28
  def initialize(**args)
28
29
  @report_url = args[:report_url]
@@ -31,6 +32,7 @@ module Publisher
31
32
  @summary_type = args[:summary_type]
32
33
  @summary_table_type = args[:summary_table_type]
33
34
  @collapse_summary = args[:collapse_summary]
35
+ @unresolved_discussion_on_failure = args[:unresolved_discussion_on_failure]
34
36
  end
35
37
 
36
38
  # :nocov:
@@ -76,7 +78,8 @@ module Publisher
76
78
  :update_pr,
77
79
  :summary_type,
78
80
  :collapse_summary,
79
- :summary_table_type
81
+ :summary_table_type,
82
+ :unresolved_discussion_on_failure
80
83
 
81
84
  # Current pull request description
82
85
  #
@@ -58,28 +58,68 @@ module Publisher
58
58
  )
59
59
  end
60
60
 
61
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
61
62
  # Add comment with report url
62
63
  #
63
64
  # @return [void]
64
65
  def add_comment
65
- unless comment
66
+ if main_comment
67
+ log_debug("Updating summary in comment with id #{discussion.id} in mr !#{mr_iid}")
68
+
69
+ client.edit_merge_request_note(
70
+ project,
71
+ mr_iid,
72
+ main_comment.id,
73
+ url_section_builder.comment_body(main_comment.body)
74
+ )
75
+ else
66
76
  log_debug("Creating comment with summary for mr ! #{mr_iid}")
67
- return client.create_merge_request_comment(project, mr_iid, url_section_builder.comment_body)
77
+ client.create_merge_request_comment(project, mr_iid, url_section_builder.comment_body)
78
+ end
79
+
80
+ @discussion = nil
81
+
82
+ if unresolved_discussion_on_failure && main_comment&.body&.include?("❌") && !alert_comment
83
+ client.create_merge_request_discussion_note(project, mr_iid, discussion.id, body: alert_comment_text)
84
+ elsif alert_comment
85
+ client.delete_merge_request_discussion_note(project, mr_iid, discussion.id, alert_comment.id)
86
+ end
87
+ end
88
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
89
+
90
+ # Existing discussion that has comment with allure urls
91
+ #
92
+ # @return [Gitlab::ObjectifiedHash]
93
+ def discussion
94
+ @discussion ||= client.merge_request_discussions(project, mr_iid).auto_paginate.detect do |discussion|
95
+ discussion.notes.any? { |note| Helpers::UrlSectionBuilder.match?(note.body) }
68
96
  end
97
+ end
69
98
 
70
- log_debug("Updating summary in comment with id #{comment.id} in mr !#{mr_iid}")
71
- client.edit_merge_request_note(project, mr_iid, comment.id, url_section_builder.comment_body(comment.body))
99
+ # Comment/note with allure urls
100
+ #
101
+ # @return [Gitlab::ObjectifiedHash]
102
+ def main_comment
103
+ discussion&.notes&.detect { |note| Helpers::UrlSectionBuilder.match?(note.body) }
72
104
  end
73
105
 
74
- # Existing comment with allure urls
106
+ # Comment with alert text
75
107
  #
76
108
  # @return [Gitlab::ObjectifiedHash]
77
- def comment
78
- client.merge_request_comments(project, mr_iid).auto_paginate.detect do |comment|
79
- Helpers::UrlSectionBuilder.match?(comment.body)
109
+ def alert_comment
110
+ @alert_comment ||= discussion&.notes&.detect do |note|
111
+ note.body.include?(alert_comment_text)
80
112
  end
81
113
  end
82
114
 
115
+ # Text for alert comment
116
+ #
117
+ # @return [String]
118
+ def alert_comment_text
119
+ @alert_comment_text ||=
120
+ env("ALLURE_FAILURE_ALERT_COMMENT") || "There are some test failures that need attention"
121
+ end
122
+
83
123
  # Get gitlab client
84
124
  #
85
125
  # @return [Gitlab::Client]
@@ -159,16 +199,6 @@ module Publisher
159
199
 
160
200
  "[#{short_sha}](#{server_url}/#{project}/-/merge_requests/#{mr_iid}/diffs?commit_id=#{sha})"
161
201
  end
162
-
163
- # Return non empty environment variable value
164
- #
165
- # @param [String] name
166
- # @return [String, nil]
167
- def env(name)
168
- return unless ENV[name] && !ENV[name].empty?
169
-
170
- ENV[name]
171
- end
172
202
  end
173
203
  end
174
204
  end
@@ -33,6 +33,7 @@ module Publisher
33
33
  # @option args [String] :summary_type
34
34
  # @option args [Symbol] :summary_table_type
35
35
  # @option args [Boolean] :collapse_summary
36
+ # @option args [Boolean] :unresolved_discussion_on_failure
36
37
  # @option args [String] :copy_latest
37
38
  def initialize(**args)
38
39
  @result_paths = args[:result_paths]
@@ -44,6 +45,7 @@ module Publisher
44
45
  @summary_table_type = args[:summary_table_type]
45
46
  @copy_latest = (Providers.provider && args[:copy_latest]) # copy latest for ci only
46
47
  @collapse_summary = args[:collapse_summary]
48
+ @unresolved_discussion_on_failure = args[:unresolved_discussion_on_failure]
47
49
  end
48
50
 
49
51
  # Execute allure report generation and upload
@@ -111,7 +113,8 @@ module Publisher
111
113
  :copy_latest,
112
114
  :summary_type,
113
115
  :collapse_summary,
114
- :summary_table_type
116
+ :summary_table_type,
117
+ :unresolved_discussion_on_failure
115
118
 
116
119
  def_delegators :report_generator, :common_info_path, :report_path
117
120
 
@@ -213,7 +216,8 @@ module Publisher
213
216
  update_pr: update_pr,
214
217
  summary_type: summary_type,
215
218
  summary_table_type: summary_table_type,
216
- collapse_summary: collapse_summary
219
+ collapse_summary: collapse_summary,
220
+ unresolved_discussion_on_failure: unresolved_discussion_on_failure
217
221
  )
218
222
  end
219
223
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "1.5.0"
4
+ VERSION = "1.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-report-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-06 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.93.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.121.0
22
+ version: 1.123.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 1.93.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.121.0
32
+ version: 1.123.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dry-cli
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -202,194 +202,6 @@ dependencies:
202
202
  - - "~>"
203
203
  - !ruby/object:Gem::Version
204
204
  version: 0.9.3
205
- - !ruby/object:Gem::Dependency
206
- name: activesupport
207
- requirement: !ruby/object:Gem::Requirement
208
- requirements:
209
- - - "~>"
210
- - !ruby/object:Gem::Version
211
- version: '7.0'
212
- type: :development
213
- prerelease: false
214
- version_requirements: !ruby/object:Gem::Requirement
215
- requirements:
216
- - - "~>"
217
- - !ruby/object:Gem::Version
218
- version: '7.0'
219
- - !ruby/object:Gem::Dependency
220
- name: allure-rspec
221
- requirement: !ruby/object:Gem::Requirement
222
- requirements:
223
- - - "~>"
224
- - !ruby/object:Gem::Version
225
- version: 2.20.0
226
- type: :development
227
- prerelease: false
228
- version_requirements: !ruby/object:Gem::Requirement
229
- requirements:
230
- - - "~>"
231
- - !ruby/object:Gem::Version
232
- version: 2.20.0
233
- - !ruby/object:Gem::Dependency
234
- name: climate_control
235
- requirement: !ruby/object:Gem::Requirement
236
- requirements:
237
- - - "~>"
238
- - !ruby/object:Gem::Version
239
- version: 1.2.0
240
- type: :development
241
- prerelease: false
242
- version_requirements: !ruby/object:Gem::Requirement
243
- requirements:
244
- - - "~>"
245
- - !ruby/object:Gem::Version
246
- version: 1.2.0
247
- - !ruby/object:Gem::Dependency
248
- name: debug
249
- requirement: !ruby/object:Gem::Requirement
250
- requirements:
251
- - - "~>"
252
- - !ruby/object:Gem::Version
253
- version: '1.0'
254
- - - ">="
255
- - !ruby/object:Gem::Version
256
- version: 1.0.0
257
- type: :development
258
- prerelease: false
259
- version_requirements: !ruby/object:Gem::Requirement
260
- requirements:
261
- - - "~>"
262
- - !ruby/object:Gem::Version
263
- version: '1.0'
264
- - - ">="
265
- - !ruby/object:Gem::Version
266
- version: 1.0.0
267
- - !ruby/object:Gem::Dependency
268
- name: rake
269
- requirement: !ruby/object:Gem::Requirement
270
- requirements:
271
- - - "~>"
272
- - !ruby/object:Gem::Version
273
- version: '13.0'
274
- type: :development
275
- prerelease: false
276
- version_requirements: !ruby/object:Gem::Requirement
277
- requirements:
278
- - - "~>"
279
- - !ruby/object:Gem::Version
280
- version: '13.0'
281
- - !ruby/object:Gem::Dependency
282
- name: rspec
283
- requirement: !ruby/object:Gem::Requirement
284
- requirements:
285
- - - "~>"
286
- - !ruby/object:Gem::Version
287
- version: '3.11'
288
- type: :development
289
- prerelease: false
290
- version_requirements: !ruby/object:Gem::Requirement
291
- requirements:
292
- - - "~>"
293
- - !ruby/object:Gem::Version
294
- version: '3.11'
295
- - !ruby/object:Gem::Dependency
296
- name: rubocop
297
- requirement: !ruby/object:Gem::Requirement
298
- requirements:
299
- - - "~>"
300
- - !ruby/object:Gem::Version
301
- version: '1.27'
302
- type: :development
303
- prerelease: false
304
- version_requirements: !ruby/object:Gem::Requirement
305
- requirements:
306
- - - "~>"
307
- - !ruby/object:Gem::Version
308
- version: '1.27'
309
- - !ruby/object:Gem::Dependency
310
- name: rubocop-performance
311
- requirement: !ruby/object:Gem::Requirement
312
- requirements:
313
- - - "~>"
314
- - !ruby/object:Gem::Version
315
- version: '1.13'
316
- type: :development
317
- prerelease: false
318
- version_requirements: !ruby/object:Gem::Requirement
319
- requirements:
320
- - - "~>"
321
- - !ruby/object:Gem::Version
322
- version: '1.13'
323
- - !ruby/object:Gem::Dependency
324
- name: rubocop-rake
325
- requirement: !ruby/object:Gem::Requirement
326
- requirements:
327
- - - "~>"
328
- - !ruby/object:Gem::Version
329
- version: 0.6.0
330
- type: :development
331
- prerelease: false
332
- version_requirements: !ruby/object:Gem::Requirement
333
- requirements:
334
- - - "~>"
335
- - !ruby/object:Gem::Version
336
- version: 0.6.0
337
- - !ruby/object:Gem::Dependency
338
- name: rubocop-rspec
339
- requirement: !ruby/object:Gem::Requirement
340
- requirements:
341
- - - "~>"
342
- - !ruby/object:Gem::Version
343
- version: '2.9'
344
- type: :development
345
- prerelease: false
346
- version_requirements: !ruby/object:Gem::Requirement
347
- requirements:
348
- - - "~>"
349
- - !ruby/object:Gem::Version
350
- version: '2.9'
351
- - !ruby/object:Gem::Dependency
352
- name: simplecov
353
- requirement: !ruby/object:Gem::Requirement
354
- requirements:
355
- - - "~>"
356
- - !ruby/object:Gem::Version
357
- version: 0.22.0
358
- type: :development
359
- prerelease: false
360
- version_requirements: !ruby/object:Gem::Requirement
361
- requirements:
362
- - - "~>"
363
- - !ruby/object:Gem::Version
364
- version: 0.22.0
365
- - !ruby/object:Gem::Dependency
366
- name: simplecov-console
367
- requirement: !ruby/object:Gem::Requirement
368
- requirements:
369
- - - "~>"
370
- - !ruby/object:Gem::Version
371
- version: 0.9.1
372
- type: :development
373
- prerelease: false
374
- version_requirements: !ruby/object:Gem::Requirement
375
- requirements:
376
- - - "~>"
377
- - !ruby/object:Gem::Version
378
- version: 0.9.1
379
- - !ruby/object:Gem::Dependency
380
- name: solargraph
381
- requirement: !ruby/object:Gem::Requirement
382
- requirements:
383
- - - "~>"
384
- - !ruby/object:Gem::Version
385
- version: 0.49.0
386
- type: :development
387
- prerelease: false
388
- version_requirements: !ruby/object:Gem::Requirement
389
- requirements:
390
- - - "~>"
391
- - !ruby/object:Gem::Version
392
- version: 0.49.0
393
205
  description: Upload allure reports to different file storage providers
394
206
  email:
395
207
  - andrejs.cunskis@gmail.com