14
14
comparison_artifact_file_name = "comparison.md"
15
15
16
16
17
+ comment_first_line = ":warning: The head of this PR and the base branch were compared for differences in the framework coverage reports. "
18
+
19
+
17
20
def get_comment_text (output_file , repo , run_id ):
18
21
size = os .path .getsize (output_file )
19
22
if size == 0 :
20
23
print ("No difference in the coverage reports" )
21
24
return
22
25
23
- comment = ":warning: The head of this PR and the base branch were compared for differences in the framework coverage reports. " + \
26
+ comment = comment_first_line + \
24
27
f"The generated reports are available in the [artifacts of this workflow run](https://github.com/{ repo } /actions/runs/{ run_id } ). " + \
25
28
"The differences will be picked up by the nightly job after the PR gets merged. "
26
29
@@ -57,6 +60,7 @@ def comment_pr(repo, run_id):
57
60
shutil .rmtree ("pr" )
58
61
59
62
# Try storing diff for previous run:
63
+ prev_run_id = 0
60
64
try :
61
65
prev_run_id = get_previous_run_id (repo , run_id , pr_number )
62
66
prev_diff_folder = "prev_diff"
@@ -75,6 +79,14 @@ def comment_pr(repo, run_id):
75
79
76
80
comment = get_comment_text (
77
81
f"{ current_diff_folder } /{ comparison_artifact_file_name } " , repo , run_id )
82
+
83
+ if comment == None :
84
+ if prev_run_id == 0 :
85
+ print ("Nothing to comment." )
86
+ return
87
+ print ("Previous run found, and current run removes coverage change." )
88
+ comment = comment_first_line + \
89
+ "A recent commit removed the previously reported differences."
78
90
post_comment (comment , repo , pr_number )
79
91
80
92
@@ -119,7 +131,7 @@ def get_previous_run_id(repo, run_id, pr_number):
119
131
120
132
# the previous run needs to be coming from the same PR:
121
133
if pr_number == prev_pr_number :
122
- return previous_run_id
134
+ return int ( previous_run_id )
123
135
124
136
raise Exception ("Couldn't find previous run." )
125
137
0 commit comments