Skip to content

Commit cd02525

Browse files
committed
refactor(build): Improve logging and return reasons for skipped projects in build steps
1 parent b30fce7 commit cd02525

File tree

5 files changed

+74
-68
lines changed

5 files changed

+74
-68
lines changed

infra/build/functions/build_and_run_coverage.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,11 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-arguments
8686
"""Returns build steps for project."""
8787
project = build_project.Project(project_name, project_yaml, dockerfile_lines)
8888
if project.disabled:
89-
logging.info('Project "%s" is disabled.', project.name)
90-
return []
89+
return [], f'Project "{project.name}" is disabled.'
9190

9291
if project.fuzzing_language not in LANGUAGES_WITH_COVERAGE_SUPPORT:
93-
logging.info(
94-
'Project "%s" is written in "%s", coverage is not supported yet.',
95-
project.name, project.fuzzing_language)
96-
return []
92+
return [], (f'Project "{project.name}" is written in '
93+
f'"{project.fuzzing_language}", coverage is not supported yet.')
9794

9895
report_date = build_project.get_datetime_now().strftime('%Y%m%d')
9996
bucket = CoverageBucket(project.name, report_date, PLATFORM, config.testing)
@@ -107,11 +104,10 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-arguments
107104
env = build_project.get_env(project.fuzzing_language, build)
108105
build_steps.append(
109106
build_project.get_compile_step(project, build, env, config.parallel))
110-
download_corpora_steps = build_lib.download_corpora_steps(
107+
download_corpora_steps, reason = build_lib.download_corpora_steps(
111108
project.name, test_image_suffix=config.test_image_suffix)
112109
if not download_corpora_steps:
113-
logging.info('Skipping code coverage build for %s.', project.name)
114-
return []
110+
return [], reason
115111

116112
build_steps.extend(download_corpora_steps)
117113

@@ -262,10 +258,9 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-arguments
262258

263259
build_steps.append(
264260
build_lib.http_upload_step(latest_report_info_body,
265-
latest_report_info_url,
261+
latest_report_info_url,
266262
LATEST_REPORT_INFO_CONTENT_TYPE))
267-
268-
return build_steps
263+
return build_steps, None
269264

270265

271266
def get_fuzz_introspector_steps( # pylint: disable=too-many-locals, too-many-arguments, unused-argument
@@ -274,14 +269,12 @@ def get_fuzz_introspector_steps( # pylint: disable=too-many-locals, too-many-ar
274269

275270
project = build_project.Project(project_name, project_yaml, dockerfile_lines)
276271
if project.disabled:
277-
logging.info('Project "%s" is disabled.', project.name)
278-
return []
272+
return [], f'Project "{project.name}" is disabled.'
279273

280274
if project.fuzzing_language not in LANGUAGES_WITH_INTROSPECTOR_SUPPORT:
281-
logging.info(('Project "%s" is written in "%s", '
282-
'Fuzz Introspector is not supported yet.'), project.name,
283-
project.fuzzing_language)
284-
return []
275+
return [], (f'Project "{project.name}" is written in '
276+
f'"{project.fuzzing_language}", Fuzz Introspector is not '
277+
'supported yet.')
285278

286279
build_steps = []
287280
build = build_project.Build(FUZZING_ENGINE, 'introspector', ARCHITECTURE)
@@ -300,10 +293,7 @@ def get_fuzz_introspector_steps( # pylint: disable=too-many-locals, too-many-ar
300293
download_coverage_steps = build_lib.download_coverage_data_steps(
301294
project.name, coverage_report_latest, bucket_name, build.out)
302295
if not download_coverage_steps:
303-
logging.warning(
304-
'Skipping introspector build for %s. No coverage data found.',
305-
project.name)
306-
return []
296+
return [], f'Skipping introspector build for {project.name}. No coverage data found.'
307297
build_steps.extend(download_coverage_steps)
308298
build_steps.extend(
309299
build_lib.get_project_image_steps(project.name,
@@ -339,8 +329,7 @@ def get_fuzz_introspector_steps( # pylint: disable=too-many-locals, too-many-ar
339329
upload_report_url,
340330
],
341331
})
342-
343-
return build_steps
332+
return build_steps, None
344333

345334

346335
def main():

infra/build/functions/build_lib.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ def download_corpora_steps(project_name, test_image_suffix):
314314
"""
315315
fuzz_targets = _get_targets_list(project_name)
316316
if not fuzz_targets:
317-
sys.stderr.write('No fuzz targets found for project "%s".\n' % project_name)
318-
return None
317+
return None, f'No fuzz targets found for project "{project_name}".'
319318

320319
steps = []
321320
# Split fuzz targets into batches of CORPUS_DOWNLOAD_BATCH_SIZE.
@@ -347,7 +346,7 @@ def download_corpora_steps(project_name, test_image_suffix):
347346
}],
348347
})
349348

350-
return steps
349+
return steps, None
351350

352351

353352
def download_coverage_data_steps(project_name, latest, bucket_name, out_dir):

infra/build/functions/build_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-statements, to
361361
config,
362362
additional_env=additional_env,
363363
use_caching=use_caching,
364-
timestamp=timestamp)
364+
timestamp=timestamp), None
365365

366366

367367
def get_build_steps_for_project(project,

infra/build/functions/test_data/expected_trial_build_steps.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,143 +14,143 @@
1414
"name": "gcr.io/cloud-builders/docker",
1515
"args": [
1616
"pull",
17-
"gcr.io/oss-fuzz-base/base-builder-testing-mybranch"
17+
"gcr.io/oss-fuzz-base/base-builder-testing-legacy-mybranch"
1818
],
1919
"waitFor": "-"
2020
},
2121
{
2222
"name": "gcr.io/cloud-builders/docker",
2323
"args": [
2424
"tag",
25-
"gcr.io/oss-fuzz-base/base-builder-testing-mybranch",
25+
"gcr.io/oss-fuzz-base/base-builder-testing-legacy-mybranch",
2626
"gcr.io/oss-fuzz-base/base-builder"
2727
]
2828
},
2929
{
3030
"name": "gcr.io/cloud-builders/docker",
3131
"args": [
3232
"pull",
33-
"gcr.io/oss-fuzz-base/base-builder-swift-testing-mybranch"
33+
"gcr.io/oss-fuzz-base/base-builder-swift-testing-legacy-mybranch"
3434
],
3535
"waitFor": "-"
3636
},
3737
{
3838
"name": "gcr.io/cloud-builders/docker",
3939
"args": [
4040
"tag",
41-
"gcr.io/oss-fuzz-base/base-builder-swift-testing-mybranch",
41+
"gcr.io/oss-fuzz-base/base-builder-swift-testing-legacy-mybranch",
4242
"gcr.io/oss-fuzz-base/base-builder-swift"
4343
]
4444
},
4545
{
4646
"name": "gcr.io/cloud-builders/docker",
4747
"args": [
4848
"pull",
49-
"gcr.io/oss-fuzz-base/base-builder-javascript-testing-mybranch"
49+
"gcr.io/oss-fuzz-base/base-builder-javascript-testing-legacy-mybranch"
5050
],
5151
"waitFor": "-"
5252
},
5353
{
5454
"name": "gcr.io/cloud-builders/docker",
5555
"args": [
5656
"tag",
57-
"gcr.io/oss-fuzz-base/base-builder-javascript-testing-mybranch",
57+
"gcr.io/oss-fuzz-base/base-builder-javascript-testing-legacy-mybranch",
5858
"gcr.io/oss-fuzz-base/base-builder-javascript"
5959
]
6060
},
6161
{
6262
"name": "gcr.io/cloud-builders/docker",
6363
"args": [
6464
"pull",
65-
"gcr.io/oss-fuzz-base/base-builder-jvm-testing-mybranch"
65+
"gcr.io/oss-fuzz-base/base-builder-jvm-testing-legacy-mybranch"
6666
],
6767
"waitFor": "-"
6868
},
6969
{
7070
"name": "gcr.io/cloud-builders/docker",
7171
"args": [
7272
"tag",
73-
"gcr.io/oss-fuzz-base/base-builder-jvm-testing-mybranch",
73+
"gcr.io/oss-fuzz-base/base-builder-jvm-testing-legacy-mybranch",
7474
"gcr.io/oss-fuzz-base/base-builder-jvm"
7575
]
7676
},
7777
{
7878
"name": "gcr.io/cloud-builders/docker",
7979
"args": [
8080
"pull",
81-
"gcr.io/oss-fuzz-base/base-builder-go-testing-mybranch"
81+
"gcr.io/oss-fuzz-base/base-builder-go-testing-legacy-mybranch"
8282
],
8383
"waitFor": "-"
8484
},
8585
{
8686
"name": "gcr.io/cloud-builders/docker",
8787
"args": [
8888
"tag",
89-
"gcr.io/oss-fuzz-base/base-builder-go-testing-mybranch",
89+
"gcr.io/oss-fuzz-base/base-builder-go-testing-legacy-mybranch",
9090
"gcr.io/oss-fuzz-base/base-builder-go"
9191
]
9292
},
9393
{
9494
"name": "gcr.io/cloud-builders/docker",
9595
"args": [
9696
"pull",
97-
"gcr.io/oss-fuzz-base/base-builder-python-testing-mybranch"
97+
"gcr.io/oss-fuzz-base/base-builder-python-testing-legacy-mybranch"
9898
],
9999
"waitFor": "-"
100100
},
101101
{
102102
"name": "gcr.io/cloud-builders/docker",
103103
"args": [
104104
"tag",
105-
"gcr.io/oss-fuzz-base/base-builder-python-testing-mybranch",
105+
"gcr.io/oss-fuzz-base/base-builder-python-testing-legacy-mybranch",
106106
"gcr.io/oss-fuzz-base/base-builder-python"
107107
]
108108
},
109109
{
110110
"name": "gcr.io/cloud-builders/docker",
111111
"args": [
112112
"pull",
113-
"gcr.io/oss-fuzz-base/base-builder-ruby-testing-mybranch"
113+
"gcr.io/oss-fuzz-base/base-builder-ruby-testing-legacy-mybranch"
114114
],
115115
"waitFor": "-"
116116
},
117117
{
118118
"name": "gcr.io/cloud-builders/docker",
119119
"args": [
120120
"tag",
121-
"gcr.io/oss-fuzz-base/base-builder-ruby-testing-mybranch",
121+
"gcr.io/oss-fuzz-base/base-builder-ruby-testing-legacy-mybranch",
122122
"gcr.io/oss-fuzz-base/base-builder-ruby"
123123
]
124124
},
125125
{
126126
"name": "gcr.io/cloud-builders/docker",
127127
"args": [
128128
"pull",
129-
"gcr.io/oss-fuzz-base/base-builder-rust-testing-mybranch"
129+
"gcr.io/oss-fuzz-base/base-builder-rust-testing-legacy-mybranch"
130130
],
131131
"waitFor": "-"
132132
},
133133
{
134134
"name": "gcr.io/cloud-builders/docker",
135135
"args": [
136136
"tag",
137-
"gcr.io/oss-fuzz-base/base-builder-rust-testing-mybranch",
137+
"gcr.io/oss-fuzz-base/base-builder-rust-testing-legacy-mybranch",
138138
"gcr.io/oss-fuzz-base/base-builder-rust"
139139
]
140140
},
141141
{
142142
"name": "gcr.io/cloud-builders/docker",
143143
"args": [
144144
"pull",
145-
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch"
145+
"gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch"
146146
],
147147
"waitFor": "-"
148148
},
149149
{
150150
"name": "gcr.io/cloud-builders/docker",
151151
"args": [
152152
"tag",
153-
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
153+
"gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
154154
"gcr.io/oss-fuzz-base/base-runner"
155155
]
156156
},
@@ -248,15 +248,15 @@
248248
"-e",
249249
"SANITIZER=address",
250250
"-t",
251-
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
251+
"gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
252252
"bash",
253253
"-c",
254254
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 skcms\\npython infra/helper.py check_build --sanitizer address --engine afl --architecture x86_64 skcms\\n********************************************************************************\" && false)"
255255
],
256256
"id": "build-check-afl-address-x86_64"
257257
},
258258
{
259-
"name": "gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
259+
"name": "gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
260260
"env": [
261261
"ARCHITECTURE=x86_64",
262262
"FUZZING_ENGINE=afl",
@@ -340,15 +340,15 @@
340340
"-e",
341341
"SANITIZER=address",
342342
"-t",
343-
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
343+
"gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
344344
"bash",
345345
"-c",
346346
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 skcms\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture x86_64 skcms\\n********************************************************************************\" && false)"
347347
],
348348
"id": "build-check-libfuzzer-address-x86_64"
349349
},
350350
{
351-
"name": "gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
351+
"name": "gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
352352
"env": [
353353
"ARCHITECTURE=x86_64",
354354
"FUZZING_ENGINE=libfuzzer",
@@ -432,15 +432,15 @@
432432
"-e",
433433
"SANITIZER=address",
434434
"-t",
435-
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
435+
"gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
436436
"bash",
437437
"-c",
438438
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 skcms\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture i386 skcms\\n********************************************************************************\" && false)"
439439
],
440440
"id": "build-check-libfuzzer-address-i386"
441441
},
442442
{
443-
"name": "gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
443+
"name": "gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
444444
"env": [
445445
"ARCHITECTURE=i386",
446446
"FUZZING_ENGINE=libfuzzer",
@@ -524,15 +524,15 @@
524524
"-e",
525525
"SANITIZER=undefined",
526526
"-t",
527-
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
527+
"gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
528528
"bash",
529529
"-c",
530530
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\\npython infra/helper.py check_build --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\\n********************************************************************************\" && false)"
531531
],
532532
"id": "build-check-libfuzzer-undefined-x86_64"
533533
},
534534
{
535-
"name": "gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
535+
"name": "gcr.io/oss-fuzz-base/base-runner-testing-legacy-mybranch",
536536
"env": [
537537
"ARCHITECTURE=x86_64",
538538
"FUZZING_ENGINE=libfuzzer",

0 commit comments

Comments
 (0)