gitlab_quality-test_tooling 1.29.1 → 1.30.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: 523cbb3e59a928b4e438ec2f97818c6b756b5120d9d61ede7945bd5904de4b79
4
- data.tar.gz: 750bb848167c76df6f6287d119eb211fa8281abfade44334ca1cb72142b03361
3
+ metadata.gz: ba1faa3616687c598a2d2b69e469c90d92ba687a9693ed87367998e1a747313d
4
+ data.tar.gz: 1486372498629cb6e21b63a999a856f40e7b393295f12bcf52cd8f74c4803efc
5
5
  SHA512:
6
- metadata.gz: ab633288538b5343309ed30766925b61c05685f457e1772f5c80113a013fd75910509cf76fa01feb9e9bffdf5d764357f221b8f7f53748f17daed1f60b240464
7
- data.tar.gz: 2dbf75f6310a515c0c9eb43301fd6b669ba96e115cbdeec37a2570fc556cac94daac00ec81638aaf1288e465efd4284af167e7d060657eaff788d65aebb92362
6
+ metadata.gz: f67bc6c00ad80ab20e33b7f69356a30e27415674211ce14c4ceb17dd80d7621ce6a441a279889e344b8e8a87d1488dec5e799f5c712d0eae629d44ee2b6019e6
7
+ data.tar.gz: ceb443481a7528bca028c3070dcf71739bdd9b90a4173890dbd5f54a4d0e22ef2b9458c0d00ac13bf23dad0354bde5465a153a4f23c92c9ccf0c44cef04822a9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (1.29.1)
4
+ gitlab_quality-test_tooling (1.30.0)
5
5
  activesupport (>= 7.0, < 7.2)
6
6
  amatch (~> 0.4.1)
7
7
  gitlab (~> 4.19)
@@ -330,4 +330,4 @@ DEPENDENCIES
330
330
  webmock (= 3.7.0)
331
331
 
332
332
  BUNDLED WITH
333
- 2.5.6
333
+ 2.5.13
data/exe/post-to-slack CHANGED
@@ -47,6 +47,10 @@ options = OptionParser.new do |opts|
47
47
  summary_table_opts[:sort_direction] = sort_direction.downcase.to_sym
48
48
  end
49
49
 
50
+ opts.on('--hide-passed-tests', 'Used with the `--include-summary-table` flag — Hide passed tests from the summary table') do
51
+ summary_table_opts[:hide_passed_tests] = true
52
+ end
53
+
50
54
  opts.on('-t', '--include-summary-table FILES', String, 'Add a test summary table based on RSpec report files (JUnit XML)') do |files|
51
55
  params[:summary_table_files] = files
52
56
  end
@@ -19,7 +19,9 @@ module GitlabQuality
19
19
  end
20
20
 
21
21
  def file_contents_at_line(line_number)
22
- file_contents.lines(chomp: true)[line_number - 1]
22
+ ignore_gitlab_client_exceptions do
23
+ file_contents.lines(chomp: true)[line_number - 1]
24
+ end
23
25
  end
24
26
  end
25
27
  end
@@ -65,7 +65,7 @@ module GitlabQuality
65
65
  def run!
66
66
  puts "Reporting tests in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
67
67
 
68
- TestResults::Builder.new(file_glob: files, token: token, project: project).test_results_per_file do |test_results|
68
+ TestResults::Builder.new(file_glob: files).test_results_per_file do |test_results|
69
69
  puts "=> Reporting #{test_results.count} tests in #{test_results.path}"
70
70
 
71
71
  process_test_results(test_results)
@@ -30,7 +30,7 @@ module GitlabQuality
30
30
  def run!
31
31
  puts "Reporting slow tests in MR #{merge_request_iid}"
32
32
 
33
- TestResults::Builder.new(token: @token, project: @project, file_glob: files).test_results_per_file do |test_results|
33
+ TestResults::Builder.new(file_glob: files).test_results_per_file do |test_results|
34
34
  puts "=> Reporting #{test_results.count} tests in #{test_results.path}"
35
35
 
36
36
  @slow_tests += slow_related_tests(find_slow_tests(test_results))
@@ -52,7 +52,7 @@ module GitlabQuality
52
52
  def run!
53
53
  puts "Reporting test failures in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
54
54
 
55
- TestResults::Builder.new(token: @token, project: @project, file_glob: files).test_results_per_file do |test_results|
55
+ TestResults::Builder.new(file_glob: files).test_results_per_file do |test_results|
56
56
  puts "=> Reporting #{test_results.count} tests in #{test_results.path}"
57
57
  process_test_results(test_results)
58
58
  end
@@ -259,7 +259,7 @@ module GitlabQuality
259
259
 
260
260
  best_matching_issue, smaller_diff_ratio = relevant_issues.min_by { |_, diff_ratio| diff_ratio }
261
261
 
