@@ -148,9 +148,9 @@ def get_run_details(run_url: str) -> dict:
148148 return response .json ()
149149
150150
151- def get_checks_fails (client : Client , job_url : str ):
151+ def get_checks_fails (client : Client , commit_sha : str , branch_name : str ):
152152 """
153- Get tests that did not succeed for the given job URL .
153+ Get tests that did not succeed for the given commit and branch .
154154 Exclude checks that have status 'error' as they are counted in get_checks_errors.
155155 """
156156 query = f"""SELECT job_status, job_name, status as test_status, test_name, results_link
@@ -163,19 +163,21 @@ def get_checks_fails(client: Client, job_url: str):
163163 report_url as results_link,
164164 task_url
165165 FROM `gh-data`.checks
166+ WHERE commit_sha='{ commit_sha } ' AND head_ref='{ branch_name } '
166167 GROUP BY check_name, test_name, report_url, task_url
167168 )
168- WHERE task_url LIKE '{ job_url } %'
169- AND test_status IN ('FAIL', 'ERROR')
169+ WHERE test_status IN ('FAIL', 'ERROR')
170170 AND job_status!='error'
171171 ORDER BY job_name, test_name
172172 """
173173 return client .query_dataframe (query )
174174
175175
176- def get_checks_known_fails (client : Client , job_url : str , known_fails : dict ):
176+ def get_checks_known_fails (
177+ client : Client , commit_sha : str , branch_name : str , known_fails : dict
178+ ):
177179 """
178- Get tests that are known to fail for the given job URL .
180+ Get tests that are known to fail for the given commit and branch .
179181 """
180182 if len (known_fails ) == 0 :
181183 return pd .DataFrame ()
@@ -190,10 +192,10 @@ def get_checks_known_fails(client: Client, job_url: str, known_fails: dict):
190192 report_url as results_link,
191193 task_url
192194 FROM `gh-data`.checks
195+ WHERE commit_sha='{ commit_sha } ' AND head_ref='{ branch_name } '
193196 GROUP BY check_name, test_name, report_url, task_url
194197 )
195- WHERE task_url LIKE '{ job_url } %'
196- AND test_status='BROKEN'
198+ WHERE test_status='BROKEN'
197199 AND test_name IN ({ ',' .join (f"'{ test } '" for test in known_fails .keys ())} )
198200 ORDER BY job_name, test_name
199201 """
@@ -213,9 +215,9 @@ def get_checks_known_fails(client: Client, job_url: str, known_fails: dict):
213215 return df
214216
215217
216- def get_checks_errors (client : Client , job_url : str ):
218+ def get_checks_errors (client : Client , commit_sha : str , branch_name : str ):
217219 """
218- Get checks that have status 'error' for the given job URL .
220+ Get checks that have status 'error' for the given commit and branch .
219221 """
220222 query = f"""SELECT job_status, job_name, status as test_status, test_name, results_link
221223 FROM (
@@ -227,10 +229,10 @@ def get_checks_errors(client: Client, job_url: str):
227229 report_url as results_link,
228230 task_url
229231 FROM `gh-data`.checks
232+ WHERE commit_sha='{ commit_sha } ' AND head_ref='{ branch_name } '
230233 GROUP BY check_name, test_name, report_url, task_url
231234 )
232- WHERE task_url LIKE '{ job_url } %'
233- AND job_status=='error'
235+ WHERE job_status=='error'
234236 ORDER BY job_name, test_name
235237 """
236238 return client .query_dataframe (query )
@@ -431,7 +433,7 @@ def get_cves(pr_number, commit_sha):
431433def url_to_html_link (url : str ) -> str :
432434 if not url :
433435 return ""
434- text = url .split ("/" )[- 1 ].replace ( "__" , "_" )
436+ text = url .split ("/" )[- 1 ].split ( "?" )[ 0 ]
435437 if not text :
436438 text = "results"
437439 return f'<a href="{ url } ">{ text } </a>'
@@ -447,7 +449,7 @@ def format_test_status(text: str) -> str:
447449 color = (
448450 "red"
449451 if text .lower ().startswith ("fail" )
450- else "orange" if text .lower () in ("error" , "broken" ) else "green"
452+ else "orange" if text .lower () in ("error" , "broken" , "pending" ) else "green"
451453 )
452454 return f'<span style="font-weight: bold; color: { color } ">{ text } </span>'
453455
@@ -523,12 +525,15 @@ def main():
523525 settings = {"use_numpy" : True },
524526 )
525527
528+ run_details = get_run_details (args .actions_run_url )
529+ branch_name = run_details .get ("head_branch" , "unknown branch" )
530+
526531 fail_results = {
527532 "job_statuses" : get_commit_statuses (args .commit_sha ),
528- "checks_fails" : get_checks_fails (db_client , args .actions_run_url ),
533+ "checks_fails" : get_checks_fails (db_client , args .commit_sha , branch_name ),
529534 "checks_known_fails" : [],
530535 "pr_new_fails" : [],
531- "checks_errors" : get_checks_errors (db_client , args .actions_run_url ),
536+ "checks_errors" : get_checks_errors (db_client , args .commit_sha , branch_name ),
532537 "regression_fails" : get_regression_fails (db_client , args .actions_run_url ),
533538 "docker_images_cves" : (
534539 [] if not args .cves else get_cves (args .pr_number , args .commit_sha )
@@ -549,12 +554,10 @@ def main():
549554
550555 if known_fails :
551556 fail_results ["checks_known_fails" ] = get_checks_known_fails (
552- db_client , args .actions_run_url , known_fails
557+ db_client , args .commit_sha , branch_name , known_fails
553558 )
554559
555560 if args .pr_number == 0 :
556- run_details = get_run_details (args .actions_run_url )
557- branch_name = run_details .get ("head_branch" , "unknown branch" )
558561 pr_info_html = f"Release ({ branch_name } )"
559562 else :
560563 try :
0 commit comments