gitlab-qa 6.0.0 → 6.1.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: 87249baf75070cf8c5362c34b9995f6163370e9b6e353a393104beefe62d4bd8
4
- data.tar.gz: 6e00eee6993c9f5c6aeb4cb187c708941bfd27cb9b59340165b23b02c30f583a
3
+ metadata.gz: 960a5ea5f4f964cf9e9a237d75e96350bd611e9c6b9c1e1721c3dd2df1476104
4
+ data.tar.gz: 4c42c1a2652f8f6d49565e849bbb6e3ecdce24d1d11662478cdd511424d7a020
5
5
  SHA512:
6
- metadata.gz: 6d621d51ca18fa402e397b13c86dda6d52039a11ca259c6a46f3e9caffeab0faa68b6b9ff58ec4f727b2dae82c386442655122571936a47c366647b3ad895a50
7
- data.tar.gz: 73bbcc44b560368e64d8bd335b3fac6d52128e8c05f6ddf582ea6139032f570d80563b6fbc9c96f41598fee2c2c345ec9155f5990f3ea4df1bde2167bede9a27
6
+ metadata.gz: 3e09dabf4c89b97a6a92d7d78a4bccaa57605f85ff0559c9423cc55b1bb3e6fb5f926ba1ccad193ee7e04c17b774502b47862011abc674cc00e84a323590a611
7
+ data.tar.gz: c88cd735d53a3c1d17c4aaf28b7af47a1a0ac827d6f3012d187e43b1f897616472f35618cfe9f419b87ff1e88cfb6d5922e49ec53db9cc4c2d3b154f8ab3a786
@@ -94,7 +94,7 @@ release:
94
94
  - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS || test_run_exit_code=$?
95
95
  - exe/gitlab-qa-report --update-screenshot-path "gitlab-qa-run-*/**/rspec-*.xml"
96
96
  - export GITLAB_QA_ACCESS_TOKEN="$GITLAB_QA_PRODUCTION_ACCESS_TOKEN"
97
- - if [ "$TOP_UPSTREAM_SOURCE_REF" == "master" ]; then exe/gitlab-qa-report --report-in-issues "gitlab-qa-run-*/**/rspec-*.xml" --project "$QA_TESTCASES_REPORTING_PROJECT" || true; fi
97
+ - if [ "$TOP_UPSTREAM_SOURCE_REF" == "master" ]; then exe/gitlab-qa-report --report-in-issues "gitlab-qa-run-*/**/rspec-*.json" --project "$QA_TESTCASES_REPORTING_PROJECT" || true; fi
98
98
  - exit $test_run_exit_code
99
99
 
100
100
  .ce-qa:
@@ -143,7 +143,7 @@ release:
143
143
  .rspec-report-opts:
144
144
  variables:
145
145
  FILE_SAFE_JOB_NAME: $(echo $CI_JOB_NAME | sed 's/[ /]/_/g')
146
- RSPEC_REPORT_OPTS: "--format RspecJunitFormatter --out \"tmp/rspec-${CI_JOB_ID}.xml\" --format html --out \"tmp/rspec-${FILE_SAFE_JOB_NAME}.htm\" --color --format documentation"
146
+ RSPEC_REPORT_OPTS: "--format QA::Support::JsonFormatter --out \"tmp/rspec-${CI_JOB_ID}.json\" --format RspecJunitFormatter --out \"tmp/rspec-${CI_JOB_ID}.xml\" --format html --out \"tmp/rspec-${FILE_SAFE_JOB_NAME}.htm\" --color --format documentation"
147
147
 
148
148
  .quarantine:
149
149
  allow_failure: true
@@ -30,12 +30,11 @@ module Gitlab
30
30
  RETRY_BACK_OFF_DELAY = 60
31
31
  MAX_RETRY_ATTEMPTS = 3
32
32
 
33
- def initialize(token:, input_files:, project: nil, input_format: :junit)
33
+ def initialize(token:, input_files:, project: nil)
34
34
  @token = token
35
35
  @files = Array(input_files)
36
36
  @project = project
37
37
  @retry_backoff = 0
