10
10
import time
11
11
import urllib .request
12
12
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
14
14
15
15
16
16
def _fetch (title , url , dest ):
17
17
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 } " )
19
19
retries = 0
20
20
max_retries = 7
21
21
retry_codes = [404 , 500 , 504 ]
@@ -27,26 +27,22 @@ def _fetch(title, url, dest):
27
27
urllib .request .urlretrieve (url , dest )
28
28
break
29
29
except ConnectionResetError as err :
30
- print_yellow (f"{ title } download error ('{ err } '), retrying..." )
30
+ warn (f"{ title } download error ('{ err } '), retrying..." )
31
31
except urllib .error .HTTPError as err :
32
32
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..." )
35
34
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 } " )
38
36
except urllib .error .URLError as err :
39
- print_yellow (f"{ title } download error ('{ err } '), retrying..." )
37
+ warn (f"{ title } download error ('{ err } '), retrying..." )
40
38
41
39
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" )
44
41
45
42
if dest .exists ():
46
- print_yellow (f"Filesize: { dest .stat ().st_size } " )
43
+ info (f"Filesize: { dest .stat ().st_size } " )
47
44
else :
48
- print_red (f"Unable to download { title } " )
49
- sys .exit (1 )
45
+ die (f"Unable to download { title } " )
50
46
51
47
52
48
def verify_build ():
@@ -60,8 +56,7 @@ def verify_build():
60
56
while retries < max_retries :
61
57
# build never started
62
58
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' ]} " )
65
60
# build is finished
66
61
elif build_status == "complete" :
67
62
break
@@ -78,16 +73,14 @@ def verify_build():
78
73
print (json .dumps (build , indent = 4 ))
79
74
80
75
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!" )
83
77
84
78
if "Build Timed Out" in build ["status_message" ]:
85
- print_red (build ["status_message" ])
86
- sys .exit (1 )
79
+ die (build ["status_message" ])
87
80
88
81
if build ["status_message" ] == "Unable to apply kernel patch" :
89
82
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?"
91
84
)
92
85
fetch_logs (build )
93
86
sys .exit (1 )
@@ -106,7 +99,7 @@ def check_log(build):
106
99
warnings_count = build ["warnings_count" ]
107
100
errors_count = build ["errors_count" ]
108
101
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" )
110
103
fetch_logs (build )
111
104
112
105
@@ -159,12 +152,12 @@ def check_built_config(build):
159
152
elif line .startswith ("# CONFIG_" ):
160
153
name , state = line .split (" " , 2 )[1 :]
161
154
if state != "is not set" :
162
- print_yellow (
155
+ warn (
163
156
f"Could not parse '{ name } ' from .config line '{ line } '!?"
164
157
)
165
158
state = 'n'
166
159
elif not line .startswith ("#" ):
167
- print_yellow (f"Could not parse .config line '{ line } '!?" )
160
+ warn (f"Could not parse .config line '{ line } '!?" )
168
161
configs [name ] = state
169
162
170
163
# Compare requested configs against the loaded dictionary.
@@ -175,7 +168,7 @@ def check_built_config(build):
175
168
name , state = config .split ('=' )
176
169
# If a config is missing from the dictionary, it is considered 'n'.
177
170
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!" )
179
172
fail = True
180
173
else :
181
174
print (f"ok: { name } ={ state } " )
@@ -195,7 +188,7 @@ def print_clang_info(build):
195
188
url = build ["download_url" ] + metadata_file .name
196
189
_fetch (metadata_file , url , metadata_file )
197
190
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" )
199
192
parse_cmd = [
200
193
Path (CI_ROOT , "scripts/parse-debian-clang.py" ), "--print-info" ,
201
194
"--version-string" , metadata_json ["compiler" ]["version_full" ]
@@ -243,8 +236,7 @@ def run_boot(build):
243
236
boot_cmd += ["-t" , "10m" ]
244
237
if "CONFIG_KASAN_KUNIT_TEST=y" in build ["kconfig" ] or \
245
238
"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" )
248
240
print ("::remove-matcher owner=linux-kernel-oopses::" )
249
241
250
242
# Before spawning a process with potentially different IO buffering,
@@ -256,19 +248,17 @@ def run_boot(build):
256
248
subprocess .run (boot_cmd , check = True )
257
249
except subprocess .CalledProcessError as err :
258
250
if err .returncode == 124 :
259
- print_red ("Image failed to boot" )
251
+ print_red ("ERROR: Image failed to boot" )
260
252
raise err
261
253
262
254
263
255
def boot_test (build ):
264
256
if build ["result" ] == "unknown" :
265
- print_red ("unknown build result, skipping boot" )
266
- sys .exit (1 )
257
+ die ("unknown build result, skipping boot" )
267
258
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" )
270
260
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" )
272
262
return
273
263
fetch_kernel_image (build )
274
264
fetch_dtb (build )
@@ -282,11 +272,11 @@ def boot_test(build):
282
272
missing .append (var )
283
273
if missing :
284
274
for var in missing :
285
- print_red (f"${ var } must be specified" )
275
+ print_red (f"ERROR: ${ var } must be specified" )
286
276
show_builds ()
287
277
sys .exit (1 )
288
278
verified_build = verify_build ()
289
- print_yellow ("Register clang error/warning problem matchers" )
279
+ info ("Register clang error/warning problem matchers" )
290
280
for problem_matcher in glob .glob (".github/problem-matchers/*.json" ):
291
281
print (f"::add-matcher::{ problem_matcher } " )
292
282
print_clang_info (verified_build )
0 commit comments