@@ -119,7 +119,6 @@ def get_pr_info_from_number(pr_number: str) -> dict:
119119 return response .json ()
120120
121121
122- @lru_cache
123122def get_run_details (run_url : str ) -> dict :
124123 """
125124 Fetch run details for a given run URL.
@@ -659,15 +658,6 @@ def create_workflow_report(
659658 check_cves : bool = False ,
660659 mark_preview : bool = False ,
661660) -> str :
662- if pr_number is None or commit_sha is None :
663- run_details = get_run_details (actions_run_url )
664- if pr_number is None :
665- if len (run_details ["pull_requests" ]) > 0 :
666- pr_number = run_details ["pull_requests" ][0 ]["number" ]
667- else :
668- pr_number = 0
669- if commit_sha is None :
670- commit_sha = run_details ["head_commit" ]["id" ]
671661
672662 host = os .getenv (DATABASE_HOST_VAR )
673663 if not host :
@@ -683,6 +673,17 @@ def create_workflow_report(
683673 if not all ([host , user , password , GITHUB_TOKEN ]):
684674 raise Exception ("Required environment variables are not set" )
685675
676+ run_details = get_run_details (actions_run_url )
677+ branch_name = run_details .get ("head_branch" , "unknown branch" )
678+ if pr_number is None or commit_sha is None :
679+ if pr_number is None :
680+ if len (run_details ["pull_requests" ]) > 0 :
681+ pr_number = run_details ["pull_requests" ][0 ]["number" ]
682+ else :
683+ pr_number = 0
684+ if commit_sha is None :
685+ commit_sha = run_details ["head_commit" ]["id" ]
686+
686687 db_client = Client (
687688 host = host ,
688689 user = user ,
@@ -693,9 +694,6 @@ def create_workflow_report(
693694 settings = {"use_numpy" : True },
694695 )
695696
696- run_details = get_run_details (actions_run_url )
697- branch_name = run_details .get ("head_branch" , "unknown branch" )
698-
699697 fail_results = {
700698 "job_statuses" : get_commit_statuses (commit_sha ),
701699 "checks_fails" : get_checks_fails (db_client , commit_sha , branch_name ),
@@ -755,13 +753,10 @@ def create_workflow_report(
755753 .sum ()
756754 )
757755
758- # Set up the Jinja2 environment
759- template_dir = os .path .dirname (__file__ )
760-
761756 # Load the template
762- template = Environment (loader = FileSystemLoader ( template_dir )). get_template (
763- "ci_run_report.html.jinja"
764- )
757+ template = Environment (
758+ loader = FileSystemLoader ( os . path . dirname ( __file__ ))
759+ ). get_template ( "ci_run_report.html.jinja" )
765760
766761 # Define the context for rendering
767762 context = {
0 commit comments