gitlab_quality-test_tooling 0.4.3 → 0.5.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: 710c5fd717aaeb8311c535e229573763b36fdf8437bc4d561aa5307441740747
4
- data.tar.gz: f790b54c1f16a507d416a216d9457c55e86ed91c6776c60dbc3c5c0963ef22e1
3
+ metadata.gz: 2a9e8046b18205a7734445f57f400fb25bf99348d6caa2266ef5ef80533fecb8
4
+ data.tar.gz: 83129e822441e760a4a628b4d0cce77cddf41a0756198210df89ef83396d28f7
5
5
  SHA512:
6
- metadata.gz: d74b227420252c2fd0ec41e0494c18f47f2be12e093eea47c44c97ccbd6e613c1990f257d928c7c9dfd3684b6685e0212667d6099d1ba4e3c03eaa77ed129db5
7
- data.tar.gz: 49e42227f975b6a91ddae3052c2b4ac62fa47f462427a4a051462e57e4ff8ffed62e709470426864d324beb4c54b86e3b51aecc425290ef02084218551de76f6
6
+ metadata.gz: 2e395e267ce42355d89bbac778b02ceaa014cea0427101827331559e6f0879e8ddc2e5f0a714e0521644601e3534dbf9dc3d736523d01e160498ee78f3f5c947
7
+ data.tar.gz: f8629f4508c2a84f4a7f9d45f5693f0904a35318ac83b5555bc621f96ec9f46804039400c0841f5904796a0ae123fdd2193241b206cf5675d4930f328c1d9f0b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (0.4.3)
4
+ gitlab_quality-test_tooling (0.5.0)
5
5
  activesupport (~> 6.1)
6
6
  gitlab (~> 4.18.0)
7
7
  http (~> 5.0)
@@ -32,6 +32,11 @@ options = OptionParser.new do |opts|
32
32
  params[:system_logs] = system_log_files
33
33
  end
34
34
 
35
+ opts.on('--base-issue-labels BASE_ISSUE_LABELS', String,
36
+ 'Labels to add to new failure issues') do |base_issue_labels|
37
+ params[:base_issue_labels] = base_issue_labels.split(',')
38
+ end
39
+
35
40
  opts.on('--dry-run', "Perform a dry-run (don't create or update issues)") do
36
41
  params[:dry_run] = true
37
42
  end
@@ -18,9 +18,17 @@ module GitlabQuality
18
18
  puts "The following note would have been posted on #{project}##{iid} issue: #{note}"
19
19
  end
20
20
 
21
+ def edit_issue_note(issue_iid:, note_id:, note:)
22
+ puts "The following note would have been edited on #{project}##{issue_iid} (note #{note_id}) issue: #{note}"
23
+ end
24
+
21
25
  def add_note_to_issue_discussion_as_thread(iid:, discussion_id:, body:)
22
26
  puts "The following discussion note would have been posted on #{project}##{iid} (discussion #{discussion_id}) issue: #{body}"
23
27
  end
28
+
29
+ def upload_file(file_fullpath:)
30
+ puts "The following file would have been uploaded: #{file_fullpath}"
31
+ end
24
32
  end
25
33
  end
26
34
  end
@@ -24,23 +24,24 @@ module GitlabQuality
24
24
  ISSUE_STACKTRACE_REGEX = /### Stack trace\s*(```)#{FAILURE_STACKTRACE_REGEX}(```)/m
25
25
  FAILED_JOB_DESCRIPTION_REGEX = %r{First happened in https?://\S+\.}m
26
26
  FAILED_JOB_NOTE_REGEX = %r{Failed most recently in \D+ pipeline: https?://\S+}
27
- NEW_ISSUE_LABELS = Set.new(%w[QA Quality test failure::new priority::2]).freeze
27
+ NEW_ISSUE_LABELS = Set.new(%w[test failure::new priority::2]).freeze
28
28
  IGNORE_EXCEPTIONS = ['Net::ReadTimeout'].freeze
29
29
  SCREENSHOT_IGNORED_ERRORS = ['500 Internal Server Error', 'fabricate_via_api!', 'Error Code 500'].freeze
30
30
 
31
31
  MultipleIssuesFound = Class.new(StandardError)
32
32
 
33
- def initialize(max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION, system_logs: [], **kwargs)
33
+ def initialize(max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION, system_logs: [], base_issue_labels: [], **kwargs)
34
34
  super
35
35
  @max_diff_ratio = max_diff_ratio.to_f
36
36
  @system_logs = Dir.glob(system_logs)
37
+ @base_issue_labels = base_issue_labels || []
37
38
  @issue_type = 'issue'
38
39
  @commented_issue_list = Set.new
39
40
  end
40
41
 
41
42
  private
42
43
 
43
- attr_reader :max_diff_ratio, :system_logs
44
+ attr_reader :max_diff_ratio, :system_logs, :base_issue_labels
44
45
 
45
46
  def run!
46
47
  puts "Reporting test failures in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
@@ -117,7 +118,7 @@ module GitlabQuality
117
118
  end
118
119
 
119
120
  def pipeline_issues_with_similar_stacktrace(test)
120
- gitlab.find_issues(options: { state: 'opened', labels: 'QA,failure::new',
121
+ gitlab.find_issues(options: { state: 'opened', labels: (base_issue_labels + %w[failure::new]).join(','),
121
122
  created_after: past_timestamp(2) }).select do |issue|
122
123
  job_url_from_issue = failed_issue_job_url(issue)
123
124
  next unless pipeline == pipeline_env_from_job_url(job_url_from_issue)
@@ -268,7 +269,7 @@ module GitlabQuality
268
269
  "\n### Stack trace",
269
270
  "```\n#{full_stacktrace(test)}\n```",
270
271
  "First happened in #{test.ci_job_url}.",
271
- "Related test case: #{test.testcase}.",
272
+ ("Related test case: #{test.testcase}." if test.testcase),
272
273
  screenshot_section(test),
273
274
  system_log_errors_section(test)
274
275
  ].compact.join("\n\n")
@@ -295,7 +296,7 @@ module GitlabQuality
295
296
  end
296
297
 
297
298
  def up_to_date_labels(test:, issue: nil, new_labels: Set.new)
298
- super << pipeline_name_label
299
+ base_issue_labels + (super << pipeline_name_label).to_a
299
300
  end
300
301
 
301
302
  def post_or_update_failed_job_note(issue, test)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "0.4.3"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_quality-test_tooling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality