gitlab-qa 5.2.0 → 5.3.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: 2f147da355d03473a605dacab05054698ebf98b19f4af618d93bff89cbe09260
4
- data.tar.gz: 5f674b1e20a26f2bb6de4588ce02f58450e820701f099372018382bc24783702
3
+ metadata.gz: 7e9cf3fd69ecf574cc318f194a49e715050b7fe6708327c1555264c589722de3
4
+ data.tar.gz: 695c6e1e0b2f49615b42b83765353c80c0613b832636231bad0022dbddb2efcb
5
5
  SHA512:
6
- metadata.gz: ccac752f52ac37f38cbf295ce1b2dd4d92811545a0c3dc244b9930b1140317985523a39cdfaa45c25df129e82973e19abf98420011a941d01c43ed02355c4f3d
7
- data.tar.gz: e4be9776a75aba05c1ba40eff3de70e18616856f8c3f72ae5850e1fffb86ddc11f8b72c04d83c205b2088e5ce31459b3e2b7bc7c127810609a757fcdf726bc5c
6
+ metadata.gz: 2cc293bccacd51527427585000e3058fc2853254c890f4965d3cb0245395b0e12455cbf57f50b1555414a7dd74b375d6f6061a2a7be24d0ecc3dc59360e732eb
7
+ data.tar.gz: 4b4de8b9fdb59f1ac502a9d5c0d25184bf80121aea31a549cb8577c578ea7fbaa8166803b886872f59a5873eee430c0435a70641d4d20c87d90febca1ff372a1
@@ -5,10 +5,18 @@ require 'gitlab'
5
5
  require 'active_support/core_ext/enumerable'
6
6
 
7
7
  module Gitlab
8
- # Monkey patch the Gitlab client to use the correct API path
8
+ # Monkey patch the Gitlab client to use the correct API path and add required methods
9
9
  class Client
10
10
  def team_member(project, id)
11
- get("/projects/#{url_encode project}/members/all/#{id}")
11
+ get("/projects/#{url_encode(project)}/members/all/#{id}")
12
+ end
13
+
14
+ def issue_discussions(project, issue_id, options = {})
15
+ get("/projects/#{url_encode(project)}/issues/#{issue_id}/discussions", query: options)
16
+ end
17
+
18
+ def add_note_to_issue_discussion_as_thread(project, issue_id, discussion_id, options = {})
19
+ post("/projects/#{url_encode(project)}/issues/#{issue_id}/discussions/#{discussion_id}/notes", query: options)
12
20
  end
13
21
  end
14
22
 
@@ -141,6 +149,16 @@ module Gitlab
141
149
  def note_status(issue, test)
142
150
  return if failures(test).empty?
143
151
 
152
+ note = note_content(test)
153
+
154
+ Gitlab.issue_discussions(project, issue.iid, order_by: 'created_at', sort: 'asc').each do |discussion|
155
+ return add_note_to_discussion(issue.iid, discussion.id) if new_note_matches_discussion?(note, discussion)
156
+ end
157
+
158
+ Gitlab.create_issue_note(project, issue.iid, note)
159
+ end
160
+
161
+ def note_content(test)
144
162
  errors = failures(test).each_with_object([]) do |failure, text|
145
163
  text << <<~TEXT
146
164
  Error:
@@ -155,7 +173,23 @@ module Gitlab
155
173
  TEXT
156
174
  end.join("\n\n")
157
175
 
158
- Gitlab.create_issue_note(project, issue.iid, ":x: ~\"#{pipeline}::failed\" in job `#{Runtime::Env.ci_job_name}` in #{Runtime::Env.ci_job_url}\n\n#{errors}")
176
+ "#{failure_summary}\n\n#{errors}"
177
+ end
178
+
179
+ def failure_summary
180
+ ":x: ~\"#{pipeline}::failed\" in job `#{Runtime::Env.ci_job_name}` in #{Runtime::Env.ci_job_url}"
181
+ end
182
+
183
+ def new_note_matches_discussion?(note, discussion)
184
+ error_and_stack_trace(note) == error_and_stack_trace(discussion.notes.first['body'])
185
+ end
186
+
187
+ def error_and_stack_trace(text)
188
+ text.strip[/Error:(.*)/, 1]
189
+ end
190
+
191
+ def add_note_to_discussion(issue_iid, discussion_id)
192
+ Gitlab.add_note_to_issue_discussion_as_thread(project, issue_iid, discussion_id, body: failure_summary)
159
193
  end
160
194
 
161
195
  def update_labels(issue, test)
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '5.2.0'.freeze
3
+ VERSION = '5.3.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Bizon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-23 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control