262
- raise(MultipleIssuesFound, %(Too many issues found for test '#{test.name}' (`#{test.file}`)!)) unless relevant_issues.values.count(smaller_diff_ratio) == 1
262
+ raise(MultipleIssuesFound, %(Too many issues found for test '#{test.name}' (`#{test.relative_file}`)!)) unless relevant_issues.values.count(smaller_diff_ratio) == 1
263
263
 
264
264
  # Re-instantiate a `Gitlab::ObjectifiedHash` object after having converted it to a hash in #find_relevant_failure_issues above.
265
265
  best_matching_issue = Gitlab::ObjectifiedHash.new(best_matching_issue)
@@ -10,7 +10,6 @@ module GitlabQuality
10
10
 
11
11
  def initialize(token:, input_files:, related_issues_file: nil, project: nil, confidential: false, dry_run: false, **_kwargs)
12
12
  @project = project
13
- @token = token
14
13
  @gitlab = (dry_run ? GitlabClient::IssuesDryClient : GitlabClient::IssuesClient).new(token: token, project: project)
15
14
  @files = Array(input_files)
16
15
  @confidential = confidential
@@ -29,7 +28,7 @@ module GitlabQuality
29
28
 
30
29
  private
31
30
 
32
- attr_reader :gitlab, :files, :project, :issue_type, :confidential, :issue_logger, :token
31
+ attr_reader :gitlab, :files, :project, :issue_type, :confidential, :issue_logger
33
32
 
34
33
  def run!
35
34
  raise NotImplementedError
@@ -47,7 +46,7 @@ module GitlabQuality
47
46
  # Should not be more than 50 characters if we want it indexed.
48
47
  #
49
48
  # See https://gitlab.com/gitlab-org/ruby/gems/gitlab_quality-test_tooling/-/issues/27#note_1607276486
50
- OpenSSL::Digest.hexdigest('SHA256', "#{test.file}#{test.name}")[..40]
49
+ OpenSSL::Digest.hexdigest('SHA256', "#{test.relative_file}#{test.name}")[..40]
51
50
  end
52
51
 
53
52
  def new_issue_description(test)
@@ -58,7 +57,7 @@ module GitlabQuality
58
57
  | Field | Value |
59
58
  | ------ | ------ |
60
59
  | File URL | #{test.test_file_link} |
61
- | Filename | `#{test.file}` |
60
+ | Filename | `#{test.relative_file}` |
62
61
  | Description | `#{test.name}` |
63
62
  | Test level | `#{test.level}` |
64
63
  | Hash | `#{test_hash(test)}` |
@@ -37,13 +37,13 @@ module GitlabQuality
37
37
  puts "Reporting test results in `#{files.join(',')}` as test cases in project `#{test_case_project}` " \
38
38
  "and issues in project `#{results_issue_project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
39
39
 
40
- TestResults::Builder.new(token: @results_issue_project_token, project: @results_issue_project, file_glob: files).test_results_per_file do |test_results|
40
+ TestResults::Builder.new(file_glob: files).test_results_per_file do |test_results|
41
41
  puts "Reporting tests in #{test_results.path}"
42
42
 
43
43
  test_results.each do |test|
44
44
  next if test.file.include?('/features/sanity/') || test.skipped?
45
45
 
46
- puts "Reporting test: #{test.file} | #{test.name}\n"
46
+ puts "Reporting test: #{test.relative_file} | #{test.name}\n"
47
47
 
48
48
  report_test(test)
49
49
  end
@@ -14,6 +14,7 @@ module GitlabQuality
14
14
  def self.collect_results(input_files, **options)
15
15
  sort_by = options[:sort_by]
16
16
  sort_direction = options[:sort_direction]
17
+ hide_passed_tests = options[:hide_passed_tests]
17
18
 
18
19
  stage_wise_results = Dir.glob(input_files).each_with_object([]) do |report_file, stage_wise_results|
19
20
  stage_hash = {}
@@ -21,6 +22,8 @@ module GitlabQuality
21
22
 
22
23
  report_stats = Nokogiri::XML(File.open(report_file)).children[0].attributes
23
24
 
25
+ next if hide_passed_tests && report_stats["failures"].value.to_i.zero? && report_stats["errors"].value.to_i.zero?
26
+
24
27
  stage_hash["Total"] = report_stats["tests"].value
25
28
  stage_hash["Failures"] = report_stats["failures"].value
26
29
  stage_hash["Errors"] = report_stats["errors"].value
@@ -13,10 +13,8 @@ module GitlabQuality
13
13
 
14
14
  attr_reader :report
15
15
 
16
- def initialize(report:, token: nil, project: nil, ref: 'master')
16
+ def initialize(report:, ref: 'master')
17
17
  @report = report
18
- @token = token
19
- @project = project
20
18
  @ref = ref
21
19
  end
22
20
 
@@ -28,7 +26,7 @@ module GitlabQuality
28
26
  raise NotImplementedError
29
27
  end
30
28
 
31
- def file
29
+ def relative_file
32
30
  raise NotImplementedError
33
31
  end
34
32
 
