skia2/infra/bots/recipes.py
recipe-roller 42e16b01cd Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls recipe
changes from upstream projects (e.g. depot_tools) into downstream projects
(e.g. tools/build).


More info is at https://goo.gl/zkKdpD. Use https://goo.gl/noib3a to file a bug.
build:
  https://crrev.com/4ed4219bd19960b21e8bc17f61f775ce2a973562 Move Win8 and Win10 bots over to swarming. (ehmaldonado@chromium.org)
  https://crrev.com/6c0332b76eb3496620601ed2b974bece89dbcd0f Add ios_compile, ios64_compile, and linux_fuzz BoringSSL builders. (davidben@chromium.org)
  https://crrev.com/a75ef95539f72ced4d30ad85ea35b6664a2ffa3c [codesearah] Refactor chromium_codesearch.py to use run_mb (shenghuazhang@google.com)
  https://crrev.com/c7749c05c3deff6d34c05b3135b98e3f12e22866 Add LIBFUZZER_FROM_DEPS to fuzzer bots. (davidben@chromium.org)
  https://crrev.com/6054a101391edc7c0feff76ae027bd5c0fd8052d Add Fuchsia slave to FYI master (scottmg@chromium.org)
  https://crrev.com/f741f2de5b2345031078dea917bdd466313a8a85 Enable PubSub streaming for tryserver.client.catapult (hinoka@google.com)
  https://crrev.com/65dbbe481846b68665ea12e737fde04d3f3b2dc6 chromite recipe_module: Remove build_type and variant support. (dgarrett@google.com)
  https://crrev.com/a922a0f7d8d1aecffb96c70fcabb4cf6aed8b5ca Manually roll depot_tools 57a8692:beec006 (phajdan.jr@chromium.org)
  https://crrev.com/5f90cd4ff7fa665e5dcd93016ead17b60a9c315b V8: Bump shards on slowest bots (machenbach@chromium.org)
  https://crrev.com/bdb9d6cb87b77bf04acc1165cfe581a508e1d40e Adjusting run_tool.py command line to account for recent changes (emso@chromium.org)
  https://crrev.com/2d2c1a2cce4ecd784375fe0b78aa2273f45df3b3 WebRTC: Tests for Android Studio project creation (kjellander@chromium.org)
  https://crrev.com/26a68cd1302d673f1ca924b22340f52a125bf315 Revert "WebRTC: Tests for Android Studio project creation" (kjellander@chromium.org)
  https://crrev.com/6d2e75af8686a56cbd4fbd9adcf808d916fdfc96 Add emso to the OWNERS (emso@chromium.org)
  https://crrev.com/bdf87b9ebf0a1534c96982344d6dcefab79c51ea Reland "WebRTC: Tests for Android Studio project creation"" (kjellander@chromium.org)
  https://crrev.com/590e609111eaaa9c7fd94d919b090e36c1fa9151 Adds more slaves to the codesearch master (emso@chromium.org)
  https://crrev.com/0903c31179747b6479b608eb5240eccca600084c chromium_checkout: do not run gclient validate if patch failed to apply (phajdan.jr@chromium.org)
depot_tools:
  https://crrev.com/1e250cdeb344f096cbff4d515e333077b3b108a8 git cl creds-check: understand '~' in path to .gitcookies. (tandrii@chromium.org)
  https://crrev.com/8e4576f38535ad6eb407f6c63fa4a4d5afe1f1cb git cl upload: fix confusing warning. (tandrii@chromium.org)
  https://crrev.com/28a5d5defd13c382af94cd8368b16641752fee88 Relax git_footers parsing to match that of Gerrit (JGit). (tandrii@chromium.org)
  https://crrev.com/fa16a83dd2f3100f996e0834ef16f1277c4070fa vpython: proper shebang :) (dnj@chromium.org)
  https://crrev.com/beec006697a11600e254ac6c69e98f76d555306b gclient validate: add schema checking (phajdan.jr@chromium.org)
  https://crrev.com/43ec62ec712c3f199f85c8abec6db77a9e5e81e1 Revert "Relax git_footers parsing to match that of Gerrit (JGit)." (tandrii@chromium.org)
recipe_engine:
  https://crrev.com/23230785ddaec6e199d3ede6d496131ec178c183 config: fix config.Dict with no value type (nodir@chromium.org)
  https://crrev.com/c594d93e17bd0e32f02620808deed9b1833bd81f [autoroll] Remove support for 'config section' in doc/recipes.py (iannucci@chromium.org)
  https://crrev.com/275cbaae0e81a737ff1be9c73049b2cd124388ad [context] Add user-facing context module. (iannucci@chromium.org)


TBR=borenet@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ic18db3dfdfead37acdbf66da6b81182f87ec736a
Reviewed-on: https://skia-review.googlesource.com/16481
Reviewed-by: Recipe Roller <recipe-roller@chromium.org>
Commit-Queue: Recipe Roller <recipe-roller@chromium.org>
2017-05-11 11:50:10 +00:00

