gitlab_quality-test_tooling 1.4.0 → 1.5.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 +4 -4
- data/Gemfile.lock +1 -1
- data/exe/relate-failure-issue +4 -0
- data/exe/slow-test-issues +4 -0
- data/lib/gitlab_quality/test_tooling/gitlab_issue_dry_client.rb +2 -2
- data/lib/gitlab_quality/test_tooling/report/generate_test_session.rb +2 -0
- data/lib/gitlab_quality/test_tooling/report/issue_logger.rb +31 -0
- data/lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb +10 -5
- data/lib/gitlab_quality/test_tooling/report/report_as_issue.rb +11 -2
- data/lib/gitlab_quality/test_tooling/report/slow_test_issue.rb +9 -3
- data/lib/gitlab_quality/test_tooling/test_result/base_test_result.rb +5 -1
- data/lib/gitlab_quality/test_tooling/test_result/json_test_result.rb +4 -0
- data/lib/gitlab_quality/test_tooling/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ac9e211aa370a7163c4173c7a1dec921cbf237fc406d28e1c3c5cfe296e9750
|
4
|
+
data.tar.gz: 99a599cdb8f65c74a489210004f9b34918f03c0d3eb54cd47e3e2dc5a1ee01a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009549cacd5c20ec47ecc157801f272e00a4681decfa5fbf5ae62e252127f8482313857ad328cda1a68327ae7047c771ec7f6d39cfb0fa835834f9b1a53b519a'
|
7
|
+
data.tar.gz: 4bc8d5f83edf2c193ff2fadbc4ae525210a9d9c817dfc48ce35bfa9efcabdecd7801e59165e761a10c2a46d382bc276e1567d45e3ba64905649ce8abab530703
|
data/Gemfile.lock
CHANGED
data/exe/relate-failure-issue
CHANGED
@@ -27,6 +27,10 @@ options = OptionParser.new do |opts|
|
|
27
27
|
params[:token] = token
|
28
28
|
end
|
29
29
|
|
30
|
+
opts.on('-r', '--related-issues-file RELATED_ISSUES_FILE', String, 'The file path for the related issues') do |related_issues_file|
|
31
|
+
params[:related_issues_file] = related_issues_file
|
32
|
+
end
|
33
|
+
|
30
34
|
opts.on('--system-log-files SYSTEM_LOG_FILES', String,
|
31
35
|
'Include errors from system logs in failure issues') do |system_log_files|
|
32
36
|
params[:system_logs] = system_log_files
|
data/exe/slow-test-issues
CHANGED
@@ -23,6 +23,10 @@ options = OptionParser.new do |opts|
|
|
23
23
|
params[:token] = token
|
24
24
|
end
|
25
25
|
|
26
|
+
opts.on('-r', '--related-issues-file RELATED_ISSUES_FILE', String, 'The file path for the related issues') do |related_issues_file|
|
27
|
+
params[:related_issues_file] = related_issues_file
|
28
|
+
end
|
29
|
+
|
26
30
|
opts.on('--dry-run', "Perform a dry-run (don't create issues)") do
|
27
31
|
params[:dry_run] = true
|
28
32
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module GitlabQuality
|
4
4
|
module TestTooling
|
5
5
|
class GitlabIssueDryClient < GitlabIssueClient
|
6
|
-
def create_issue(title:, description:, labels:, issue_type: 'issue')
|
7
|
-
attrs = { description: description, labels: labels }
|
6
|
+
def create_issue(title:, description:, labels:, issue_type: 'issue', confidential: false)
|
7
|
+
attrs = { description: description, labels: labels, confidential: confidential }
|
8
8
|
|
9
9
|
puts "The following #{issue_type} would have been created:"
|
10
10
|
puts "project: #{project}, title: #{title}, attrs: #{attrs}"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GitlabQuality
|
4
|
+
module TestTooling
|
5
|
+
module Report
|
6
|
+
class IssueLogger
|
7
|
+
def initialize(file_path:)
|
8
|
+
@file_path = file_path
|
9
|
+
@data = File.exist?(file_path) ? JSON.parse(File.read(file_path)) : Hash.new { |h, k| h[k] = [] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def collect(test, issues)
|
13
|
+
data[test.ci_job_url] += Array(issues).map(&:web_url)
|
14
|
+
data[test.ci_job_url].uniq!
|
15
|
+
end
|
16
|
+
|
17
|
+
def write
|
18
|
+
dirname = File.dirname(file_path)
|
19
|
+
|
20
|
+
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
21
|
+
|
22
|
+
File.write(file_path, JSON.pretty_generate(data))
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :file_path, :data
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -55,15 +55,20 @@ module GitlabQuality
|
|
55
55
|
|
56
56
|
TestResults::Builder.new(files).test_results_per_file do |test_results|
|
57
57
|
puts "=> Reporting #{test_results.count} tests in #{test_results.path}"
|
58
|
+
process_test_results(test_results)
|
59
|
+
end
|
58
60
|
|
59
|
-
|
61
|
+
write_issues_log_file
|
62
|
+
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
+
def process_test_results(test_results)
|
65
|
+
systemic_failures = systemic_failures_for_test_results(test_results)
|
64
66
|
|
65
|
-
|
67
|
+
test_results.each do |test|
|
68
|
+
collect_issues(test, relate_failure_to_issue(test)) if should_report?(test, systemic_failures)
|
66
69
|
end
|
70
|
+
|
71
|
+
test_results.write
|
67
72
|
end
|
68
73
|
|
69
74
|
def systemic_failures_for_test_results(test_results)
|
@@ -8,11 +8,12 @@ module GitlabQuality
|
|
8
8
|
class ReportAsIssue
|
9
9
|
include Concerns::Utils
|
10
10
|
|
11
|
-
def initialize(token:, input_files:, project: nil, confidential: false, dry_run: false, **_kwargs)
|
11
|
+
def initialize(token:, input_files:, related_issues_file: nil, project: nil, confidential: false, dry_run: false, **_kwargs)
|
12
12
|
@project = project
|
13
13
|
@gitlab = (dry_run ? GitlabIssueDryClient : GitlabIssueClient).new(token: token, project: project)
|
14
14
|
@files = Array(input_files)
|
15
15
|
@confidential = confidential
|
16
|
+
@issue_logger = IssueLogger.new(file_path: related_issues_file) if related_issues_file.present?
|
16
17
|
end
|
17
18
|
|
18
19
|
def invoke!
|
@@ -23,12 +24,20 @@ module GitlabQuality
|
|
23
24
|
|
24
25
|
private
|
25
26
|
|
26
|
-
attr_reader :gitlab, :files, :project, :issue_type, :confidential
|
27
|
+
attr_reader :gitlab, :files, :project, :issue_type, :confidential, :issue_logger
|
27
28
|
|
28
29
|
def run!
|
29
30
|
raise NotImplementedError
|
30
31
|
end
|
31
32
|
|
33
|
+
def collect_issues(test, issues)
|
34
|
+
issue_logger.collect(test, issues) if issue_logger.present?
|
35
|
+
end
|
36
|
+
|
37
|
+
def write_issues_log_file
|
38
|
+
issue_logger.write if issue_logger.present?
|
39
|
+
end
|
40
|
+
|
32
41
|
def test_hash(test)
|
33
42
|
OpenSSL::Digest.hexdigest('SHA256', "#{test.file}#{test.name}")
|
34
43
|
end
|
@@ -30,6 +30,8 @@ module GitlabQuality
|
|
30
30
|
create_slow_issue(test) if test.slow_test?
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
write_issues_log_file
|
33
35
|
end
|
34
36
|
|
35
37
|
def new_issue_title(test)
|
@@ -51,11 +53,15 @@ module GitlabQuality
|
|
51
53
|
|
52
54
|
issues = find_issues(test, SEARCH_LABELS, state: 'opened')
|
53
55
|
|
54
|
-
issues.
|
55
|
-
|
56
|
+
if issues.blank?
|
57
|
+
issues << create_issue(test)
|
58
|
+
else
|
59
|
+
issues.each do |issue|
|
60
|
+
puts " => Existing issue link #{issue['web_url']}"
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
|
-
|
64
|
+
collect_issues(test, issues)
|
59
65
|
rescue MultipleIssuesFound => e
|
60
66
|
warn(e.message)
|
61
67
|
end
|
@@ -11,7 +11,7 @@ module GitlabQuality
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def stage
|
14
|
-
@stage ||= file[%r{(?:api|browser_ui)/(?:(?:\d+_)?(\w+))}, 1]
|
14
|
+
@stage ||= file[%r{(?:api|browser_ui)/(?:(?:\d+_)?(\w+))}, 1] || category
|
15
15
|
end
|
16
16
|
|
17
17
|
def name
|
@@ -22,6 +22,10 @@ module GitlabQuality
|
|
22
22
|
raise NotImplementedError
|
23
23
|
end
|
24
24
|
|
25
|
+
def category
|
26
|
+
raise NotImplementedError
|
27
|
+
end
|
28
|
+
|
25
29
|
def skipped?
|
26
30
|
raise NotImplementedError
|
27
31
|
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.5.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: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -377,6 +377,7 @@ files:
|
|
377
377
|
- lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb
|
378
378
|
- lib/gitlab_quality/test_tooling/report/concerns/utils.rb
|
379
379
|
- lib/gitlab_quality/test_tooling/report/generate_test_session.rb
|
380
|
+
- lib/gitlab_quality/test_tooling/report/issue_logger.rb
|
380
381
|
- lib/gitlab_quality/test_tooling/report/merge_request_slow_tests_report.rb
|
381
382
|
- lib/gitlab_quality/test_tooling/report/prepare_stage_reports.rb
|
382
383
|
- lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb
|