@@ -56,6 +54,10 @@ module GitlabQuality
56
54
  failures.any?
57
55
  end
58
56
 
57
+ def file
58
+ @file ||= relative_file.start_with?('qa/') ? "qa/#{relative_file}" : relative_file
59
+ end
60
+
59
61
  def full_stacktrace
60
62
  failures.each do |failure|
61
63
  message = failure['message'] || ""
@@ -77,15 +79,15 @@ module GitlabQuality
77
79
 
78
80
  def files_client
79
81
  @files_client ||= GitlabClient::RepositoryFilesClient.new(
80
- token: token,
81
- project: project,
82
+ token: '',
83
+ project: 'gitlab-org/gitlab',
82
84
  file_path: file,
83
85
  ref: ref)
84
86
  end
85
87
 
86
88
  private
87
89
 
88
- attr_reader :token, :project, :ref
90
+ attr_reader :ref
89
91
  end
90
92
  end
91
93
  end
@@ -10,7 +10,7 @@ module GitlabQuality
10
10
  report['name']
11
11
  end
12
12
 
13
- def file
13
+ def relative_file
14
14
  report['file']&.delete_prefix('./')
15
15
  end
16
16
 
@@ -40,7 +40,7 @@ module GitlabQuality
40
40
  report.fetch('full_description').split('#<').first
41
41
  end
42
42
 
43
- def file
43
+ def relative_file
44
44
  report.fetch('file_path').delete_prefix('./')
45
45
  end
46
46
 
@@ -179,9 +179,7 @@ module GitlabQuality
179
179
  end
180
180
 
181
181
  def test_file_link
182
- path_prefix = file.start_with?('qa/') ? 'qa/' : ''
183
-
184
- "[`#{path_prefix}#{file}#L#{line_number}`](#{Runtime::Env.file_base_url}#{path_prefix}#{file}#L#{line_number})"
182
+ "[`#{file}#L#{line_number}`](#{Runtime::Env.file_base_url}#{file}#L#{line_number})"
185
183
  end
186
184
 
187
185
  private
@@ -8,10 +8,8 @@ module GitlabQuality
8
8
 
9
9
  attr_reader :path
10
10
 
11
- def initialize(path:, token: nil, project: nil, ref: 'master')
11
+ def initialize(path:, ref: 'master')
12
12
  @path = path
13
- @token = token
14
- @project = project
15
13
  @ref = ref
16
14
  @results = parse
17
15
  @testcases = process
@@ -27,7 +25,7 @@ module GitlabQuality
27
25
 
28
26
  private
29
27
 
30
- attr_reader :results, :testcases, :token, :project, :ref
28
+ attr_reader :results, :testcases, :ref
31
29
 
32
30
  def parse
33
31
  raise NotImplementedError
@@ -4,10 +4,8 @@ module GitlabQuality
4
4
  module TestTooling
5
5
  module TestResults
6
6
  class Builder
7
- def initialize(file_glob:, token: nil, project: nil, ref: 'master')
7
+ def initialize(file_glob:, ref: 'master')
8
8
  @file_glob = file_glob
9
- @token = token
10
- @project = project
11
9
  @ref = ref
12
10
  end
13
11
 
@@ -18,9 +16,9 @@ module GitlabQuality
18
16
  test_results =
19
17
  case extension
20
18
  when '.json'
21
- TestResults::JsonTestResults.new(path: path, token: token, project: project, ref: ref)
19
+ TestResults::JsonTestResults.new(path: path, ref: ref)
22
20
  when '.xml'
23
- TestResults::JUnitTestResults.new(path: path, token: token, project: project, ref: ref)
21
+ TestResults::JUnitTestResults.new(path: path, ref: ref)
24
22
  else
25
23
  raise "Unknown extension #{extension}"
26
24
  end
@@ -31,7 +29,7 @@ module GitlabQuality
31
29
 
32
30
  private
33
31
 
34
- attr_reader :file_glob, :token, :project, :ref
32
+ attr_reader :file_glob, :ref
35
33
  end
36
34
  end
37
35
  end
@@ -18,7 +18,7 @@ module GitlabQuality
18
18
 
19
19
  def process
20
20
  results.xpath('//testcase').map do |test|
21
- GitlabQuality::TestTooling::TestResult::JUnitTestResult.new(report: test, project: project, token: token)
21
+ GitlabQuality::TestTooling::TestResult::JUnitTestResult.new(report: test)
22
22
  end
23
23
  end
24
24
  end
@@ -20,7 +20,7 @@ module GitlabQuality
20
20
 
21
21
  def process
22
22
  results['examples'].map do |test|
23
- GitlabQuality::TestTooling::TestResult::JsonTestResult.new(report: test, project: project, token: token)
23
+ GitlabQuality::TestTooling::TestResult::JsonTestResult.new(report: test)
24
24
  end
25
25
  end
26
26
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "1.29.1"
5
+ VERSION = "1.30.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: 1.29.1
4
+ version: 1.30.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: 2024-06-21 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control