@@ -172,6 +172,7 @@ def compare_command_logic(args, project_name, project_version):
172172 logging .info ("Detected slack webhook token" )
173173 webhook_client_slack = WebhookClient (webhook_url )
174174
175+ old_regression_comment_body = ""
175176 if github_token is not None :
176177 logging .info ("Detected github token" )
177178 g = Github (github_token )
@@ -189,12 +190,17 @@ def compare_command_logic(args, project_name, project_version):
189190 contains_regression_comment , pos = check_regression_comment (comments )
190191 if contains_regression_comment :
191192 regression_comment = comments [pos ]
193+ old_regression_comment_body = regression_comment .body
192194 logging .info (
193195 "Already contains regression comment. Link: {}" .format (
194196 regression_comment .html_url
195197 )
196198 )
197- print (regression_comment )
199+ if verbose :
200+ logging .info ("Printing old regression comment:" )
201+ print ("" .join (["-" for x in range (1 , 80 )]))
202+ print (regression_comment .body )
203+ print ("" .join (["-" for x in range (1 , 80 )]))
198204 else :
199205 logging .info ("Does not contain regression comment" )
200206
@@ -312,39 +318,62 @@ def compare_command_logic(args, project_name, project_version):
312318 )
313319
314320 if contains_regression_comment :
315-
316- if auto_approve :
317- print ("auto approving..." )
321+ same_comment = False
322+ if comment_body == old_regression_comment_body :
323+ logging .info (
324+ "The old regression comment is the same as the new comment. skipping..."
325+ )
326+ same_comment = True
318327 else :
319- user_input = input (
320- "Do you wish to update the comment {} (y/n): " .format (
321- regression_comment .html_url
322- )
328+ logging .info (
329+ "The old regression comment is different from the new comment. updating it..."
323330 )
324- if user_input .lower () == "y" or auto_approve :
325- print ("Updating comment {}" .format (regression_comment .html_url ))
326- regression_comment .edit (comment_body )
327- html_url = regression_comment .html_url
328- print (
329- "Updated comment. Access it via {}" .format (
330- regression_comment .html_url
331- )
331+ comment_body_arr = comment_body .split ("\n " )
332+ old_regression_comment_body_arr = old_regression_comment_body .split (
333+ "\n "
332334 )
333- if webhook_notifications_active :
334- logging .info (
335- "Sending slack notification about updated comment..."
335+ if verbose :
336+ DF = [
337+ x
338+ for x in comment_body_arr
339+ if x not in old_regression_comment_body_arr
340+ ]
341+ print ("---------------------" )
342+ print (DF )
343+ print ("---------------------" )
344+ if same_comment is False :
345+ if auto_approve :
346+ print ("auto approving..." )
347+ else :
348+ user_input = input (
349+ "Do you wish to update the comment {} (y/n): " .format (
350+ regression_comment .html_url
351+ )
336352 )
337- generate_new_pr_comment_notification (
338- webhook_client_slack ,
339- comparison_summary ,
340- html_url ,
341- tf_github_org ,
342- tf_github_repo ,
343- baseline_str ,
344- comparison_str ,
345- regression_count ,
346- "UPDATED" ,
353+ if user_input .lower () == "y" or auto_approve :
354+ print ("Updating comment {}" .format (regression_comment .html_url ))
355+ regression_comment .edit (comment_body )
356+ html_url = regression_comment .html_url
357+ print (
358+ "Updated comment. Access it via {}" .format (
359+ regression_comment .html_url
360+ )
347361 )
362+ if webhook_notifications_active :
363+ logging .info (
364+ "Sending slack notification about updated comment..."
365+ )
366+ generate_new_pr_comment_notification (
367+ webhook_client_slack ,
368+ comparison_summary ,
369+ html_url ,
370+ tf_github_org ,
371+ tf_github_repo ,
372+ baseline_str ,
373+ comparison_str ,
374+ regression_count ,
375+ "UPDATED" ,
376+ )
348377
349378 else :
350379 if auto_approve :
@@ -512,11 +541,10 @@ def compute_regression_table(
512541 )
513542 )
514543 writer = MarkdownTableWriter (
515- table_name = "Comparison between {} and {}.\n \n Time Period from {} to {} . (environment used: {})\n " .format (
544+ table_name = "Comparison between {} and {}.\n \n Time Period from {}. (environment used: {})\n " .format (
516545 baseline_str ,
517546 comparison_str ,
518547 from_human_str ,
519- to_human_str ,
520548 baseline_deployment_name ,
521549 ),
522550 headers = [
0 commit comments