208 lines
6.5 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright 2017 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Bootstrap script to clone and forward to the recipe engine tool.
*******************
** DO NOT MODIFY **
*******************
This is a copy of https://github.com/luci/recipes-py/blob/master/doc/recipes.py.
To fix bugs, fix in the github repo then run the autoroller.
"""
import argparse
import json
import logging
import os
import random
import subprocess
import sys
import time
import urlparse
from collections import namedtuple
from cStringIO import StringIO
# The dependency entry for the recipe_engine in the client repo's recipes.cfg
#
# url (str) - the url to the engine repo we want to use.
# revision (str) - the git revision for the engine to get.
# path_override (str) - the subdirectory in the engine repo we should use to
# find it's recipes.py entrypoint. This is here for completeness, but will
# essentially always be empty. It would be used if the recipes-py repo was
# merged as a subdirectory of some other repo and you depended on that
# subdirectory.
# branch (str) - the branch to fetch for the engine as an absolute ref (e.g.
# refs/heads/master)
# repo_type ("GIT"|"GITILES") - An ignored enum which will be removed soon.
EngineDep = namedtuple('EngineDep',
'url revision path_override branch repo_type')
class MalformedRecipesCfg(Exception):
def __init__(self, msg, path):
super(MalformedRecipesCfg, self).__init__('malformed recipes.cfg: %s: %r'
% (msg, path))
def parse(repo_root, recipes_cfg_path):
"""Parse is a lightweight a recipes.cfg file parser.
Args:
repo_root (str) - native path to the root of the repo we're trying to run
recipes for.
recipes_cfg_path (str) - native path to the recipes.cfg file to process.
Returns (as tuple):
engine_dep (EngineDep): The recipe_engine dependency.
recipes_path (str) - native path to where the recipes live inside of the
current repo (i.e. the folder containing `recipes/` and/or
`recipe_modules`)
"""
with open(recipes_cfg_path, 'rU') as fh:
pb = json.load(fh)
try:
if pb['api_version'] != 2:
raise MalformedRecipesCfg('unknown version %d' % pb['api_version'],
recipes_cfg_path)
engine = pb['deps']['recipe_engine']
if 'url' not in engine:
raise MalformedRecipesCfg(
'Required field "url" in dependency "recipe_engine" not found',
recipes_cfg_path)
engine.setdefault('revision', '')
engine.setdefault('path_override', '')
engine.setdefault('branch', 'refs/heads/master')
recipes_path = pb.get('recipes_path', '')
# TODO(iannucci): only support absolute refs
if not engine['branch'].startswith('refs/'):
engine['branch'] = 'refs/heads/' + engine['branch']
engine.setdefault('repo_type', 'GIT')
if engine['repo_type'] not in ('GIT', 'GITILES'):
raise MalformedRecipesCfg(
'Unsupported "repo_type" value in dependency "recipe_engine"',
recipes_cfg_path)
recipes_path = os.path.join(
repo_root, recipes_path.replace('/', os.path.sep))
return EngineDep(**engine), recipes_path
except KeyError as ex:
raise MalformedRecipesCfg(ex.message, recipes_cfg_path)
GIT = 'git.bat' if sys.platform.startswith(('win', 'cygwin')) else 'git'
def _subprocess_call(argv, **kwargs):
logging.info('Running %r', argv)
return subprocess.call(argv, **kwargs)
def _git_check_call(argv, **kwargs):
argv = [GIT]+argv
logging.info('Running %r', argv)
subprocess.check_call(argv, **kwargs)
def _git_output(argv, **kwargs):
argv = [GIT]+argv
logging.info('Running %r', argv)
return subprocess.check_output(argv, **kwargs)
def parse_args(argv):
"""This extracts a subset of the arguments that this bootstrap script cares
about. Currently this consists of:
* an override for the recipe engine in the form of `-O recipe_engin=/path`
* the --package option.
"""
PREFIX = 'recipe_engine='
p = argparse.ArgumentParser(add_help=False)
p.add_argument('-O', '--project-override', action='append')
p.add_argument('--package', type=os.path.abspath)
args, _ = p.parse_known_args(argv)
for override in args.project_override or ():
if override.startswith(PREFIX):
return override[len(PREFIX):], args.package
return None, args.package
def checkout_engine(engine_path, repo_root, recipes_cfg_path):
dep, recipes_path = parse(repo_root, recipes_cfg_path)
url = dep.url
if not engine_path and url.startswith('file://'):
engine_path = urlparse.urlparse(url).path
if not engine_path:
revision = dep.revision
subpath = dep.path_override
branch = dep.branch
# Ensure that we have the recipe engine cloned.
engine = os.path.join(recipes_path, '.recipe_deps', 'recipe_engine')
engine_path = os.path.join(engine, subpath)
with open(os.devnull, 'w') as NUL:
# Note: this logic mirrors the logic in recipe_engine/fetch.py
_git_check_call(['init', engine], stdout=NUL)
try:
_git_check_call(['rev-parse', '--verify', '%s^{commit}' % revision],
cwd=engine, stdout=NUL, stderr=NUL)
except subprocess.CalledProcessError:
_git_check_call(['fetch', url, branch], cwd=engine, stdout=NUL,
stderr=NUL)
try:
_git_check_call(['diff', '--quiet', revision], cwd=engine)
except subprocess.CalledProcessError:
_git_check_call(['reset', '-q', '--hard', revision], cwd=engine)
return engine_path
def main():
if '--verbose' in sys.argv:
logging.getLogger().setLevel(logging.INFO)
args = sys.argv[1:]
engine_override, recipes_cfg_path = parse_args(args)
if recipes_cfg_path:
# calculate repo_root from recipes_cfg_path
repo_root = os.path.dirname(
os.path.dirname(
os.path.dirname(recipes_cfg_path)))
else:
# find repo_root with git and calculate recipes_cfg_path
repo_root = (_git_output(
['rev-parse', '--show-toplevel'],
cwd=os.path.abspath(os.path.dirname(__file__))).strip())
repo_root = os.path.abspath(repo_root)
recipes_cfg_path = os.path.join(repo_root, 'infra', 'config', 'recipes.cfg')
args = ['--package', recipes_cfg_path] + args
engine_path = checkout_engine(engine_override, repo_root, recipes_cfg_path)
return _subprocess_call([
sys.executable, '-u',
os.path.join(engine_path, 'recipes.py')] + args)
if __name__ == '__main__':
sys.exit(main())