blob: ee195ad0b7afb549ce4417e848b1950786990e34 [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Recipe for uploading build and test outputs."""
DEPS = [
'fuchsia/testing',
'fuchsia/upload',
'recipe_engine/file',
'recipe_engine/json',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/step',
]
from recipe_engine.recipe_api import Property
PROPERTIES = {
'upload_to_catapult':
Property(
param_name='upload_to_catapult',
kind=bool,
help='Whether to upload perf data to catapult',
default=False),
'parent_build_id':
Property(
param_name='parent_build_id',
kind=int,
help='Buildbucket ID of this build\'s parent build',
default=None),
}
def RunSteps(api, upload_to_catapult, parent_build_id):
gcs_bucket = 'bucket'
file_path = api.path['cleanup'].join('file-to-upload.txt')
api.upload.file_to_gcs(
source=file_path,
bucket=gcs_bucket,
subpath='dest',
namespace=parent_build_id,
)
dir_path = api.path['cleanup'].join('dir-to-upload')
api.upload.directory_to_gcs(
source=dir_path,
bucket=gcs_bucket,
subpath='dest',
namespace=parent_build_id,
)
upload_paths = [
api.upload.DirectoryPath(dir_path),
api.upload.FilePath(dir_path.join('my_file'))
]
api.upload.upload_isolated(dir_path, upload_paths)
pkg_name = 'fuchsia/foo/${platform}'
api.upload.cipd_package(
pkg_name,
dir_path,
upload_paths, {'git_revision': 'abc1234'},
'tools',
extra_tags={
'version': 'abc1234',
'extra_tag': 'value'
})
if upload_to_catapult:
catapult_dir = api.path.mkdtemp('catapult')
catapult_file = catapult_dir.join('output.catapult_json')
api.file.write_json('write_json', catapult_file, {})
deprecated_catapult_file = catapult_dir.join('deprecated.catapult_json')
api.file.write_json('write_json', deprecated_catapult_file, {})
api.upload.test_outputs_to_catapult(catapult_dir)
def GenTests(api):
yield (api.test('basic') + api.step_data(
'cipd.cipd search fuchsia/foo/${platform} git_revision:' + 'abc1234',
api.json.output({'result': []})))
yield (api.test('upload_to_catapult') +
api.properties(upload_to_catapult=True))
yield (api.test('led_job') + api.properties(**{
'$recipe_engine/led': {
'led_run_id': 'led/user_example.com/abc123'
},
}))
yield (api.test('child_build') + api.properties(parent_build_id=1234))