gitlab-qa 6.12.0 → 6.13.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: a7db5ca406c7143f6b4b8ac2d5061080f52157dbe77f23459fdf15919cc24209
4
- data.tar.gz: b0dca304397f7c373ca94b41936f8d04db818b797dc9a09e05e31accfd8a9cfd
3
+ metadata.gz: '0692b909c3bf06d12d5f0846dc3296b93755d0c58c5969a71773e9664b298a8c'
4
+ data.tar.gz: 3aac312bb7b6dd2244d92b9bbf9ce1ecf561c65caae723abca625b155c00cfa4
5
5
  SHA512:
6
- metadata.gz: 25678e888d7a338ef9f54269927e16ab6d5f60bc4b37175185bda64174689d9aecf40ac35c7d31be15e6fb1305527604f4667f09aa6c89f42ba4e02c7187a68d
7
- data.tar.gz: ff1c2808b0030677ba8420444e4cb303b0d58d6751511bef90a8bcbea98df6a98e1efea83945d7b6488f076eb8f978519198b4938dc9b99503bd97c0d2b9ea57
6
+ metadata.gz: 05c3a6b9ad1eec8d6adf2892ae3b90568bbfebc7f7def626126ae2b14da9be902b71edd8d45a7c98a3cb89b596fa6cee6b352da159f7e3ae1ca2daf8b37dc176
7
+ data.tar.gz: 4554af9b7849516651be2e5f32f4fd5d57690b4af2787292d4b18e6a8838fad92201a9d101edcbc9c2391327322fdaca96a37393fe6ea1a3111f734be7934d2f
@@ -6,6 +6,7 @@ module Gitlab
6
6
  class GenerateTestSession < ReportAsIssue
7
7
  private
8
8
 
9
+ # rubocop:disable Metrics/AbcSize
9
10
  def run!
10
11
  puts "Generating test results in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
11
12
 
@@ -18,11 +19,12 @@ module Gitlab
18
19
  issue = gitlab.create_issue(
19
20
  title: "Test session report | #{Runtime::Env.deploy_environment}",
20
21
  description: generate_description(tests),
21
- labels: ['Quality', 'QA', 'triage report']
22
+ labels: ['Quality', 'QA', 'triage report', deploy_environment_label]
22
23
  )
23
24
 
24
25
  File.write('REPORT_ISSUE_URL', issue.web_url)
25
26
  end
27
+ # rubocop:enable Metrics/AbcSize
26
28
 
27
29
  def generate_description(tests)
28
30
  <<~MARKDOWN
