Class: GitlabQuality::TestTooling::Report::TestHealthIssueFinder
- Inherits:
-
ReportAsIssue
- Object
- ReportAsIssue
- GitlabQuality::TestTooling::Report::TestHealthIssueFinder
- Defined in:
- lib/gitlab_quality/test_tooling/report/test_health_issue_finder.rb
Constant Summary collapse
- HEALTH_PROBLEM_TYPE_TO_LABEL =
{ 'pass-after-retry' => 'test-health:pass-after-retry', 'slow' => 'test-health:slow', 'failures' => 'test-health:failures' }.freeze
Constants included from Concerns::Utils
Concerns::Utils::MAX_TITLE_LENGTH
Instance Method Summary collapse
- #applicable_tests ⇒ Object
- #found_existing_unhealthy_test_issue? ⇒ Boolean
-
#initialize(health_problem_type: [], **kwargs) ⇒ TestHealthIssueFinder
constructor
A new instance of TestHealthIssueFinder.
- #run! ⇒ Object
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(health_problem_type: [], **kwargs) ⇒ TestHealthIssueFinder
Returns a new instance of TestHealthIssueFinder.
16 17 18 19 20 |
# File 'lib/gitlab_quality/test_tooling/report/test_health_issue_finder.rb', line 16 def initialize(health_problem_type: [], **kwargs) super(**kwargs) @health_problem_type = health_problem_type end |
Instance Method Details
#applicable_tests ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/gitlab_quality/test_tooling/report/test_health_issue_finder.rb', line 45 def applicable_tests applicable_tests = [] TestResults::Builder.new(file_glob: files, token: token, project: project).test_results_per_file do |test_results| applicable_tests = test_results.select { |test| test_is_applicable?(test) } end applicable_tests end |
#found_existing_unhealthy_test_issue? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/gitlab_quality/test_tooling/report/test_health_issue_finder.rb', line 22 def found_existing_unhealthy_test_issue? issue_url = invoke! !issue_url.nil? && !issue_url.empty? end |
#run! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gitlab_quality/test_tooling/report/test_health_issue_finder.rb', line 28 def run! existing_issue_found = nil applicable_tests.each do |test| issues = find_issues_by_hash(test_hash(test), state: 'opened', labels: search_labels) next if issues.empty? existing_issue_found = issues.first.web_url puts "Found an existing test health issue of type #{health_problem_type} for test #{test.file}:#{test.line_number}: #{existing_issue_found}." break end puts "Did not find an existing test health issue of type #{health_problem_type}." unless existing_issue_found existing_issue_found end |