1010import time
1111import urllib .request
1212
13- from utils import CI_ROOT , get_build , get_image_name , get_requested_llvm_version , print_red , print_yellow , get_cbl_name , show_builds
13+ from utils import CI_ROOT , get_build , get_image_name , get_requested_llvm_version , print_red , get_cbl_name , show_builds , die , warn , info
1414
1515
1616def _fetch (title , url , dest ):
1717 current_time = time .strftime ("%H:%M:%S" , time .localtime ())
18- print_yellow (f"{ current_time } : fetching { title } from: { url } " )
18+ info (f"{ current_time } : fetching { title } from: { url } " )
1919 retries = 0
2020 max_retries = 7
2121 retry_codes = [404 , 500 , 504 ]
@@ -27,26 +27,22 @@ def _fetch(title, url, dest):
2727 urllib .request .urlretrieve (url , dest )
2828 break
2929 except ConnectionResetError as err :
30- print_yellow (f"{ title } download error ('{ err } '), retrying..." )
30+ warn (f"{ title } download error ('{ err } '), retrying..." )
3131 except urllib .error .HTTPError as err :
3232 if err .code in retry_codes :
33- print_yellow (
34- f"{ title } download error ({ err .code } ), retrying..." )
33+ warn (f"{ title } download error ({ err .code } ), retrying..." )
3534 else :
36- print_red (f"{ err .code } error trying to download { title } " )
37- sys .exit (1 )
35+ die (f"{ err .code } error trying to download { title } " )
3836 except urllib .error .URLError as err :
39- print_yellow (f"{ title } download error ('{ err } '), retrying..." )
37+ warn (f"{ title } download error ('{ err } '), retrying..." )
4038
4139 if retries == max_retries :
42- print_red (f"Unable to download { title } after { max_retries } tries" )
43- sys .exit (1 )
40+ die (f"Unable to download { title } after { max_retries } tries" )
4441
4542 if dest .exists ():
46- print_yellow (f"Filesize: { dest .stat ().st_size } " )
43+ info (f"Filesize: { dest .stat ().st_size } " )
4744 else :
48- print_red (f"Unable to download { title } " )
49- sys .exit (1 )
45+ die (f"Unable to download { title } " )
5046
5147
5248def verify_build ():
@@ -60,8 +56,7 @@ def verify_build():
6056 while retries < max_retries :
6157 # build never started
6258 if (build_status := build ['tuxbuild_status' ]) == 'error' :
63- print_red (f"msg from tuxsuite: { build ['status_message' ]} " )
64- sys .exit (1 )
59+ die (f"msg from tuxsuite: { build ['status_message' ]} " )
6560 # build is finished
6661 elif build_status == "complete" :
6762 break
@@ -78,16 +73,14 @@ def verify_build():
7873 print (json .dumps (build , indent = 4 ))
7974
8075 if retries == max_retries :
81- print_red ("Build is not finished on TuxSuite's side!" )
82- sys .exit (1 )
76+ die ("Build is not finished on TuxSuite's side!" )
8377
8478 if "Build Timed Out" in build ["status_message" ]:
85- print_red (build ["status_message" ])
86- sys .exit (1 )
79+ die (build ["status_message" ])
8780
8881 if build ["status_message" ] == "Unable to apply kernel patch" :
8982 print_red (
90- "Patch failed to apply to current kernel tree, does it need to be removed or updated?"
83+ "ERROR: Patch failed to apply to current kernel tree, does it need to be removed or updated?"
9184 )
9285 fetch_logs (build )
9386 sys .exit (1 )
@@ -106,7 +99,7 @@ def check_log(build):
10699 warnings_count = build ["warnings_count" ]
107100 errors_count = build ["errors_count" ]
108101 if warnings_count + errors_count > 0 :
109- print_yellow (f"{ warnings_count } warnings, { errors_count } errors" )
102+ info (f"{ warnings_count } warnings, { errors_count } errors" )
110103 fetch_logs (build )
111104
112105
@@ -159,12 +152,12 @@ def check_built_config(build):
159152 elif line .startswith ("# CONFIG_" ):
160153 name , state = line .split (" " , 2 )[1 :]
161154 if state != "is not set" :
162- print_yellow (
155+ warn (
163156 f"Could not parse '{ name } ' from .config line '{ line } '!?"
164157 )
165158 state = 'n'
166159 elif not line .startswith ("#" ):
167- print_yellow (f"Could not parse .config line '{ line } '!?" )
160+ warn (f"Could not parse .config line '{ line } '!?" )
168161 configs [name ] = state
169162
170163 # Compare requested configs against the loaded dictionary.
@@ -175,7 +168,7 @@ def check_built_config(build):
175168 name , state = config .split ('=' )
176169 # If a config is missing from the dictionary, it is considered 'n'.
177170 if state != configs .get (name , 'n' ):
178- print_red (f"FAIL : { config } not found in .config!" )
171+ print_red (f"ERROR : { config } not found in .config!" )
179172 fail = True
180173 else :
181174 print (f"ok: { name } ={ state } " )
@@ -195,7 +188,7 @@ def print_clang_info(build):
195188 url = build ["download_url" ] + metadata_file .name
196189 _fetch (metadata_file , url , metadata_file )
197190 metadata_json = json .loads (metadata_file .read_text (encoding = 'utf-8' ))
198- print_yellow ("Printing clang-nightly checkout date and hash" )
191+ info ("Printing clang-nightly checkout date and hash" )
199192 parse_cmd = [
200193 Path (CI_ROOT , "scripts/parse-debian-clang.py" ), "--print-info" ,
201194 "--version-string" , metadata_json ["compiler" ]["version_full" ]
@@ -243,8 +236,7 @@ def run_boot(build):
243236 boot_cmd += ["-t" , "10m" ]
244237 if "CONFIG_KASAN_KUNIT_TEST=y" in build ["kconfig" ] or \
245238 "CONFIG_KCSAN_KUNIT_TEST=y" in build ["kconfig" ]:
246- print_yellow (
247- "Disabling Oops problem matcher under Sanitizer KUnit build" )
239+ info ("Disabling Oops problem matcher under Sanitizer KUnit build" )
248240 print ("::remove-matcher owner=linux-kernel-oopses::" )
249241
250242 # Before spawning a process with potentially different IO buffering,
@@ -256,19 +248,17 @@ def run_boot(build):
256248 subprocess .run (boot_cmd , check = True )
257249 except subprocess .CalledProcessError as err :
258250 if err .returncode == 124 :
259- print_red ("Image failed to boot" )
251+ print_red ("ERROR: Image failed to boot" )
260252 raise err
261253
262254
263255def boot_test (build ):
264256 if build ["result" ] == "unknown" :
265- print_red ("unknown build result, skipping boot" )
266- sys .exit (1 )
257+ die ("unknown build result, skipping boot" )
267258 if build ["result" ] == "fail" :
268- print_red ("fatal build errors encountered during build, skipping boot" )
269- sys .exit (1 )
259+ die ("fatal build errors encountered during build, skipping boot" )
270260 if "BOOT" in os .environ and os .environ ["BOOT" ] == "0" :
271- print_yellow ("boot test disabled via config, skipping boot" )
261+ info ("boot test disabled via config, skipping boot" )
272262 return
273263 fetch_kernel_image (build )
274264 fetch_dtb (build )
@@ -282,11 +272,11 @@ def boot_test(build):
282272 missing .append (var )
283273 if missing :
284274 for var in missing :
285- print_red (f"${ var } must be specified" )
275+ print_red (f"ERROR: ${ var } must be specified" )
286276 show_builds ()
287277 sys .exit (1 )
288278 verified_build = verify_build ()
289- print_yellow ("Register clang error/warning problem matchers" )
279+ info ("Register clang error/warning problem matchers" )
290280 for problem_matcher in glob .glob (".github/problem-matchers/*.json" ):
291281 print (f"::add-matcher::{ problem_matcher } " )
292282 print_clang_info (verified_build )
0 commit comments