Class: Gitlab::QA::Report::ResultsInIssues

Inherits:
ReportAsIssue show all
Includes:
ResultsReporterShared
Defined in:
lib/gitlab/qa/report/results_in_issues.rb

Overview

Uses the API to create or update GitLab test result issues with the results of tests from RSpec report files.

Constant Summary

Constants included from ResultsReporterShared

Gitlab::QA::Report::ResultsReporterShared::TEST_CASE_RESULTS_SECTION_TEMPLATE

Constants inherited from ReportAsIssue

Gitlab::QA::Report::ReportAsIssue::MAX_TITLE_LENGTH

Instance Method Summary collapse

Methods included from ResultsReporterShared

#find_issue, #find_issue_by_iid, #issue_title_needs_updating?, #new_issue_labels, #search_term, #up_to_date_labels, #update_issue_title

Methods inherited from ReportAsIssue

#invoke!

Constructor Details

#initialize(**kwargs) ⇒ ResultsInIssues

Returns a new instance of ResultsInIssues.



10
11
12
13
# File 'lib/gitlab/qa/report/results_in_issues.rb', line 10

def initialize(**kwargs)
  super
  @issue_type = 'issue'
end

Instance Method Details



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/qa/report/results_in_issues.rb', line 15

def get_related_issue(testcase, test)
  issue = find_linked_results_issue_by_iid(testcase, test)
  is_new = false

  if issue
    issue = update_issue_title(issue, test) if issue_title_needs_updating?(issue, test)
  else
    puts "No valid issue link found"
    issue = find_or_create_results_issue(test)
    is_new = true
  end

  [issue, is_new]
end

#update_issue(issue, test) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gitlab/qa/report/results_in_issues.rb', line 30

def update_issue(issue, test)
  new_labels = issue_labels(issue)
  new_labels |= ['Testcase Linked']

  labels_updated = update_labels(issue, test, new_labels)
  note_posted = note_status(issue, test)

  if labels_updated || note_posted
    puts "Issue updated: #{issue.web_url}"
  else
    puts "Test passed, no results issue update needed."
  end
end