gitlab_quality-test_tooling 1.29.0 → 1.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/exe/post-to-slack +4 -0
- data/lib/gitlab_quality/test_tooling/gitlab_client/repository_files_client.rb +4 -3
- data/lib/gitlab_quality/test_tooling/report/health_problem_reporter.rb +1 -1
- data/lib/gitlab_quality/test_tooling/report/merge_request_slow_tests_report.rb +1 -0
- data/lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb +1 -1
- data/lib/gitlab_quality/test_tooling/report/report_as_issue.rb +3 -4
- data/lib/gitlab_quality/test_tooling/report/report_results.rb +2 -1
- data/lib/gitlab_quality/test_tooling/summary_table.rb +3 -0
- data/lib/gitlab_quality/test_tooling/test_result/base_test_result.rb +9 -7
- data/lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb +1 -1
- data/lib/gitlab_quality/test_tooling/test_result/json_test_result.rb +2 -4
- data/lib/gitlab_quality/test_tooling/test_results/base_test_results.rb +2 -4
- data/lib/gitlab_quality/test_tooling/test_results/builder.rb +4 -6
- data/lib/gitlab_quality/test_tooling/test_results/j_unit_test_results.rb +1 -1
- data/lib/gitlab_quality/test_tooling/test_results/json_test_results.rb +1 -1
- data/lib/gitlab_quality/test_tooling/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba1faa3616687c598a2d2b69e469c90d92ba687a9693ed87367998e1a747313d
|
4
|
+
data.tar.gz: 1486372498629cb6e21b63a999a856f40e7b393295f12bcf52cd8f74c4803efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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
|
@@ -9,8 +9,7 @@ module GitlabQuality
|
|
9
9
|
def initialize(file_path:, ref:, **kwargs)
|
10
10
|
@file_path = file_path
|
11
11
|
@ref = ref
|
12
|
-
|
13
|
-
super
|
12
|
+
super(**kwargs)
|
14
13
|
end
|
15
14
|
|
16
15
|
def file_contents
|
@@ -20,7 +19,9 @@ module GitlabQuality
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def file_contents_at_line(line_number)
|
23
|
-
|
22
|
+
ignore_gitlab_client_exceptions do
|
23
|
+
file_contents.lines(chomp: true)[line_number - 1]
|
24
|
+
end
|
24
25
|
end
|
25
26
|
end
|
26
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
|
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)
|
@@ -9,6 +9,7 @@ module GitlabQuality
|
|
9
9
|
SLOW_TEST_NOTE_SOURCE_CODE = 'Generated by [`gitlab_quality-test_tooling`](https://gitlab.com/gitlab-org/ruby/gems/gitlab_quality-test_tooling/-/blob/main/lib/gitlab_quality/test_tooling/report/merge_request_slow_tests_report.rb).'
|
10
10
|
|
11
11
|
def initialize(token:, input_files:, merge_request_iid:, project: nil, dry_run: false, **_kwargs)
|
12
|
+
@token = token
|
12
13
|
@project = project
|
13
14
|
@gitlab_merge_request = (dry_run ? GitlabClient::MergeRequestsDryClient : GitlabClient::MergeRequestsClient).new(token: token, project: project)
|
14
15
|
@files = Array(input_files)
|
@@ -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.
|
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
|
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.
|
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.
|
60
|
+
| Filename | `#{test.relative_file}` |
|
62
61
|
| Description | `#{test.name}` |
|
63
62
|
| Test level | `#{test.level}` |
|
64
63
|
| Hash | `#{test_hash(test)}` |
|
@@ -14,6 +14,7 @@ module GitlabQuality
|
|
14
14
|
def initialize(
|
15
15
|
test_case_project_token:, results_issue_project_token:, input_files:, test_case_project: nil, results_issue_project: nil, dry_run: false,
|
16
16
|
**kwargs)
|
17
|
+
@results_issue_project_token = results_issue_project_token
|
17
18
|
@testcase_project_reporter = GitlabQuality::TestTooling::Report::ResultsInTestCases.new(
|
18
19
|
token: test_case_project_token, input_files: input_files, project: test_case_project, dry_run: dry_run, **kwargs)
|
19
20
|
@results_issue_project_reporter = GitlabQuality::TestTooling::Report::ResultsInIssues.new(
|
@@ -42,7 +43,7 @@ module GitlabQuality
|
|
42
43
|
test_results.each do |test|
|
43
44
|
next if test.file.include?('/features/sanity/') || test.skipped?
|
44
45
|
|
45
|
-
puts "Reporting test: #{test.
|
46
|
+
puts "Reporting test: #{test.relative_file} | #{test.name}\n"
|
46
47
|
|
47
48
|
report_test(test)
|
48
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:,
|
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
|
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:
|
81
|
-
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 :
|
90
|
+
attr_reader :ref
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|
@@ -40,7 +40,7 @@ module GitlabQuality
|
|
40
40
|
report.fetch('full_description').split('#<').first
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
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
|
-
|
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:,
|
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, :
|
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:,
|
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,
|
19
|
+
TestResults::JsonTestResults.new(path: path, ref: ref)
|
22
20
|
when '.xml'
|
23
|
-
TestResults::JUnitTestResults.new(path: path,
|
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, :
|
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
|
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
|
23
|
+
GitlabQuality::TestTooling::TestResult::JsonTestResult.new(report: test)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
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.
|
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-
|
11
|
+
date: 2024-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|