gitlab-qa 6.12.0 → 6.15.2

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: 946c39f638a57c7e2a1ba24dffe836a3b124b0e12dd3b8c18b07a73a5626282a
4
+ data.tar.gz: 3d8adfbf3589e92ad6aaeafa535bc679bad341202eab354ff842e518116b758a
5
5
  SHA512:
6
- metadata.gz: 25678e888d7a338ef9f54269927e16ab6d5f60bc4b37175185bda64174689d9aecf40ac35c7d31be15e6fb1305527604f4667f09aa6c89f42ba4e02c7187a68d
7
- data.tar.gz: ff1c2808b0030677ba8420444e4cb303b0d58d6751511bef90a8bcbea98df6a98e1efea83945d7b6488f076eb8f978519198b4938dc9b99503bd97c0d2b9ea57
6
+ metadata.gz: cd31b62d6d3b78d6384f1884f9f210d95c4cebcb4704a7eb9c2e652180a1d029e8f567addeec03ede879d27dc8de42a297cf3be7e4d8e8ad4899d612243c0e6d
7
+ data.tar.gz: 304ee3fa3f5bb12d1c3f4064f8d3aa3b573bb95ea511648ac391023991884fc220f8fb0fbdca2a70dba9ab82903d37b60c7068558f529251a49f039f012fffc3
@@ -1,8 +1,8 @@
1
1
  stages:
2
2
  - check
3
- - release
4
3
  - test
5
4
  - report
5
+ - deploy
6
6
  - notify
7
7
 
8
8
  default:
@@ -35,13 +35,6 @@ workflow:
35
35
  # For triggers from GitLab MR pipelines (and pipelines from other projects), create a pipeline
36
36
  - if: '$CI_PIPELINE_SOURCE == "pipeline"'
37
37
 
38
- .default-rules:
39
- rules:
40
- - if: '$CI_COMMIT_TAG || $RELEASE'
41
- when: never
42
- - if: '$RELEASE == null && $CI_JOB_NAME =~ /staging/'
43
- when: manual
44
-
45
38
  variables:
46
39
  DOCKER_DRIVER: overlay2
47
40
  DOCKER_HOST: tcp://docker:2375
@@ -65,21 +58,6 @@ rubocop:
65
58
  rspec:
66
59
  extends: .check-base
67
60
 
68
- release:
69
- stage: release
70
- rules:
71
- - if: '$CI_COMMIT_TAG'
72
- script:
73
- - gem update --system
74
- - ruby --version
75
- - gem env version
76
- - gem build gitlab-qa.gemspec
77
- - gem push gitlab-qa*.gem
78
- artifacts:
79
- paths:
80
- - gitlab-qa*.gem
81
- expire_in: 30 days
82
-
83
61
  .test:
84
62
  stage: test
85
63
  services:
@@ -107,6 +85,10 @@ release:
107
85
  variables:
108
86
  DEFAULT_RELEASE: "CE"
109
87
  rules:
88
+ # Don't run E2E jobs on release pipelines
89
+ - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab-qa" && $RELEASE == null'
90
+ changes: ["lib/**/version.rb"]
91
+ when: never
110
92
  - if: '$CI_COMMIT_TAG || $RELEASE =~ /gitlab-ee/'
111
93
  when: never
112
94
  - if: '$RELEASE == null && $CI_JOB_NAME =~ /quarantine|custom/'
@@ -121,6 +103,10 @@ release:
121
103
  variables:
122
104
  DEFAULT_RELEASE: "EE"
123
105
  rules:
106
+ # Don't run E2E jobs on release pipelines
107
+ - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab-qa" && $RELEASE == null'
108
+ changes: ["lib/**/version.rb"]
109
+ when: never
124
110
  - if: '$CI_COMMIT_TAG || $RELEASE =~ /gitlab-ce/'
125
111
  when: never
126
112
  - if: '$RELEASE == null && $CI_JOB_NAME =~ /quarantine|custom/'
@@ -132,7 +118,15 @@ release:
132
118
  - if: '$RELEASE == null || $RELEASE =~ /gitlab-ee/ || $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME == "master"'
133
119
 
134
120
  .only-qa:
135
- extends: .default-rules
121
+ rules:
122
+ # Don't run E2E jobs on release pipelines
123
+ - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab-qa" && $RELEASE == null'
124
+ changes: ["lib/**/version.rb"]
125
+ when: never
126
+ - if: '$CI_COMMIT_TAG || $RELEASE'
127
+ when: never
128
+ - if: '$RELEASE == null && $CI_JOB_NAME =~ /staging/'
129
+ when: manual
136
130
 
137
131
  .high-capacity:
138
132
  tags:
@@ -1012,3 +1006,7 @@ notify_slack:
1012
1006
  - echo "CI_PIPELINE_URL is $CI_PIPELINE_URL"
1013
1007
  - echo "TOP_UPSTREAM_SOURCE_JOB is $TOP_UPSTREAM_SOURCE_JOB"
1014
1008
  - 'bin/slack $NOTIFY_CHANNEL "☠️ QA against $RELEASE failed! ☠️ See the test session report: $(cat REPORT_ISSUE_URL), and pipeline: $CI_PIPELINE_URL (triggered from $TOP_UPSTREAM_SOURCE_JOB)" ci_failing'
1009
+
1010
+ include:
1011
+ - project: 'gitlab-org/quality/pipeline-common'
1012
+ file: '/ci/gem-release.yml'
@@ -30,6 +30,6 @@ with the latest commit from https://gitlab.com/gitlab-org/gitlab-qa/commits/mast
30
30
  - [ ] Release notes are accurate.
31
31
 
32
32
  - Checklist after merging:
33
- - [ ] [Create a tag for the new release version](docs/release_process.md#how-to).
33
+ - [ ] [Update the release notes for the newly created tag](docs/release_process.md#how-to).
34
34
 
35
35
  /label ~Quality ~"feature::maintenance"
@@ -24,12 +24,13 @@ when we make a change - no matter the size of the change.
24
24
  - If not, update [`lib/gitlab/qa/version.rb`] to an appropriate [semantic version](https://semver.org) in a new merge request using the [release template](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/.gitlab/merge_request_templates/Release.md)
25
25
  and title the MR like `"Bump version to <version>"`.
26
26
  - Merge the merge request.
27
- - Create a new tag via the UI (https://gitlab.com/gitlab-org/gitlab-qa/-/tags/new).
28
- * **Tag name**: The same version found in [`lib/gitlab/qa/version.rb`], prefixed with `v`, e.g. if the version is `4.7.1`, the tag would be `v4.7.1`.
29
- * **Message**: Set it to "Version x.y.z", e.g. if the version is `4.7.1`, the message would be "Version 4.7.1".
27
+ - The new version should automatically be tagged and pushed to Rubygems by the `gem-release` job in the merge commit pipeline.
28
+ - Update the release notes for the newly created tag (https://gitlab.com/gitlab-org/gitlab-qa/-/tags):
30
29
  * **Release notes**: Copy the release notes from the merge request.
31
- * Click *Create Tag*.
32
-
33
- GitLab will then start a pipeline for this new tag, and the `release` job will build and push the new version of `gitlab-qa` to RubyGems.
30
+
31
+ Note: The `gem-release` job uses:
32
+
33
+ - the `GITLAB_API_TOKEN` environment variable to authenticate against GitLab.com's API in order to create the tag
34
+ - the `GEM_HOST_API_KEY` environment variable to authenticate against Rubygems.org's API in order to release the gem
34
35
 
35
36
  [`lib/gitlab/qa/version.rb`]: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/lib/gitlab/qa/version.rb#L3
@@ -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
 
@@ -16,22 +17,26 @@ module Gitlab
16
17
  end
17
18
 
18
19
  issue = gitlab.create_issue(
19
- title: "Test session report | #{Runtime::Env.deploy_environment}",
20
+ title: "Test session report | #{pipeline}",
20
21
  description: generate_description(tests),
21
- labels: ['Quality', 'QA', 'triage report']
22
+ labels: ['Quality', 'QA', 'triage report', pipeline_name_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
29
31
  ## Session summary
30
32
 
31
33
  * Deploy version: #{Runtime::Env.deploy_version}
32
- * Pipeline: [#{Runtime::Env.ci_pipeline_id}](#{Runtime::Env.ci_pipeline_url})
34
+ * Deploy environment: #{Runtime::Env.deploy_environment}
35
+ * Pipeline: #{Runtime::Env.pipeline_from_project_name} [#{Runtime::Env.ci_pipeline_id}](#{Runtime::Env.ci_pipeline_url})
33
36
  #{generate_summary(tests: tests)}
34
37
 
38
+ #{generate_failed_jobs_listing}
39
+
35
40
  #{generate_stages_listing(tests)}
36
41
 
37
42
  ## Release QA issue
@@ -55,6 +60,33 @@ module Gitlab
55
60
  MARKDOWN
56
61
  end
57
62
 
63
+ def generate_failed_jobs_listing
64
+ failed_jobs = []
65
+
66
+ client = Gitlab.client(
67
+ endpoint: Runtime::Env.ci_api_v4_url,
68
+ private_token: Runtime::Env.gitlab_ci_api_token)
69
+
70
+ gitlab.handle_gitlab_client_exceptions do
71
+ failed_jobs = client.pipeline_jobs(
72
+ Runtime::Env.ci_project_id,
73
+ Runtime::Env.ci_pipeline_id,
74
+ scope: 'failed')
75
+ end
76
+
77
+ listings = failed_jobs.map do |job|
78
+ allowed_to_fail = ' (allowed to fail)' if job.allow_failure
79
+
80
+ "* [#{job.name}](#{job.web_url})#{allowed_to_fail}"
81
+ end.join("\n")
82
+
83
+ <<~MARKDOWN.chomp if failed_jobs.any?
84
+ ## Failed jobs
85
+
86
+ #{listings}
87
+ MARKDOWN
88
+ end
89
+
58
90
  def generate_stages_listing(tests)
59
91
  generate_tests_by_stage(tests).map do |stage, tests_for_stage|
60
92
  tests_by_status = tests_for_stage.group_by(&:status)
@@ -185,7 +217,7 @@ module Gitlab
185
217
  tests_with_same_testcase.select(&:failure_issue)
186
218
 
187
219
  if tests_having_failure_issue.any?
188
- items = tests_having_failure_issue.map do |test|
220
+ items = tests_having_failure_issue.uniq(&:failure_issue).map do |test|
189
221
  "<li>[ ] [failure issue](#{test.failure_issue})</li>"
190
222
  end.join(' ')
191
223
 
@@ -34,7 +34,10 @@ module Gitlab
34
34
  # /qa/specs/features/ee/api/<stage>
35
35
  # /qa/specs/features/ee/browser_ui/<stage>
36
36
  # For now we assume the Stage is whatever follows api/ or browser_ui/
37
- stage = strip_number_prefix(test['file'].match(%r{(api|browser_ui)/([a-z0-9_]+)}i)[2])
37
+ test_path_match = test['file'].match(%r{(api|browser_ui)/([a-z0-9_]+)}i)
38
+ next unless test_path_match
39
+
40
+ stage = strip_number_prefix(test_path_match[2])
38
41
  testcases[stage] = [] unless testcases.key?(stage)
39
42
  testcases[stage] << test
40
43
  end
@@ -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,29 +137,12 @@ 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
152
143
 
153
144
  def up_to_date_labels(test:, issue: nil)
154
- super << deploy_environment_label
145
+ super << pipeline_name_label
155
146
  end
156
147
 
157
148
  def post_failed_job_note(issue, test)
@@ -104,6 +104,21 @@ module Gitlab
104
104
  labels
105
105
  end
106
106
 
107
+ def pipeline_name_label
108
+ case pipeline
109
+ when 'production'
110
+ 'found:gitlab.com'
111
+ when 'canary', 'staging'
112
+ "found:#{pipeline}.gitlab.com"
113
+ when 'preprod'
114
+ 'found:pre.gitlab.com'
115
+ when 'staging-orchestrated', 'nightly', 'master'
116
+ "found:#{pipeline}"
117
+ else
118
+ raise "No `found:*` label for the `#{pipeline}` pipeline!"
119
+ end
120
+ end
121
+
107
122
  def ee_test?(test)
108
123
  test.file =~ %r{features/ee/(api|browser_ui)}
109
124
  end
@@ -116,6 +116,14 @@ module Gitlab
116
116
  ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
117
117
  end
118
118
 
119
+ def gitlab_ci_api_token
120
+ ENV['GITLAB_CI_API_TOKEN']
121
+ end
122
+
123
+ def ci_api_v4_url
124
+ ENV['CI_API_V4_URL']
125
+ end
126
+
119
127
  def ci_job_name
120
128
  ENV['CI_JOB_NAME']
121
129
  end
@@ -136,8 +144,8 @@ module Gitlab
136
144
  ENV['CI_PIPELINE_ID']
137
145
  end
138
146
 
139
- def ci_project_name
140
- ENV['CI_PROJECT_NAME']
147
+ def ci_project_id
148
+ ENV['CI_PROJECT_ID']
141
149
  end
142
150
 
143
151
  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.15.2'.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.15.2
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-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control