@@ -356,9 +356,8 @@ def to_hist(
356356 )
357357 parser_avg .add_argument (
358358 "--produce-github-summary" ,
359- type = str ,
360- help = "Create a github CI summary file using the provided filename" ,
361- default = "" ,
359+ action = "store_true" ,
360+ help = f"Create a summary file '{ options .github_summary_filename } ' for Github workflow summaries." ,
362361 )
363362
364363 args = parser .parse_args ()
@@ -377,18 +376,14 @@ def to_hist(
377376 args .avg_type , args .name , args .compare_file , args .results_dir , args .cutoff
378377 )
379378
380- # Initialize github summary variables:
379+ # Initialize Github summary variables:
381380 if args .produce_github_summary :
382381 gh_summary = []
383382
384383 filter_type_capitalized = (
385384 args .regression_filter_type [0 ].upper () + args .regression_filter_type [1 :]
386385 )
387386
388- def write_summary_to_file (summary : list [str ]):
389- with open (args .produce_github_summary , "w" ) as f :
390- f .write ("\n " .join (summary ))
391-
392387 # Not all regressions are of concern: if a filter is provided, filter
393388 # regressions using filter
394389 regressions_ignored = []
@@ -402,7 +397,7 @@ def write_summary_to_file(summary: list[str]):
402397 regressions_ignored .append (test )
403398
404399 def print_regression (entry : dict , is_warning : bool = False ):
405- """Print an entry outputted from Compare.to_hist[github_summary.md" )
400+ """Print an entry outputted from Compare.to_hist( )
406401
407402 Args:
408403 entry (dict): The entry to print
@@ -421,6 +416,12 @@ def print_regression(entry: dict, is_warning: bool = False):
421416 )
422417 gh_summary .append (f"- Run result: { entry ['value' ]} " )
423418 gh_summary .append (
419+ # Since we are dealing with floats, our deltas have a lot
420+ # of decimal places. For easier readability, we round our
421+ # deltas and format our Github summary output as:
422+ #
423+ # Delta: <rounded number>% (<full number>)
424+ #
424425 f"- Delta: { round (entry ['delta' ]* 100 , 2 )} % ({ entry ['delta' ]} )"
425426 )
426427 gh_summary .append ("" )
@@ -472,13 +473,15 @@ def print_regression(entry: dict, is_warning: bool = False):
472473
473474 if not args .dry_run :
474475 if args .produce_github_summary :
475- write_summary_to_file (gh_summary )
476- exit (1 ) # Exit 1 to trigger github test failure
476+ with open (options .github_summary_filename , "w" ) as f :
477+ f .write ("\n " .join (summary ))
478+ exit (1 ) # Exit 1 to trigger Github test failure
477479
478480 log .info ("No unexpected regressions found!" )
479481 if args .produce_github_summary :
480482 gh_summary .append ("No unexpected regressions found!" )
481- write_summary_to_file (gh_summary )
483+ with open (options .github_summary_filename , "w" ) as f :
484+ f .write ("\n " .join (summary ))
482485
483486 else :
484487 log .error ("Unsupported operation: exiting." )
0 commit comments