gitlab_quality-test_tooling 1.34.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: 6d3f45e3af6f11c3ebca5f44f3d717960c1ac20cffdc13db75a16d68c9eecfbd
4
- data.tar.gz: 0edf629fc7f432a779141be67a231887224a78793defedad416df50b327ecbcb
3
+ metadata.gz: af317c2353ed0cd5ac69cda95756183c9811e4b9983397e5658972cc2ec80853
4
+ data.tar.gz: 4ef83ce3161fe6560b6e3e9d7426673e50b80291973ccbff0a5051184dcc13a4
5
5
  SHA512:
6
- metadata.gz: 7570cde0cd99ea0fe3148f9a8c1f9a7035c165fb0f5506623a79d3f2c3227581d6de878fd56c9a5d5f4c4bae22191d688f49355c74e4b4926b6362ef5d3f8d06
7
- data.tar.gz: 0112df035902806c60a82433118669b43bcd9feff89fd8dc7061ee6ffcda9c53ead791c7df4c188567b2b16ee3be8880e269088f4bee944b944aa2dafb60bfef
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.34.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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "1.34.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.34.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-08-19 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