@@ -32,6 +34,8 @@ module Gitlab
32
34
  * Pipeline: [#{Runtime::Env.ci_pipeline_id}](#{Runtime::Env.ci_pipeline_url})
33
35
  #{generate_summary(tests: tests)}
34
36
 
37
+ #{generate_failed_jobs_listing}
38
+
35
39
  #{generate_stages_listing(tests)}
36
40
 
37
41
  ## Release QA issue
@@ -55,6 +59,27 @@ module Gitlab
55
59
  MARKDOWN
56
60
  end
57
61
 
62
+ def generate_failed_jobs_listing
63
+ gitlab.handle_gitlab_client_exceptions do
64
+ failed_jobs = Gitlab.pipeline_jobs(
65
+ Runtime::Env.ci_project_id,
66
+ Runtime::Env.ci_pipeline_id,
67
+ scope: 'failed')
68
+
69
+ listings = failed_jobs.map do |job|
70
+ allowed_to_fail = ' (allowed to fail)' if job.allow_failure
71
+
72
+ "* [#{job.name}](#{job.web_url})#{allowed_to_fail}"
73
+ end.join("\n")
74
+
75
+ <<~MARKDOWN.chomp if failed_jobs.any?
76
+ ## Failed jobs
77
+
78
+ #{listings}
79
+ MARKDOWN
80
+ end
81
+ end
82
+
58
83
  def generate_stages_listing(tests)
59
84
  generate_tests_by_stage(tests).map do |stage, tests_for_stage|
60
85
  tests_by_status = tests_for_stage.group_by(&:status)
@@ -185,7 +210,7 @@ module Gitlab
185
210
  tests_with_same_testcase.select(&:failure_issue)
186
211
 
187
212
  if tests_having_failure_issue.any?
188
- items = tests_having_failure_issue.map do |test|
213
+ items = tests_having_failure_issue.uniq(&:failure_issue).map do |test|
189
214
  "<li>[ ] [failure issue](#{test.failure_issue})</li>"
190
215
  end.join(' ')
191
216
 
@@ -88,7 +88,12 @@ module Gitlab
88
88
  diff_ratio = (distance.to_f / first_test_failure_stacktrace.size).round(3)
89
89
  if diff_ratio <= max_diff_ratio
90
90
  puts " => [DEBUG] Issue #{issue} has an acceptable diff ratio of #{(diff_ratio * 100).round(2)}%."
91
- memo[issue] = diff_ratio
91
+ # The `Gitlab::ObjectifiedHash` class overrides `#hash` which is used by `Hash#[]=` to compute the hash key.
92
+ # This leads to a `TypeError Exception: no implicit conversion of Hash into Integer` error, so we convert the object to a hash before using it as a Hash key.
93
+ # See:
94
+ # - https://gitlab.com/gitlab-org/gitlab-qa/-/merge_requests/587#note_453336995
95
+ # - https://github.com/NARKOZ/gitlab/commit/cbdbd1e32623f018a8fae39932a8e3bc4d929abb?_pjax=%23js-repo-pjax-container#r44484494
96
+ memo[issue.to_h] = diff_ratio
92
97
  else
93
98
  puts " => [DEBUG] Found issue #{issue.web_url} but stacktraces are too different (#{(diff_ratio * 100).round(2)}%)."
94
99
  end
@@ -116,6 +121,9 @@ module Gitlab
116
121
  raise(MultipleIssuesFound, %(Too many issues found for test '#{test.name}' (`#{test.file}`)!))
117
122
  end
118
123
 
124
+ # Re-instantiate a `Gitlab::ObjectifiedHash` object after having converted it to a hash in #find_relevant_failure_issues above.
125
+ best_matching_issue = Gitlab::ObjectifiedHash.new(best_matching_issue)
126
+
119
127
  test.failure_issue ||= best_matching_issue.web_url
120
128
 
121
129
  [best_matching_issue, smaller_diff_ratio]
@@ -129,23 +137,6 @@ module Gitlab
129
137
  ].join("\n\n")
130
138
  end
131
139
 
132
- def deploy_environment_label
133
- environment = Runtime::Env.deploy_environment
134
-
135
- case environment
136
- when 'production'
137
- 'found:gitlab.com'
138
- when 'canary', 'staging'
139
- "found:#{environment}.gitlab.com"
140
- when 'preprod'
141
- 'found:pre.gitlab.com'
142
- when 'staging-orchestrated', 'nightly', 'master'
143
- "found:#{environment}"
144
- else
145
- raise "No `found:*` label for the `#{environment}` environment!"
146
- end
147
- end
148
-
149
140
  def new_issue_labels(test)
150
141
  NEW_ISSUE_LABELS + up_to_date_labels(test: test)
151
142
  end
@@ -104,6 +104,23 @@ module Gitlab
104
104
  labels
105
105
  end
106
106
 
107
+ def deploy_environment_label
108
+ environment = Runtime::Env.deploy_environment
109
+
110
+ case environment
111
+ when 'production'
112
+ 'found:gitlab.com'
113
+ when 'canary', 'staging'
114
+ "found:#{environment}.gitlab.com"
115
+ when 'preprod'
116
+ 'found:pre.gitlab.com'
117
+ when 'staging-orchestrated', 'nightly', 'master'
118
+ "found:#{environment}"
119
+ else
120
+ raise "No `found:*` label for the `#{environment}` environment!"
121
+ end
122
+ end
123
+
107
124
  def ee_test?(test)
108
125
  test.file =~ %r{features/ee/(api|browser_ui)}
109
126
  end
@@ -136,8 +136,8 @@ module Gitlab
136
136
  ENV['CI_PIPELINE_ID']
137
137
  end
138
138
 
139
- def ci_project_name
140
- ENV['CI_PROJECT_NAME']
139
+ def ci_project_id
140
+ ENV['CI_PROJECT_ID']
141
141
  end
142
142
 
143
143
  def ci_commit_ref_name
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '6.12.0'.freeze
3
+ VERSION = '6.13.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: 6.12.0
4
+ version: 6.13.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-11-24 00:00:00.000000000 Z
11
+ date: 2020-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control