gitlab_quality-test_tooling 1.4.0 → 1.5.1

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: 7237e27f052e0d9934df2a8ad8d8d413cb1db81b4bc30fd334458cd05ee23494
4
- data.tar.gz: 1775470edd1236836c8f4a2f729d40d642d6e9fde2c40630b79925f84c821e8c
3
+ metadata.gz: 7ba60bceafbfb950d7cc588d11b14b457f74cdf3f39271b33b171d7de935c6a2
4
+ data.tar.gz: 3129a7a6da1a0c6f46df06ccd69f4d6d84a2f926a1dca268ea73455054fdbf4d
5
5
  SHA512:
6
- metadata.gz: 0d77a24b7561c7d1b194a68290d0334d46e2c10120b3457f0288b53f161421bedccb6ff6c638e519d1a8c788e300b4b7ba543b7b5c45ad59b314ec05867e1be4
7
- data.tar.gz: c384fda5b0c98647804c19880d581c0ccdf233dccd82c52b0f1aaf83fd56c729b3fdd33628433b9b278f48073a0e446ced610c5ee04408717dfbe919e9d3e77b
6
+ metadata.gz: 0cfd0c911a463fe793c701ae13bef14dcd4e5220bc0e41819126e6659f1bcb6589ce1dba5baa33f6410f92a8ddc6414623cb7952638f66a3d79a55099089f1a6
7
+ data.tar.gz: 12600147b76a659a725662119d08318999a85f1483a5d68bb6da14f464085f3d67fc6748a2f94dcee9bef82357c62a17f874d3a3feb2ee6961fbcb094f61aec0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (1.4.0)
4
+ gitlab_quality-test_tooling (1.5.1)
5
5
  activesupport (>= 6.1, < 7.2)
6
6
  amatch (~> 0.4.1)
7
7
  gitlab (~> 4.19)
@@ -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}"
@@ -138,6 +138,8 @@ module GitlabQuality
138
138
  growth
139
139
  fulfillment
140
140
  enablement
141
+ self-managed
142
+ saas
141
143
  ]
142
144
 
143
145
  tests.sort_by do |test|
@@ -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
- systemic_failures = systemic_failures_for_test_results(test_results)
61
+ write_issues_log_file
62
+ end
60
63
 
61
- test_results.each do |test|
62
- relate_failure_to_issue(test) if should_report?(test, systemic_failures)
63
- end
64
+ def process_test_results(test_results)
65
+ systemic_failures = systemic_failures_for_test_results(test_results)
64
66
 
65
- test_results.write
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) unless related_issues_file.nil?
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)
35
+ end
36
+
37
+ def write_issues_log_file
38
+ issue_logger&.write
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.each do |issue|
55
- puts " => Existing issue link #{issue['web_url']}"
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
- create_issue(test) unless issues.any?
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
@@ -88,6 +88,10 @@ module GitlabQuality
88
88
  report['feature_category']
89
89
  end
90
90
 
91
+ def category
92
+ report['category']
93
+ end
94
+
91
95
  def run_time
92
96
  report['run_time'].to_f.round(2)
93
97
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "1.4.0"
5
+ VERSION = "1.5.1"
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.4.0
4
+ version: 1.5.1
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-10-27 00:00:00.000000000 Z
11
+ date: 2023-11-07 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