| # 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/step', |
| ] |
| |
| |
| 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() |
| output_file = output_root.join('update_results_database') |
| 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. |
| builder = str(api.buildbucket.builder_name) |
| package_name = 'dart/ci/builder_scripts/mac-arm64' if builder.endswith( |
| 'mac-arm64') else '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'), |
| ) |
| |
| yield api.test( |
| 'basic-mac-arm64', |
| api.buildbucket.ci_build(builder='dart-ci-scripts-mac-arm64'), |
| ) |
| |
| yield api.test( |
| 'basic-with-revision', |
| api.buildbucket.ci_build( |
| builder='dart-ci-scripts', revision='refs/changes/20/203220/9'), |
| ) |