Class: GitlabQuality::TestTooling::Report::FailedTestIssue
- Inherits:
-
HealthProblemReporter
- Object
- ReportAsIssue
- HealthProblemReporter
- GitlabQuality::TestTooling::Report::FailedTestIssue
- Defined in:
- lib/gitlab_quality/test_tooling/report/failed_test_issue.rb
Overview
Uses the API to create GitLab issues for any failed test coming from JSON test reports.
-
Takes the JSON test reports like rspec-*.json
-
Takes a project where failed test issues should be created
-
For every passed test in the report:
-
Find issue by test hash or create a new issue if no issue was found
-
Add a failure report in the “Failure reports” note
-
Constant Summary collapse
- IDENTITY_LABELS =
['test', 'test-health:failures', 'automation:bot-authored'].freeze
- NEW_ISSUE_LABELS =
Set.new(['type::maintenance', 'failure::new', 'priority::3', 'severity::3', 'suppress-contributor-links', *IDENTITY_LABELS]).freeze
- REPORT_SECTION_HEADER =
'#### Failure reports'- FAILURE_STACKTRACE_REGEX =
%r{(?:(?:.*Failure/Error:(?<stacktrace>.+))|(?<stacktrace>.+))}m
- ISSUE_STACKTRACE_REGEX =
/##### Stack trace\s*(```)#{FAILURE_STACKTRACE_REGEX}(```)\n*/m
- DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION =
0.15
Constants inherited from HealthProblemReporter
HealthProblemReporter::BASE_SEARCH_LABELS, HealthProblemReporter::FOUND_IN_MASTER_LABEL, HealthProblemReporter::FOUND_IN_MR_LABEL
Constants included from Concerns::IssueReports
Concerns::IssueReports::DAILY_REPORTS_THRESHOLDS, Concerns::IssueReports::DISPLAYED_HISTORY_REPORTS_THRESHOLD, Concerns::IssueReports::FAILED_JOB_DESCRIPTION_REGEX, Concerns::IssueReports::JOB_URL_REGEX, Concerns::IssueReports::LATEST_REPORTS_TO_SHOW, Concerns::IssueReports::REPORT_ITEM_REGEX
Constants included from Concerns::Utils
Concerns::Utils::MAX_TITLE_LENGTH
Instance Method Summary collapse
-
#initialize(base_issue_labels: nil, max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION, **kwargs) ⇒ FailedTestIssue
constructor
A new instance of FailedTestIssue.
- #most_recent_report_date_for_issue(issue_iid:) ⇒ Object
Methods included from Concerns::IssueReports
#failed_issue_job_url, #failed_issue_job_urls, #increment_reports, #increment_total_reports_count, #initial_reports_section
Methods included from Concerns::GroupAndCategoryLabels
#group_and_category_labels_for_test
Methods inherited from ReportAsIssue
Methods included from Concerns::Utils
#label_names_to_label_quick_action, #new_issue_title, #partial_file_path, #pipeline, #readable_duration, #search_safe, #title_from_test
Constructor Details
#initialize(base_issue_labels: nil, max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION, **kwargs) ⇒ FailedTestIssue
Returns a new instance of FailedTestIssue.
22 23 24 25 26 27 28 29 30 |
# File 'lib/gitlab_quality/test_tooling/report/failed_test_issue.rb', line 22 def initialize( base_issue_labels: nil, max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION, **kwargs) super(**kwargs) @base_issue_labels = Set.new(base_issue_labels) @max_diff_ratio = max_diff_ratio.to_f end |
Instance Method Details
#most_recent_report_date_for_issue(issue_iid:) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab_quality/test_tooling/report/failed_test_issue.rb', line 32 def most_recent_report_date_for_issue(issue_iid:) reports_discussion = existing_reports_discussion(issue_iid: issue_iid) return unless reports_discussion # We're skipping the first note of the discussion as this is the "non-collapsible note", aka # the "header note", which doesn't contain any stack trace. reports_discussion.notes[1..].filter_map do |reports_note| most_recent_report_from_reports_note(reports_note)&.report_date end.max end |