@@ -172,6 +172,7 @@ def compare_command_logic(args, project_name, project_version):
172
172
logging .info ("Detected slack webhook token" )
173
173
webhook_client_slack = WebhookClient (webhook_url )
174
174
175
+ old_regression_comment_body = ""
175
176
if github_token is not None :
176
177
logging .info ("Detected github token" )
177
178
g = Github (github_token )
@@ -189,12 +190,17 @@ def compare_command_logic(args, project_name, project_version):
189
190
contains_regression_comment , pos = check_regression_comment (comments )
190
191
if contains_regression_comment :
191
192
regression_comment = comments [pos ]
193
+ old_regression_comment_body = regression_comment .body
192
194
logging .info (
193
195
"Already contains regression comment. Link: {}" .format (
194
196
regression_comment .html_url
195
197
)
196
198
)
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 )]))
198
204
else :
199
205
logging .info ("Does not contain regression comment" )
200
206
@@ -312,39 +318,62 @@ def compare_command_logic(args, project_name, project_version):
312
318
)
313
319
314
320
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
318
327
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..."
323
330
)
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 "
332
334
)
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
+ )
336
352
)
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
+ )
347
361
)
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
+ )
348
377
349
378
else :
350
379
if auto_approve :
@@ -512,11 +541,10 @@ def compute_regression_table(
512
541
)
513
542
)
514
543
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 (
516
545
baseline_str ,
517
546
comparison_str ,
518
547
from_human_str ,
519
- to_human_str ,
520
548
baseline_deployment_name ,
521
549
),
522
550
headers = [
0 commit comments