38
- @input_format = input_format.to_sym
39
38
  end
40
39
 
41
40
  def invoke!
@@ -47,11 +46,15 @@ module Gitlab
47
46
 
48
47
  Dir.glob(files).each do |file|
49
48
  puts "Reporting tests in #{file}"
50
- case input_format
51
- when :json
49
+ extension = File.extname(file)
50
+
51
+ case extension
52
+ when '.json'
52
53
  test_results = Report::JsonTestResults.new(file)
53
- when :junit
54
+ when '.xml'
54
55
  test_results = Report::JUnitTestResults.new(file)
56
+ else
57
+ raise "Unknown extension #{extension}"
55
58
  end
56
59
 
57
60
  test_results.each do |test|
@@ -62,7 +65,7 @@ module Gitlab
62
65
 
63
66
  private
64
67
 
65
- attr_reader :files, :token, :project, :input_format
68
+ attr_reader :files, :token, :project
66
69
 
67
70
  def validate_input!
68
71
  assert_project!
@@ -137,8 +140,11 @@ module Gitlab
137
140
  end
138
141
  end
139
142
 
143
+ # rubocop:disable Metrics/AbcSize
140
144
  def find_issue(test)
141
145
  handle_gitlab_client_exceptions do
146
+ return Gitlab.issue(project, id_from_status_issue_url(test.status_issue)) if test.status_issue
147
+
142
148
  issues = Gitlab.issues(project, { search: search_term(test) })
143
149
  .auto_paginate
144
150
  .select { |issue| issue.state == 'opened' && issue.title.strip == title_from_test(test) }
@@ -148,6 +154,11 @@ module Gitlab
148
154
  issues.first
149
155
  end
150
156
  end
157
+ # rubocop:enable Metrics/AbcSize
158
+
159
+ def id_from_status_issue_url(url)
160
+ url.split('/').last.to_i
161
+ end
151
162
 
152
163
  def search_term(test)
153
164
  %("#{test.file}" "#{search_safe(test.name)}")
@@ -4,7 +4,7 @@ module Gitlab
4
4
  module QA
5
5
  module Report
6
6
  class TestResult
7
- attr_accessor :name, :file, :skipped, :failures
7
+ attr_accessor :name, :file, :skipped, :failures, :status_issue
8
8
 
9
9
  def self.from_json(test)
10
10
  new.tap do |test_result|
@@ -12,6 +12,7 @@ module Gitlab
12
12
  test_result.file = test['file_path']
13
13
  test_result.skipped = test['status'] == 'pending'
14
14
  test_result.failures = failures_from_json_exceptions(test)
15
+ test_result.status_issue = test['status_issue']
15
16
  end
16
17
  end
17
18
 
@@ -28,9 +29,13 @@ module Gitlab
28
29
  return [] unless test.key?('exceptions')
29
30
 
30
31
  test['exceptions'].map do |exception|
32
+ spec_file_first_index = exception['backtrace'].rindex do |line|
33
+ line.include?(File.basename(test['file_path']))
34
+ end
35
+
31
36
  {
32
37
  'message' => "#{exception['class']}: #{exception['message']}",
33
- 'stacktrace' => exception['backtrace'].join('\n')
38
+ 'stacktrace' => exception['backtrace'].slice(0..spec_file_first_index).join("\n")
34
39
  }
35
40
  end
36
41
  end
@@ -41,9 +46,14 @@ module Gitlab
41
46
  return [] if failures.empty?
42
47
 
43
48
  failures.map do |exception|
49
+ trace = exception.content.split("\n").map(&:strip)
50
+ spec_file_first_index = trace.rindex do |line|
51
+ line.include?(File.basename(test['file']))
52
+ end
53
+
44
54
  {
45
55
  'message' => "#{exception['type']}: #{exception['message']}",
46
- 'stacktrace' => exception.content
56
+ 'stacktrace' => trace.slice(0..spec_file_first_index).join("\n")
47
57
  }
48
58
  end
49
59
  end
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '6.0.0'.freeze
3
+ VERSION = '6.1.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.0.0
4
+ version: 6.1.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-08-13 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control