gitlab_quality-test_tooling 1.33.0 → 1.35.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: 19bea0cdd5a0f100cec11b00c6415c39f8ab637165f67171ad6edac7c33128b9
4
- data.tar.gz: 9727a96a8ca06238ae89bacdb6f3cc88b66451a6190cac8df48fc82102e7c155
3
+ metadata.gz: af317c2353ed0cd5ac69cda95756183c9811e4b9983397e5658972cc2ec80853
4
+ data.tar.gz: 4ef83ce3161fe6560b6e3e9d7426673e50b80291973ccbff0a5051184dcc13a4
5
5
  SHA512:
6
- metadata.gz: 5dfdfea69e7e2f3500b243d83489050e6d0f2a251a1657a43250206a3710c0b848bdbb38ac34e645a2ec1dc4fc19ce4df47afa21a8c038754ac76f6b606cb14f
7
- data.tar.gz: 7aa7942d0f0f86c75a2f07eea937c70c9f725b4025302778176e0fb0b9a14db41acd983d1202f86b6a59ce6f00b1c6f85ba214d86deb1a947167a57ff82ad3a4
6
+ metadata.gz: 8a015884914a10e72b3ad2bada2ba48444a15dd701a752c54029fa5acf9906e3384ac0ca9d991c04657b31a9fc25d6ec5708ed128e232ac6c5e8a4e76563c1db
7
+ data.tar.gz: bec57b7c3f65ead2655c992ee9ac972551bbcff9454b81b2b76a5ae11479e7f441717244a3b853c857e3f5ac4377eafbfd116272cea75feca20fc7b1c0d43397
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (1.33.0)
4
+ gitlab_quality-test_tooling (1.35.0)
5
5
  activesupport (>= 7.0, < 7.2)
6
6
  amatch (~> 0.4.1)
7
7
  gitlab (~> 4.19)
@@ -20,6 +20,18 @@ module GitlabQuality
20
20
  FOUND_IN_MR_LABEL = '~"found:in MR"'
21
21
  FOUND_IN_MASTER_LABEL = '~"found:master"'
22
22
 
23
+ def initialize(input_files: [], **kwargs)
24
+ super(input_files: input_files, **kwargs)
25
+ end
26
+
27
+ def most_recent_report_date_for_issue(issue_iid:)
28
+ if report_in_discussion?
29
+ most_recent_report_from_discussion(issue_iid: issue_iid)
30
+ else
31
+ most_recent_report_from_note(issue_iid: issue_iid)
32
+ end
33
+ end
34
+
23
35
  private
24
36
 
25
37
  def problem_type
@@ -62,6 +74,28 @@ module GitlabQuality
62
74
  found_label
63
75
  end
64
76
 
77
+ def most_recent_report_from_discussion(issue_iid:)
78
+ reports_discussion = existing_reports_discussion(issue_iid: issue_iid)
79
+ return unless reports_discussion
80
+
81
+ # We're skipping the first note of the discussion as this is the "non-collapsible note", aka
82
+ # the "header note", which doesn't contain any stack trace.
83
+ reports_discussion.notes[1..].filter_map do |reports_note|
84
+ most_recent_report_from_reports_note(reports_note)&.report_date
85
+ end.max
86
+ end
87
+
88
+ def most_recent_report_from_note(issue_iid:)
89
+ reports_note = existing_reports_note(issue_iid: issue_iid)
90
+ return unless reports_note
91
+
92
+ most_recent_report_from_reports_note(reports_note)&.report_date
93
+ end
94
+
95
+ def most_recent_report_from_reports_note(reports_note)
96
+ @most_recent_report_from_reports_note ||= report_lines(reports_note&.body.to_s).first
97
+ end
98
+
65
99
  def run!
66
100
  puts "Reporting tests in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
67
101
 
@@ -102,11 +136,11 @@ module GitlabQuality
102
136
  def add_report_to_issue(issue:, test:, related_issues:) # rubocop:disable Metrics/AbcSize -- FIXME
103
137
  current_reports_note =
104
138
  if report_in_discussion?
105
- reports_discussion = find_or_create_reports_discussion(issue: issue)
139
+ reports_discussion = find_or_create_reports_discussion(issue_iid: issue.iid)
106
140
 
107
141
  find_failure_discussion_note(issue: issue, test: test, reports_discussion: reports_discussion)
108
142
  else
109
- existing_reports_note(issue: issue)
143
+ existing_reports_note(issue_iid: issue.iid)
110
144
  end
111
145
 
112
146
  new_reports_list = add_report_for_test(current_reports_content: current_reports_note&.body.to_s, test: test)
@@ -135,15 +169,15 @@ module GitlabQuality
135
169
  end
136
170
  end
137
171
 
138
- def find_or_create_reports_discussion(issue:)
139
- reports_discussion = existing_reports_discussion(issue: issue)
172
+ def find_or_create_reports_discussion(issue_iid:)
173
+ reports_discussion = existing_reports_discussion(issue_iid: issue_iid)
140
174
  return reports_discussion if reports_discussion
141
175
 
142
- gitlab.create_issue_discussion(iid: issue.iid, note: report_section_header)
176
+ gitlab.create_issue_discussion(iid: issue_iid, note: report_section_header)
143
177
  end
144
178
 
145
- def existing_reports_discussion(issue:)
146
- gitlab.find_issue_discussions(iid: issue.iid).find do |discussion|
179
+ def existing_reports_discussion(issue_iid:)
180
+ gitlab.find_issue_discussions(iid: issue_iid).find do |discussion|
147
181
  next if discussion.individual_note
148
182
  next unless discussion.notes.first
149
183
 
@@ -151,8 +185,8 @@ module GitlabQuality
151
185
  end
152
186
  end
153
187
 
154
- def existing_reports_note(issue:)
155
- gitlab.find_issue_notes(iid: issue.iid).find do |note|
188
+ def existing_reports_note(issue_iid:)
189
+ gitlab.find_issue_notes(iid: issue_iid).find do |note|
156
190
  note.body.start_with?(report_section_header)
157
191
  end
158
192
  end
@@ -109,6 +109,10 @@ module GitlabQuality
109
109
  description: updated_description
110
110
  }
111
111
 
112
+ # We reopen closed issues to not lose any history
113
+ state_event = issue.state == 'closed' ? 'reopen' : nil
114
+ issue_attrs[:state_event] = state_event if state_event
115
+
112
116
  gitlab.edit_issue(iid: issue.iid, options: issue_attrs)
113
117
  puts " => Added a report in #{issue.web_url}!"
114
118
  end
@@ -11,7 +11,6 @@ module GitlabQuality
11
11
  attr_reader :project, :ref, :report_issue, :processed_commits
12
12
 
13
13
  TEST_PLATFORM_MAINTAINERS_SLACK_CHANNEL_ID = 'C0437FV9KBN' # test-platform-maintainers
14
- BATCH_LIMIT = 10
15
14
 
16
15
  def initialize(token:, project:, specs_file:, processor:, ref: 'master', dry_run: false)
17
16
  @specs_file = specs_file
@@ -29,7 +28,7 @@ module GitlabQuality
29
28
 
30
29
  contents['specs'].each do |spec|
31
30
  processor.create_commit(spec, self)
32
- break if processed_commits.keys.count >= BATCH_LIMIT
31
+ break if processed_commits.keys.count >= ENV.fetch('BATCH_LIMIT', 10)
33
32
  end
34
33
 
35
34
  processor.create_merge_requests(self)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "1.33.0"
5
+ VERSION = "1.35.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.33.0
4
+ version: 1.35.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-07-26 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control