Module: GitlabQuality::TestTooling::Report::Concerns::ResultsReporter
Constant Summary
collapse
- TEST_CASE_RESULTS_SECTION_TEMPLATE =
"\n\n### DO NOT EDIT BELOW THIS LINE\n\nActive and historical test results:"
Constants included
from Utils
Utils::MAX_TITLE_LENGTH
Instance Method Summary
collapse
Methods included from Utils
#label_names_to_label_quick_action, #new_issue_title, #partial_file_path, #pipeline, #readable_duration, #search_safe, #title_from_test
Instance Method Details
#find_issue(test) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb', line 14
def find_issue(test)
issues = search_for_issues(test)
warn(%(Too many #{issue_type}s found with the file path "#{test.file}" and name "#{test.name}")) if issues.many?
puts "Found existing #{issue_type}: #{issues.first.web_url}" unless issues.empty?
issues.first
end
|
#find_issue_by_iid(iid) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb', line 24
def find_issue_by_iid(iid)
issues = gitlab.find_issues(iid: iid) do |issue|
issue.state == 'opened' && issue.issue_type == issue_type
end
warn(%(#{issue_type} iid "#{iid}" not valid)) if issues.empty?
issues.first
end
|
#issue_title_needs_updating?(issue, test) ⇒ Boolean
34
35
36
|
# File 'lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb', line 34
def issue_title_needs_updating?(issue, test)
issue.title.strip != title_from_test(test) && !%w[canary production preprod release].include?(pipeline)
end
|
#new_issue_labels(_test) ⇒ Object
38
39
40
|
# File 'lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb', line 38
def new_issue_labels(_test)
%w[E2E status::automated suppress-contributor-links]
end
|
#up_to_date_labels(test:, issue: nil, new_labels: Set.new) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb', line 42
def up_to_date_labels(test:, issue: nil, new_labels: Set.new)
labels = super
labels |= new_issue_labels(test).to_set
labels.delete_if { |label| label.start_with?("#{pipeline}::") }
labels << (test.failures.empty? ? "#{pipeline}::passed" : "#{pipeline}::failed")
end
|
#update_issue(issue, test) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/gitlab_quality/test_tooling/report/concerns/results_reporter.rb', line 49
def update_issue(issue, test)
update_params = {}
old_title = issue.title.strip
new_title = title_from_test(test)
if old_title != new_title
update_params[:title] = new_title
warn(%(#{issue_type} title needs to be updated from '#{old_title}' to '#{new_title}'))
end
old_description = issue.description
new_description = updated_description(issue, test)
if old_description != new_description
warn(%(#{issue_type} description needs to be updated from '#{old_description}' to '#{new_description}'))
update_params[:description] = new_description
end
return if update_params.empty?
gitlab.edit_issue(iid: issue.iid, options: update_params)
end
|