Skip to content
2 changes: 1 addition & 1 deletion infra/build/functions/build_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def get_runner_image_name(test_image_suffix, base_image_tag=None):
# Only add a tag if it's specified and not 'legacy', as 'legacy' implies
# 'latest', which is the default behavior.
if base_image_tag and base_image_tag != 'legacy':
image += ':' + base_image_tag
image += f":{base_image_tag}"

return image

Expand Down
17 changes: 12 additions & 5 deletions infra/build/functions/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def __init__(self, name, project_yaml, dockerfile):
self.labels = project_yaml['labels']
self.fuzzing_language = project_yaml['language']
self.run_tests = project_yaml['run_tests']
self.base_os_version = project_yaml.get('base_os_version', 'legacy')
if 'main_repo' in project_yaml:
self.main_repo = project_yaml['main_repo']
else:
Expand Down Expand Up @@ -488,7 +489,8 @@ def get_build_steps_for_project(project,
# Generate targets list.
{
'name':
build_lib.get_runner_image_name(config.test_image_suffix),
build_lib.get_runner_image_name(config.test_image_suffix,
config.base_image_tag),
'env':
env,
'args': [
Expand Down Expand Up @@ -828,11 +830,12 @@ def parse_args(description, args):
return parser.parse_args(args)


def create_config(args, build_type):
def create_config(args, build_type, base_image_tag=None):
"""Create a Config object from parsed command line |args|."""
upload = not args.experiment
return Config(testing=args.testing,
test_image_suffix=args.test_image_suffix,
base_image_tag=base_image_tag,
branch=args.branch,
parallel=args.parallel,
upload=upload,
Expand All @@ -855,7 +858,6 @@ def build_script_main(script_description,

credentials = oauth2client.client.GoogleCredentials.get_application_default()
error = False
config = create_config(args, build_type)
for project_name in args.projects:
try:
project_yaml, dockerfile_contents = get_project_data(project_name)
Expand All @@ -864,8 +866,13 @@ def build_script_main(script_description,
error = True
continue

steps = get_build_steps_func(project_name, project_yaml,
dockerfile_contents, config)
base_image_tag = project_yaml.get('base_os_version', 'legacy')
if base_image_tag == 'legacy':
base_image_tag = None
config = create_config(args, build_type, base_image_tag=base_image_tag)

steps, _ = get_build_steps_func(project_name, project_yaml,
dockerfile_contents, config)
if not steps:
logging.error('No steps. Skipping %s.', project_name)
error = True
Expand Down
39 changes: 39 additions & 0 deletions infra/build/functions/build_project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,45 @@ def test_get_centipede_build_steps(self, mock_url, mock_get_datetime_now,
config)
self.assertEqual(build_steps, expected_build_steps)

@mock.patch('build_lib.get_signed_url', return_value='test_url')
@mock.patch('build_project.get_datetime_now',
return_value=test_utils.FAKE_DATETIME)
@mock.patch('build_lib.get_unique_build_step_image_id',
return_value='UNIQUE_ID')
def test_get_build_steps_ubuntu_24_04(self, mock_url, mock_get_datetime_now,
mock_get_id):
"""Test for get_build_steps with ubuntu-24-04."""
del mock_url, mock_get_datetime_now
project_yaml_contents = (
'language: c++\n'
'base_os_version: ubuntu-24-04\n'
'sanitizers:\n'
' - address\n'
' - memory\n'
' - undefined\n'
'architectures:\n'
' - x86_64\n'
' - i386\n'
' - aarch64\n'
'main_repo: https://github.com/google/oss-fuzz.git\n')
self.fs.create_dir(test_utils.PROJECT_DIR)
test_utils.create_project_data(test_utils.PROJECT, project_yaml_contents)

expected_build_steps_file_path = test_utils.get_test_data_file_path(
'expected_build_steps_ubuntu_24_04.json')
self.fs.add_real_file(expected_build_steps_file_path)
with open(expected_build_steps_file_path) as expected_build_steps_file:
expected_build_steps = json.load(expected_build_steps_file)

config = build_project.Config(upload=True)
project_yaml, dockerfile = build_project.get_project_data(
test_utils.PROJECT)
config.base_image_tag = project_yaml.get('base_os_version')
build_steps, _ = build_project.get_build_steps(test_utils.PROJECT,
project_yaml, dockerfile,
config)
self.assertEqual(build_steps, expected_build_steps)


if __name__ == '__main__':
unittest.main(exit=False)
Loading
Loading