@@ -61,30 +61,41 @@ def comment_pr(repo, run_id):
6161
6262 # Try storing diff for previous run:
6363 prev_run_id = 0
64+ prev_diff_exists = False
6465 try :
6566 prev_run_id = get_previous_run_id (repo , run_id , pr_number )
6667 prev_diff_folder = "prev_diff"
6768 utils .download_artifact (repo , comparison_artifact_name ,
6869 prev_diff_folder , prev_run_id )
6970
71+ prev_diff_exists = True
72+
7073 if filecmp .cmp (f"{ current_diff_folder } /{ comparison_artifact_file_name } " , f"{ prev_diff_folder } /{ comparison_artifact_file_name } " , shallow = False ):
7174 print (
7275 f"Previous run { prev_run_id } resulted in the same diff, so not commenting again." )
7376 return
7477 else :
7578 print (f"Diff of previous run { prev_run_id } differs, commenting." )
7679 except Exception :
77- # this is not mecessarily a failure, it can also mean that there was no previous run yet.
80+ # this is not necessarily a failure, it can also mean that there was no previous run yet.
7881 print ("Couldn't generate diff for previous run:" , sys .exc_info ()[1 ])
7982
8083 comment = get_comment_text (
8184 f"{ current_diff_folder } /{ comparison_artifact_file_name } " , repo , run_id )
8285
8386 if comment == None :
8487 if prev_run_id == 0 :
85- print ("Nothing to comment." )
88+ print (
89+ "Nothing to comment. There's no previous run, and there's no coverage change." )
8690 return
91+
8792 print ("Previous run found, and current run removes coverage change." )
93+
94+ if not prev_diff_exists :
95+ print (
96+ "Couldn't get the comparison artifact from previous run. Not commenting." )
97+ return
98+
8899 comment = comment_first_line + \
89100 "A recent commit removed the previously reported differences."
90101 post_comment (comment , repo , pr_number )
0 commit comments