gitlab_quality-test_tooling 2.1.0 → 2.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7437a045ff423ca3c6585be2aa13b11d97fd94abb5d8ffd95a14d11f48970b68
|
4
|
+
data.tar.gz: fd91b826d48c661a7b05f196857ec95c7fc59d478e8718ffa9ca5d534f38ffe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4de31f3a187af7c92df5b015c631e5fa1278fa6a3d62f8111294ce07c245236b9e30e78a6760859eee4d024ee0de62dd544201e2d3e4beec73ef7be00f443def
|
7
|
+
data.tar.gz: 1d44821f07f2d61ac2d1b31b0837149bcf015070ffa1c4e6791d4685c3be322ab0991a28bf1551130eaf274045d58855a405b680948673f78aa208c9a34cab77
|
data/Gemfile.lock
CHANGED
@@ -11,13 +11,15 @@ module GitlabQuality
|
|
11
11
|
FAILED_JOB_DESCRIPTION_REGEX = /First happened in #{JOB_URL_REGEX}\./m
|
12
12
|
REPORT_ITEM_REGEX = /^1\. (?<report_date>\d{4}-\d{2}-\d{2}): #{JOB_URL_REGEX} \((?<pipeline_url>\S+)\) ?(?<extra_content>.*)$/
|
13
13
|
LATEST_REPORTS_TO_SHOW = 10
|
14
|
+
DISPLAYED_HISTORY_REPORTS_THRESHOLD = 510 # https://gitlab.com/gitlab-org/quality/engineering-productivity/team/-/issues/587
|
14
15
|
DAILY_REPORTS_THRESHOLDS = 10
|
15
16
|
|
16
17
|
class ReportsList
|
17
|
-
def initialize(preserved_content:, section_header:, reports:, extra_content:)
|
18
|
+
def initialize(preserved_content:, section_header:, reports:, total_reports_count:, extra_content:)
|
18
19
|
@preserved_content = preserved_content
|
19
20
|
@section_header = section_header
|
20
21
|
@reports = reports
|
22
|
+
@total_reports_count = total_reports_count
|
21
23
|
@extra_content = extra_content
|
22
24
|
end
|
23
25
|
|
@@ -31,14 +33,14 @@ module GitlabQuality
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def reports_count
|
34
|
-
|
36
|
+
total_reports_count
|
35
37
|
end
|
36
38
|
|
37
39
|
def to_s
|
38
40
|
[
|
39
41
|
preserved_content,
|
40
42
|
"#{section_header} (#{reports_count})",
|
41
|
-
reports_list,
|
43
|
+
reports_list(total_reports_count),
|
42
44
|
extra_content
|
43
45
|
].reject(&:blank?).compact.join("\n\n")
|
44
46
|
end
|
@@ -53,15 +55,16 @@ module GitlabQuality
|
|
53
55
|
|
54
56
|
private
|
55
57
|
|
56
|
-
attr_reader :preserved_content, :section_header, :reports, :extra_content
|
58
|
+
attr_reader :preserved_content, :section_header, :reports, :total_reports_count, :extra_content
|
57
59
|
|
58
|
-
def reports_list
|
60
|
+
def reports_list(total_reports_count)
|
59
61
|
if sorted_reports.size > LATEST_REPORTS_TO_SHOW
|
62
|
+
max_displayed_reports = DISPLAYED_HISTORY_REPORTS_THRESHOLD - LATEST_REPORTS_TO_SHOW
|
60
63
|
[
|
61
64
|
"Last #{LATEST_REPORTS_TO_SHOW} reports:",
|
62
|
-
|
63
|
-
"<details><summary>
|
64
|
-
|
65
|
+
displayed_reports[...LATEST_REPORTS_TO_SHOW].join("\n"),
|
66
|
+
"<details><summary>With #{total_reports_count - LATEST_REPORTS_TO_SHOW} more reports (displaying up to #{max_displayed_reports} reports) </summary>",
|
67
|
+
displayed_reports[LATEST_REPORTS_TO_SHOW..].join("\n"),
|
65
68
|
"</details>"
|
66
69
|
].join("\n\n")
|
67
70
|
else
|
@@ -70,7 +73,12 @@ module GitlabQuality
|
|
70
73
|
end
|
71
74
|
|
72
75
|
def sorted_reports
|
73
|
-
@sorted_reports ||=
|
76
|
+
@sorted_reports ||=
|
77
|
+
reports.sort_by { |report| [report.report_date, report.job_id, report.to_s] }.reverse
|
78
|
+
end
|
79
|
+
|
80
|
+
def displayed_reports
|
81
|
+
sorted_reports[0...DISPLAYED_HISTORY_REPORTS_THRESHOLD]
|
74
82
|
end
|
75
83
|
end
|
76
84
|
|
@@ -88,8 +96,8 @@ module GitlabQuality
|
|
88
96
|
"1. #{report_date}: #{job_url} (#{pipeline_url}) #{extra_content}".strip
|
89
97
|
end
|
90
98
|
|
91
|
-
def
|
92
|
-
|
99
|
+
def job_id
|
100
|
+
job_url.split('/').last
|
93
101
|
end
|
94
102
|
|
95
103
|
private
|
@@ -122,14 +130,33 @@ module GitlabQuality
|
|
122
130
|
preserved_content = current_reports_content.split(reports_section_header).first&.strip
|
123
131
|
reports = report_lines(current_reports_content) + [ReportsList.report_list_item(test, item_extra_content: item_extra_content)]
|
124
132
|
|
133
|
+
total_reports_count = increment_total_reports_count(
|
134
|
+
reports_section_header: reports_section_header,
|
135
|
+
content: current_reports_content,
|
136
|
+
reports: reports
|
137
|
+
)
|
138
|
+
|
125
139
|
ReportsList.new(
|
126
140
|
preserved_content: preserved_content,
|
127
141
|
section_header: reports_section_header,
|
128
142
|
reports: reports,
|
143
|
+
total_reports_count: total_reports_count,
|
129
144
|
extra_content: reports_extra_content
|
130
145
|
)
|
131
146
|
end
|
132
147
|
|
148
|
+
def increment_total_reports_count(reports_section_header:, content:, reports:)
|
149
|
+
reports_count = reports.count
|
150
|
+
|
151
|
+
return reports_count if reports_count < DISPLAYED_HISTORY_REPORTS_THRESHOLD
|
152
|
+
|
153
|
+
count_match = content.match(/#{Regexp.escape(reports_section_header)} \((\d+)\)/)
|
154
|
+
|
155
|
+
return reports_count unless count_match
|
156
|
+
|
157
|
+
count_match[1].to_i + 1
|
158
|
+
end
|
159
|
+
|
133
160
|
def failed_issue_job_url(issue)
|
134
161
|
job_urls_from_description(issue.description, REPORT_ITEM_REGEX).last ||
|
135
162
|
# Legacy format
|
@@ -16,9 +16,14 @@ module GitlabQuality
|
|
16
16
|
|
17
17
|
def parse
|
18
18
|
JSON.parse(File.read(path))
|
19
|
+
rescue JSON::ParserError
|
20
|
+
Runtime::Logger.debug("#{self.class.name}##{__method__} attempted to parse invalid JSON at path: #{path}")
|
21
|
+
{}
|
19
22
|
end
|
20
23
|
|
21
24
|
def process
|
25
|
+
return [] if results.empty?
|
26
|
+
|
22
27
|
results['examples'].map do |test|
|
23
28
|
GitlabQuality::TestTooling::TestResult::JsonTestResult.new(report: test, project: project, token: token)
|
24
29
|
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: 2.
|
4
|
+
version: 2.2.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-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|