Module: GitlabQuality::TestTooling::Report::Concerns::IssueReports
- Included in:
- HealthProblemReporter, RelateFailureIssue
- Defined in:
- lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb
Defined Under Namespace
Classes: ReportListItem, ReportsList
Constant Summary collapse
- JOB_URL_REGEX =
%r{(?<job_url>https://(?<host>[\w.]+)/(?<project_path>[\w\-./]+)/-/jobs/\d+)}- FAILED_JOB_DESCRIPTION_REGEX =
/First happened in #{JOB_URL_REGEX}\./m- REPORT_ITEM_REGEX =
/^1\. (?<report_date>\d{4}-\d{2}-\d{2}): #{JOB_URL_REGEX} \((?<pipeline_url>\S+)\) ?(?<extra_content>.*)$/- LATEST_REPORTS_TO_SHOW =
10- DISPLAYED_HISTORY_REPORTS_THRESHOLD =
510- DAILY_REPORTS_THRESHOLDS =
10
Instance Method Summary collapse
- #failed_issue_job_url(issue) ⇒ Object
- #failed_issue_job_urls(issue) ⇒ Object
- #increment_reports(current_reports_content:, test:, reports_section_header: '### Reports', item_extra_content: nil, reports_extra_content: nil) ⇒ Object
- #increment_total_reports_count(reports_section_header:, content:, reports:) ⇒ Object
- #initial_reports_section(test, item_extra_content: nil) ⇒ Object
Instance Method Details
#failed_issue_job_url(issue) ⇒ Object
160 161 162 163 164 |
# File 'lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb', line 160 def failed_issue_job_url(issue) job_urls_from_description(issue.description, REPORT_ITEM_REGEX).last || # Legacy format job_urls_from_description(issue.description, FAILED_JOB_DESCRIPTION_REGEX).last end |
#failed_issue_job_urls(issue) ⇒ Object
166 167 168 169 170 |
# File 'lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb', line 166 def failed_issue_job_urls(issue) job_urls_from_description(issue.description, REPORT_ITEM_REGEX) + # Legacy format job_urls_from_description(issue.description, FAILED_JOB_DESCRIPTION_REGEX) end |
#increment_reports(current_reports_content:, test:, reports_section_header: '### Reports', item_extra_content: nil, reports_extra_content: nil) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb', line 124 def increment_reports( current_reports_content:, test:, reports_section_header: '### Reports', item_extra_content: nil, reports_extra_content: nil) preserved_content = current_reports_content.split(reports_section_header).first&.strip reports = report_lines(current_reports_content) + [ReportsList.report_list_item(test, item_extra_content: item_extra_content)] total_reports_count = increment_total_reports_count( reports_section_header: reports_section_header, content: current_reports_content, reports: reports ) ReportsList.new( preserved_content: preserved_content, section_header: reports_section_header, reports: reports, total_reports_count: total_reports_count, extra_content: reports_extra_content ) end |
#increment_total_reports_count(reports_section_header:, content:, reports:) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb', line 148 def increment_total_reports_count(reports_section_header:, content:, reports:) reports_count = reports.count return reports_count if reports_count < DISPLAYED_HISTORY_REPORTS_THRESHOLD count_match = content.match(/#{Regexp.escape(reports_section_header)} \((\d+)\)/) return reports_count unless count_match count_match[1].to_i + 1 end |
#initial_reports_section(test, item_extra_content: nil) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb', line 116 def initial_reports_section(test, item_extra_content: nil) <<~REPORTS ### Reports (1) #{ReportsList.report_list_item(test, item_extra_content: item_extra_content)} REPORTS end |