From ffc328f299c4870205594fedbd2d32798a2fcfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B3bal=20Arroyo?= Date: Fri, 2 Aug 2024 11:27:01 -0500 Subject: [PATCH] Revert "Report: Jobs failing subsection (#75)" This reverts commit a6fb47c74f3c6819c7ee9ec00fdf18d54b9a77cb. --- database/scripts/close_old_known_issues.sh | 7 +++++- database/scripts/format_report.rb | 1 - database/scripts/generate_report.rb | 2 +- database/scripts/get_known_issues.sql | 3 +-- database/scripts/jobs_last_success.sql | 9 ------- database/scripts/jobs_never_passed.sql | 11 -------- database/scripts/lib/buildfarm_tools.rb | 29 +++------------------- database/scripts/lib/report_formatter.rb | 13 ++-------- 8 files changed, 14 insertions(+), 61 deletions(-) delete mode 100644 database/scripts/jobs_last_success.sql delete mode 100644 database/scripts/jobs_never_passed.sql diff --git a/database/scripts/close_old_known_issues.sh b/database/scripts/close_old_known_issues.sh index 317ca08..67db85b 100755 --- a/database/scripts/close_old_known_issues.sh +++ b/database/scripts/close_old_known_issues.sh @@ -7,9 +7,14 @@ close_issue() { ./sql_run.sh issue_close_by_name.sql "$error_name" "$error_job_name" } -for Line in $(./sql_run.sh get_known_issues.sql OPEN) +for Line in $(./sql_run.sh get_known_issues.sql) do + if [[ $Line =~ "CLOSED" ]] + then + continue + fi + error_name=$(echo $Line | sed 's/|.*//') error_job_name=$(echo $Line | sed 's/^.*|\(.*\)|.*|.*/\1/') diff --git a/database/scripts/format_report.rb b/database/scripts/format_report.rb index 4a38b6e..8f40648 100755 --- a/database/scripts/format_report.rb +++ b/database/scripts/format_report.rb @@ -10,7 +10,6 @@ report['urgent']['build_regressions'] = ReportFormatter::build_regressions(report['urgent']['build_regressions']) report['urgent']['test_regressions_consecutive'] = ReportFormatter::test_regressions_consecutive(report['urgent']['test_regressions_consecutive']) report['urgent']['test_regressions_flaky'] = ReportFormatter::test_regressions_flaky(report['urgent']['test_regressions_flaky']) -report['maintenance']['jobs_failing'] = ReportFormatter::jobs_failing(report['maintenance']['jobs_failing']) # Sample output: # puts report['urgent']['build_regressions'] diff --git a/database/scripts/generate_report.rb b/database/scripts/generate_report.rb index 303e4d3..a57b011 100755 --- a/database/scripts/generate_report.rb +++ b/database/scripts/generate_report.rb @@ -32,7 +32,7 @@ def generate_report(report_name, exclude_set) 'test_regressions_flaky' => urgent_flaky_test_regressions = BuildfarmToolsLib::flaky_test_regressions(group_issues: true), }, 'maintenance' => { - 'jobs_failing' => maintenance_jobs_failing = BuildfarmToolsLib::jobs_failing(days_exclude: 7), + 'jobs_failing' => [], 'gh_issues_reported' => [], 'tests_disabled' => [], }, diff --git a/database/scripts/get_known_issues.sql b/database/scripts/get_known_issues.sql index 0b503aa..d78f708 100644 --- a/database/scripts/get_known_issues.sql +++ b/database/scripts/get_known_issues.sql @@ -2,5 +2,4 @@ SELECT error_name, job_name, github_issue, status -FROM test_fail_issues -WHERE status LIKE "%@param1@%"; +FROM test_fail_issues; \ No newline at end of file diff --git a/database/scripts/jobs_last_success.sql b/database/scripts/jobs_last_success.sql deleted file mode 100644 index a45e53a..0000000 --- a/database/scripts/jobs_last_success.sql +++ /dev/null @@ -1,9 +0,0 @@ -SELECT job_name, last_success_time -FROM ( - SELECT bs.job_name, MAX(bs.build_datetime) AS last_success_time - FROM build_status bs - INNER JOIN server_status ss ON bs.job_name = ss.job_name - WHERE bs.status = 'SUCCESS' - GROUP BY bs.job_name -) AS last_success_times -ORDER BY last_success_time ASC; \ No newline at end of file diff --git a/database/scripts/jobs_never_passed.sql b/database/scripts/jobs_never_passed.sql deleted file mode 100644 index efc7f99..0000000 --- a/database/scripts/jobs_never_passed.sql +++ /dev/null @@ -1,11 +0,0 @@ -SELECT bs.job_name, - COUNT(*) as failed_build_count -FROM build_status bs -INNER JOIN server_status ss ON bs.job_name = ss.job_name -WHERE bs.job_name NOT IN ( - SELECT job_name - FROM build_status - WHERE status = 'SUCCESS' -) -GROUP BY bs.job_name -ORDER BY failed_build_count DESC; \ No newline at end of file diff --git a/database/scripts/lib/buildfarm_tools.rb b/database/scripts/lib/buildfarm_tools.rb index 8028ae5..0083057 100644 --- a/database/scripts/lib/buildfarm_tools.rb +++ b/database/scripts/lib/buildfarm_tools.rb @@ -22,9 +22,11 @@ def self.build_regressions_today(filter_known: false) out end - def self.known_issues(status: '') + def self.known_issues(status: nil) # Keys: error_name, job_name, github_issue, status - run_command("./sql_run.sh get_known_issues.sql", args: [status.upcase]) + out = run_command('./sql_run.sh get_known_issues.sql') + out.filter! { |e| e['status'] == status.upcase } unless status.nil? + out end def self.error_appearances_in_job(test_name, job_name) @@ -90,29 +92,6 @@ def self.test_regression_reported_issues(error_name, status: nil) is_known_issue.map { |issue| { 'github_issue' => issue['github_issue'], 'status' => issue['status'] } }.uniq end - def self.jobs_last_success - run_command('./sql_run.sh jobs_last_success.sql') - end - - def self.jobs_never_passed - run_command('./sql_run.sh jobs_never_passed.sql') - end - - def self.jobs_failing(days_exclude: 0) - # Keys: job_name, last_success - out = [] - jobs_never_passed.each do |e| - out << {"job_name" => e["job_name"], "last_success" => "Never"} - end - - jobs_last_success.each do |e| - last_success = DateTime.parse(e['last_success_time']) - next if last_success > (Date.today - days_exclude) - out << {"job_name" => e["job_name"], "last_success" => last_success.strftime('%Y-%m-%d')} - end - out - end - def self.run_command(cmd, args: [], keys: []) cmd += " '#{args.shift}'" until args.empty? begin diff --git a/database/scripts/lib/report_formatter.rb b/database/scripts/lib/report_formatter.rb index 7c32386..d38b42c 100644 --- a/database/scripts/lib/report_formatter.rb +++ b/database/scripts/lib/report_formatter.rb @@ -127,19 +127,10 @@ def self.test_regressions_flaky(tr_array) out += "### Warnings\n#{warnings_table}\n" if warnings_table.count("\n") > 2 out end - - def self.jobs_failing(job_array) - return "" if job_array.empty? - table = "| Job Name | Last Success |\n| -- | -- |\n" - job_array.each do |job| - table += "| #{job['job_name']} | #{job['last_success']} |\n" - end - table - end + def self.format_report(report_hash) # Use
and tags to prevent long reports - details_subcategories = ['test_regressions_flaky', 'jobs_failing'] output_report = "" report_hash.each_pair do |category, subcategory_hash| @@ -149,7 +140,7 @@ def self.format_report(report_hash) subcategory_report_title = "

#{subcategory.gsub('_', ' ').capitalize}

\n" subcategory_report_str = "#{subcategory_report_title}\n#{subcategory_report}\n" - subcategory_report_str = "
#{subcategory_report_title}\n\n#{subcategory_report}
\n" if details_subcategories.include? subcategory + subcategory_report_str = "
#{subcategory_report_title}\n\n#{subcategory_report}
\n" if subcategory == 'test_regressions_flaky' output_report += subcategory_report_str end end