Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report: Jobs last success date subsection #75

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions database/scripts/close_old_known_issues.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/')

Expand Down
1 change: 1 addition & 0 deletions database/scripts/format_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion database/scripts/generate_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [],
},
Expand Down
3 changes: 2 additions & 1 deletion database/scripts/get_known_issues.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ SELECT error_name,
job_name,
github_issue,
status
FROM test_fail_issues;
FROM test_fail_issues
WHERE status LIKE "%@param1@%";
9 changes: 9 additions & 0 deletions database/scripts/jobs_last_success.sql
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions database/scripts/jobs_never_passed.sql
Original file line number Diff line number Diff line change
@@ -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;
29 changes: 25 additions & 4 deletions database/scripts/lib/buildfarm_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Crola1702 marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
13 changes: 11 additions & 2 deletions database/scripts/lib/report_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Crola1702 marked this conversation as resolved.
Show resolved Hide resolved
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 <details> and <summary> tags to prevent long reports
details_subcategories = ['test_regressions_flaky', 'jobs_failing']
output_report = ""

report_hash.each_pair do |category, subcategory_hash|
Expand All @@ -140,7 +149,7 @@ def self.format_report(report_hash)

subcategory_report_title = "<h2>#{subcategory.gsub('_', ' ').capitalize}</h2>\n"
subcategory_report_str = "#{subcategory_report_title}\n#{subcategory_report}\n"
subcategory_report_str = "<details><summary>#{subcategory_report_title}</summary>\n\n#{subcategory_report}</details>\n" if subcategory == 'test_regressions_flaky'
subcategory_report_str = "<details><summary>#{subcategory_report_title}</summary>\n\n#{subcategory_report}</details>\n" if details_subcategories.include? subcategory
output_report += subcategory_report_str
end
end
Expand Down