diff --git a/database/scripts/close_old_known_issues.sh b/database/scripts/close_old_known_issues.sh index 67db85b..317ca08 100755 --- a/database/scripts/close_old_known_issues.sh +++ b/database/scripts/close_old_known_issues.sh @@ -7,14 +7,9 @@ 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) +for Line in $(./sql_run.sh get_known_issues.sql OPEN) 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 8f40648..4a38b6e 100755 --- a/database/scripts/format_report.rb +++ b/database/scripts/format_report.rb @@ -10,6 +10,7 @@ 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 a57b011..303e4d3 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' => [], + 'jobs_failing' => maintenance_jobs_failing = BuildfarmToolsLib::jobs_failing(days_exclude: 7), 'gh_issues_reported' => [], 'tests_disabled' => [], }, diff --git a/database/scripts/get_known_issues.sql b/database/scripts/get_known_issues.sql index d78f708..0b503aa 100644 --- a/database/scripts/get_known_issues.sql +++ b/database/scripts/get_known_issues.sql @@ -2,4 +2,5 @@ SELECT error_name, job_name, github_issue, status -FROM test_fail_issues; \ No newline at end of file +FROM test_fail_issues +WHERE status LIKE "%@param1@%"; diff --git a/database/scripts/jobs_last_success.sql b/database/scripts/jobs_last_success.sql new file mode 100644 index 0000000..a45e53a --- /dev/null +++ b/database/scripts/jobs_last_success.sql @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000..efc7f99 --- /dev/null +++ b/database/scripts/jobs_never_passed.sql @@ -0,0 +1,11 @@ +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 0083057..8028ae5 100644 --- a/database/scripts/lib/buildfarm_tools.rb +++ b/database/scripts/lib/buildfarm_tools.rb @@ -22,11 +22,9 @@ def self.build_regressions_today(filter_known: false) out end - def self.known_issues(status: nil) + def self.known_issues(status: '') # Keys: error_name, job_name, github_issue, status - out = run_command('./sql_run.sh get_known_issues.sql') - out.filter! { |e| e['status'] == status.upcase } unless status.nil? - out + run_command("./sql_run.sh get_known_issues.sql", args: [status.upcase]) end def self.error_appearances_in_job(test_name, job_name) @@ -92,6 +90,29 @@ 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 d38b42c..7c32386 100644 --- a/database/scripts/lib/report_formatter.rb +++ b/database/scripts/lib/report_formatter.rb @@ -127,10 +127,19 @@ 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| @@ -140,7 +149,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 subcategory == 'test_regressions_flaky' + subcategory_report_str = "
#{subcategory_report_title}\n\n#{subcategory_report}
\n" if details_subcategories.include? subcategory output_report += subcategory_report_str end end