Chromium Code Reviews| Index: scripts/slave/recipes/infra/gae_sdk_cipd_packager.py |
| diff --git a/scripts/slave/recipes/infra/gae_sdk_cipd_packager.py b/scripts/slave/recipes/infra/gae_sdk_cipd_packager.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dbc3759b33f4f239d2a42b35585ef6d2de702e8c |
| --- /dev/null |
| +++ b/scripts/slave/recipes/infra/gae_sdk_cipd_packager.py |
| @@ -0,0 +1,82 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
|
iannucci
2016/09/30 21:05:21
This recipe should have been a separate CL
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +DEPS = [ |
| + 'depot_tools/cipd', |
| + 'gae_sdk', |
| + 'gsutil', |
| + 'recipe_engine/path', |
| + 'recipe_engine/python', |
| + 'recipe_engine/raw_io', |
| + 'recipe_engine/step', |
| +] |
| + |
| + |
| +def RunSteps(api): |
| + # Determine the current GAE SDK version. |
| + try: |
| + version = api.gae_sdk.latest_upstream_version() |
| + except api.gae_sdk.VersionParseError as e: |
| + api.python.failing_step('Version Fetch', |
| + 'Failed to fetch latest version: %s' % (e,)) |
| + |
| + # Make sure the CIPD client is installed. |
| + api.cipd.install_client() |
| + |
| + # Iterate over all of the GAE SDK packages and build any that don't exist. |
| + version_tag = api.gae_sdk.version_tag(version) |
| + pkg_outdir = api.path.mkdtemp('gae_sdk_package') |
| + for plat, arch in api.gae_sdk.all_packages: |
| + pkg_name = api.gae_sdk.package(plat, arch=arch) |
| + with api.step.nest('Sync %s' % (pkg_name,)): |
| + step = api.cipd.search(pkg_name, '%s:%s' % (version_tag)) |
| + if len(step.json.output['result']) > 0: |
| + api.python.succeeding_step('Synced', 'Package is up to date.') |
| + continue |
| + |
| + # Create a temporary directory to build the package in. |
| + pkg_base = api.gae_sdk.download_and_unpack(plat, arch, version) |
| + |
| + # Build and register our CIPD package. |
| + pkg_path = pkg_outdir.join('gae_sdk_%s_%s.pkg' % (plat, arch)) |
| + api.cipd.build( |
| + pkg_base, |
| + pkg_path, |
| + pkg_name, |
| + install_mode='copy', |
| + ) |
| + api.cipd.register( |
| + pkg_name, |
| + pkg_path, |
| + refs=[api.gae_sdk.latest_ref], |
| + tags={version_tag[0]: version_tag[1]}, |
| + ) |
| + |
| + |
| +def GenTests(api): |
| + LATEST_YAML = '\n'.join(( |
| + 'release: "1.2.3"', |
| + 'foo: bar', |
| + 'baz:', |
| + ' - qux', |
| + )) |
| + |
| + def cipd_pkg(plat, pkg_base, exists): |
| + pkg_name = 'infra/gae_sdk/%s/%s' % (plat, pkg_base) |
| + cipd_step = 'cipd search %s gae_sdk_version:1.2.3' % (pkg_name,) |
| + instances = (2) if exists else (0) |
| + return api.step_data('Sync %s.%s' % (pkg_name, cipd_step), |
| + api.cipd.example_search(pkg_name, instances=instances)) |
| + |
| + yield (api.test('packages') + |
| + api.step_data('gsutil GAE SDK: Get Latest', |
| + api.raw_io.stream_output(LATEST_YAML, stream='stdout')) + |
| + cipd_pkg('go', 'linux-amd64', False) + |
| + cipd_pkg('go', 'linux-386', True) + |
| + cipd_pkg('go', 'mac-amd64', True) + |
| + cipd_pkg('python', 'all', False)) |
| + |
| + yield (api.test('bad_version_yaml') + |
| + api.step_data('gsutil GAE SDK: Get Latest', |
| + api.raw_io.stream_output('', stream='stdout'))) |