gitlab_quality-test_tooling 2.5.0 → 2.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: cd181fe7622793361cd772d2f949d1a8922f4b0762c2d50ae9f839fdfd69bb86
4
- data.tar.gz: aaa900d8e19eff7ae0016bda52bf6dc3722aa4e4fe288f16c16d6685254c831a
3
+ metadata.gz: 279a7eab459c664263a3506753c09d78111784af48af599cab26ed8928f54e2a
4
+ data.tar.gz: '06388341bfbb2c868ae25569af2597666f64cdb7e980465078a78778081ca107'
5
5
  SHA512:
6
- metadata.gz: 5b5e1a85230726944574ec3c92c9fbe0e8a547776a6a7f7ce07d4db1889abf1a23b35a8b13b55d79eaf90eb3b7cfac4ec47960efa9eedaa509ffa02dd9655077
7
- data.tar.gz: 47f438135b5ac5d4cc2cfc95a30e6a917f6de4c714bd8f42ed74c4d51439af925ac1424bf2105e71c76cd581f5faf287d8d0a415bf4c220df36df2fd85ec6149
6
+ metadata.gz: cd37eca775b6899df0e476d11499ee491a8ea4278d88bf8f9584feb3cb8d1245da3319aa534ed4743c06ca1bd7da7a4eefcf619aa26688eb895bf3168d58eb9d
7
+ data.tar.gz: 58f7c549202b39a20d6d5b5fc117e9017a044ee2e6bff63f07b82dda9650ed819f43407f20a5363d638b986fb8860d69c2452ea68bdf7fe5b7e33e70abb281b4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (2.5.0)
4
+ gitlab_quality-test_tooling (2.6.0)
5
5
  activesupport (>= 7.0, < 7.2)
6
6
  amatch (~> 0.4.1)
7
7
  fog-google (~> 1.24, >= 1.24.1)
@@ -122,6 +122,21 @@ module GitlabQuality
122
122
  end
123
123
  end
124
124
 
125
+ def find_pipeline(project, pipeline_id)
126
+ handle_gitlab_client_exceptions do
127
+ client.pipeline(project, pipeline_id)
128
+ end
129
+ end
130
+
131
+ def find_commit_parent(project, sha)
132
+ handle_gitlab_client_exceptions do
133
+ # In a merged results commit, the first parent is the one from
134
+ # the main branch, and the second parent is from the branch
135
+ # itself (more likely to have caused the issue)
136
+ client.commit(project, sha).parent_ids.last
137
+ end
138
+ end
139
+
125
140
  private
126
141
 
127
142
  attr_reader :token, :project
@@ -113,11 +113,11 @@ module GitlabQuality
113
113
  end
114
114
  end
115
115
 
116
- def initial_reports_section(test)
116
+ def initial_reports_section(test, item_extra_content: nil)
117
117
  <<~REPORTS
118
118
  ### Reports (1)
119
119
 
120
- #{ReportsList.report_list_item(test)}
120
+ #{ReportsList.report_list_item(test, item_extra_content: item_extra_content)}
121
121
  REPORTS
122
122
  end
123
123
 
@@ -26,6 +26,13 @@ module GitlabQuality
26
26
  NEW_ISSUE_LABELS = Set.new(%w[test failure::new priority::2 automation:bot-authored]).freeze
27
27
  SCREENSHOT_IGNORED_ERRORS = ['500 Internal Server Error', 'fabricate_via_api!', 'Error Code 500'].freeze
28
28
 
29
+ # Map commits to security fork (gitlab-org/security/gitlab) for gitlab-org/gitlab since security patches exist
30
+ # there before being released to the public repository
31
+ DIFF_PROJECT_MAPPINGS = {
32
+ 'gitlab-org/gitlab' => 'gitlab-org/security/gitlab',
33
+ 'gitlab-org/customers-gitlab-com' => 'gitlab-org/customers-gitlab-com'
34
+ }.freeze
35
+
29
36
  MultipleIssuesFound = Class.new(StandardError)
30
37
 
31
38
  def initialize(
@@ -271,14 +278,27 @@ module GitlabQuality
271
278
 
272
279
  def new_issue_description(test)
273
280
  super + [
274
- "\n### Stack trace",
281
+ "\n#{compare_against_previous_commit}",
282
+ "### Stack trace",
275
283
  "```\n#{test.full_stacktrace}\n```",
276
284
  screenshot_section(test),
277
285
  system_log_errors_section(test),
278
- initial_reports_section(test)
286
+ initial_reports_section(test, item_extra_content: screenshot_artifact_url(test))
279
287
  ].compact.join("\n\n")
280
288
  end
281
289
 
290
+ def compare_against_previous_commit
291
+ pipeline_sha = gitlab.find_pipeline(project, Runtime::Env.ci_pipeline_id.to_i).sha
292
+ parent_sha = gitlab.find_commit_parent(project, pipeline_sha)
293
+ diff_project = if DIFF_PROJECT_MAPPINGS.key?(project)
294
+ DIFF_PROJECT_MAPPINGS[project]
295
+ else
296
+ raise "Project #{project} is not supported for commit diff links"
297
+ end
298
+
299
+ "### Commit diff\nhttps://gitlab.com/#{diff_project}/-/compare/#{parent_sha}...#{pipeline_sha}"
300
+ end
301
+
282
302
  def system_log_errors_section(test)
283
303
  correlation_id = test.failures.first['correlation_id']
284
304
  section = ''
@@ -322,7 +342,7 @@ module GitlabQuality
322
342
  state_event = issue.state == 'closed' ? 'reopen' : nil
323
343
 
324
344
  issue_attrs = {
325
- description: increment_reports(current_reports_content: issue.description, test: test).to_s,
345
+ description: increment_reports(current_reports_content: issue.description, test: test, item_extra_content: screenshot_artifact_url(test)).to_s,
326
346
  labels: up_to_date_labels(test: test, issue: issue)
327
347
  }
328
348
  issue_attrs[:state_event] = state_event if state_event
@@ -386,6 +406,13 @@ module GitlabQuality
386
406
  .filter_map { |e| failure_to_ignore.find { |m| e['message'].include?(m) } }
387
407
  .compact
388
408
  end
409
+
410
+ def screenshot_artifact_url(test)
411
+ ci_job_url = test.ci_job_url
412
+ screenshot_path = test.screenshot_image[%r{qa/.*$}]
413
+
414
+ "|| [Screenshot](#{ci_job_url}/artifacts/file/#{screenshot_path})"
415
+ end
389
416
  end
390
417
  end
391
418
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "2.5.0"
5
+ VERSION = "2.6.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_quality-test_tooling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2025-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control