blob: 910c7658b400aaecd2ff58ff890481f7e07668f8 [file] [log] [blame]
# Copyright 2021 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.
# Compiles platform specific executables for the scripts in dart_ci/builder
# and uploads them as CIPD package 'dart/ci/builder_scripts/${platform}'.
from recipe_engine.post_process import Filter
DEPS = [
'depot_tools/git',
'recipe_engine/buildbucket',
'recipe_engine/cipd',
'recipe_engine/context',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/step',
]
PYTHON_VERSION_COMPATIBILITY = "PY3"
def RunSteps(api):
# Checkout dart_ci version to build.
revision = api.buildbucket.gitiles_commit.id or 'HEAD'
got_revision = api.git.checkout(
url='https://dart.googlesource.com/dart_ci',
ref=revision,
set_got_revision=True)
source_path = api.path['start_dir'].join('dart_ci')
# Get the Dart SDK to be used to compile the scripts.
packages_path = api.path['cache'].join('cipd_packages')
ensure_file = api.cipd.EnsureFile()
# Cannot use ensure_tool here because of dartbug.com/46364
ensure_file.add_package('dart/dart-sdk/${platform}', 'version:2.13.1')
api.cipd.ensure(packages_path, ensure_file)
dart = packages_path.join('dart-sdk', 'bin', 'dart')
# Compile scripts.
output_root = api.path.mkdtemp()
executable_name = ('update_results_database.exe'
if api.platform.is_win else 'update_results_database')
output_file = output_root.join(executable_name)
input_file = source_path.join('builder', 'bin',
'update_results_database.dart')
pub_cache = api.path.mkdtemp()
with api.context(
cwd=source_path.join('builder'), env={'PUB_CACHE': pub_cache}):
api.step('pub get', [dart, 'pub', 'get'])
api.step('compile script',
[dart, 'compile', 'exe', input_file, '-o', output_file])
# Create CIPD package from scripts.
package_name = 'dart/ci/builder_scripts/${platform}'
pkg = api.cipd.PackageDefinition(package_name, output_root, 'copy')
pkg.add_file(output_file)
api.cipd.create_from_pkg(
pkg, tags={'git_revision': got_revision}, refs=['latest'])
def GenTests(api):
yield api.test(
'basic',
api.buildbucket.ci_build(builder='dart-ci-scripts-linux') +
api.platform('linux', 64),
)
yield api.test(
'basic-win',
api.buildbucket.ci_build(builder='dart-ci-scripts-win') +
api.platform('win', 64),
)
yield api.test(
'basic-with-revision',
api.buildbucket.ci_build(
builder='dart-ci-scripts', revision='refs/changes/20/203220/9'),
)