blob: 02eff8d774854372d265a5db4d7bf90f4db8238f [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from contextlib import contextmanager
from PB.recipes.flutter.engine.engine_license import InputProperties
from PB.recipes.flutter.engine.engine_license import EnvProperties
DEPS = [
'depot_tools/depot_tools',
'depot_tools/gclient',
'flutter/build_util',
'flutter/flutter_deps',
'flutter/logs_util',
'flutter/os_utils',
'flutter/repo_util',
'flutter/retry',
'flutter/test_utils',
'fuchsia/goma',
'recipe_engine/buildbucket',
'recipe_engine/context',
'recipe_engine/file',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/runtime',
'recipe_engine/step',
]
GIT_REPO = 'https://flutter.googlesource.com/mirrors/engine'
PROPERTIES = InputProperties
ENV_PROPERTIES = EnvProperties
def GetCheckoutPath(api):
return api.path['cache'].join('builder', 'src')
def CheckLicenses(api):
checkout = GetCheckoutPath(api)
with api.context(cwd=checkout):
licenses_cmd = checkout.join('flutter', 'ci', 'licenses.sh')
api.step('licenses check', [licenses_cmd])
def RunSteps(api, properties, env_properties):
# Collect memory/cpu/process before task execution.
api.os_utils.collect_os_info()
cache_root = api.path['cache'].join('builder')
checkout = GetCheckoutPath(api)
api.file.rmtree('Clobber build output', checkout.join('out'))
api.file.ensure_directory('Ensure checkout cache', cache_root)
api.goma.ensure()
dart_bin = checkout.join(
'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin'
)
android_home = checkout.join('third_party', 'android_tools', 'sdk')
env = {
'GOMA_DIR': api.goma.goma_dir,
'ANDROID_HOME': str(android_home),
'FLUTTER_PREBUILT_DART_SDK': 'True',
}
env_prefixes = {'PATH': [dart_bin]}
api.logs_util.initialize_logs_collection(env)
# Add certificates and print the ones required for pub.
api.flutter_deps.certs(env, env_prefixes)
api.os_utils.print_pub_certs()
api.repo_util.engine_checkout(cache_root, env, env_prefixes)
# Delete derived data on mac. This is a noop for other platforms.
api.os_utils.clean_derived_data()
# Various scripts we run assume access to depot_tools on path for `ninja`.
with api.context(cwd=cache_root, env=env,
env_prefixes=env_prefixes), api.depot_tools.on_path():
api.gclient.runhooks()
try:
CheckLicenses(api)
finally:
api.logs_util.upload_logs('engine')
# This is to clean up leaked processes.
api.os_utils.kill_processes()
# Collect memory/cpu/process after task execution.
api.os_utils.collect_os_info()
# pylint: disable=line-too-long
# See https://chromium.googlesource.com/infra/luci/recipes-py/+/refs/heads/master/doc/user_guide.md
# The tests in here make sure that every line of code is used and does not fail.
# pylint: enable=line-too-long
def GenTests(api):
for platform in ['linux']:
test = api.test(
'%s' % platform,
api.platform(platform, 64),
api.buildbucket.ci_build(
builder='%s Engine License' % platform.capitalize(),
git_repo=GIT_REPO,
project='flutter',
),
api.runtime(is_experimental=False),
api.properties(
InputProperties(
goma_jobs='1024',
),
),
api.properties.environ(
EnvProperties(SWARMING_TASK_ID='deadbeef')
),
)
yield test