22# The test scenario is randomly selected.
33# The inputs are printed to stdout in GitHub step output key=value format.
44
5+ import argparse
56from dataclasses import dataclass
67import random
78import typing as t
@@ -43,6 +44,16 @@ class Scenario:
4344
4445
4546def main () -> None :
47+
48+ parser = argparse .ArgumentParser (
49+ description = 'Randomly picks a multinode scenario to execute' )
50+ parser .add_argument (
51+ '--output-summary' , '-s' ,
52+ type = argparse .FileType ('w' , encoding = 'UTF-8' ),
53+ default = None ,
54+ help = "Generate a markdown table with selected inputs, can be '-' for stdout" )
55+ args = parser .parse_args ()
56+
4657 scenario = random_scenario ()
4758 inputs = {
4859 "os_distribution" : scenario .os_release .distribution ,
@@ -57,6 +68,8 @@ def main() -> None:
5768 }
5869 for name , value in inputs .items ():
5970 write_output (name , value )
71+ if args .output_summary :
72+ write_summary (inputs , args .output_summary )
6073
6174
6275def random_scenario () -> Scenario :
@@ -84,5 +97,13 @@ def write_output(name: str, value: str) -> None:
8497 print (f"{ name } ={ value } " )
8598
8699
100+ def write_summary (inputs : dict , output : t .TextIO ):
101+ print (
102+ '| Input | Value |\n '
103+ '| -----: | :---- |' , file = output )
104+ for key , value in inputs .items ():
105+ print (f'| **{ key } ** | `{ value } ` |' , file = output )
106+
107+
87108if __name__ == "__main__" :
88109 main ()
0 commit comments