skia2/infra/bots/recipes.py
recipe-roller be9aa64ff9 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools, recipe_engine) into this repository.

depot_tools:
09f358bae3~..b39f6bbf82e3a9bfbed3d24b561726c247d7a48d
  09f358b (ehmaldonado@google.com)
      metrics: Don't collect metrics on DEPOT_TOOLS_METRICS=0
  534f505 (songfangzhen@bytedance.com)
      Update format of `git cl split`
  3ac55bc (nodir@chromium.org)
      Revert "[dirmd] Roll dirmd"
  9f6aa1b (raphael.kubo.da.costa@intel.com)
      gerrit_util: Make GceAuthenticator also consider proxy errors i...
  6f0df68 (dpranke@google.com)
      Add use_python3 to codereview.settings to set default for PRESU...
  a73eec2 (fdegans@google.com)
      Add a new argument to skip shebang checks on python3
  2a6dffa (tikuta@chromium.org)
      Reland "use python3 for goma related scripts"
  4577360 (sokcevic@google.com)
      Reland "Reland "Update gsutil to use gsutil version 4.61, pytho...
  fc3fb20 (brucedawson@chromium.org)
      Revert "Reland "use python3 for goma related scripts""
  a806594 (brucedawson@chromium.org)
      Reland "Reland "use python3 for goma related scripts""
  db632b6 (sokcevic@google.com)
      Use main as default branch in documentation
  a50bd44 (vadimsh@chromium.org)
      [cipd] Update CIPD client to 2.6.0.
  965a05b (kyleju@chromium.org)
      Fix py3 presubmit error. Use unicode strings explicitly.
  1bfda8e (sigurds@chromium.org)
      Respect git config cl.date-order in `git cl st`
  6b08432 (sokcevic@google.com)
      Use main as default branch for git recipe module
  866be0f (wnwen@chromium.org)
      Add an option to specify pylint version
  f0d7ed8 (sokcevic@google.com)
      Allow custom filters for json validation
  0aabd63 (victorsamun@yandex-team.ru)
      Fix python2/3 compatibility in DownloadUsingHttp function
  b3d52d3 (sokcevic@google.com)
      Revert "Use main as default branch for git recipe module"
  c079895 (vadimsh@chromium.org)
      [cipd] Update CIPD client and vpython.
  26adc2a (sokcevic@google.com)
      Fix generating man pages
  eb140ae (yyanagisawa@chromium.org)
      Roll out new goma client binary VERSION=225
  b39f6bb (bryner@google.com)
      Roll new vpython to depot_tools.

recipe_engine:
fe59faf05e~..af228e7f3c4fe44fe10fd65d866dccaedff4a219
  fe59faf (tikuta@chromium.org)
      cas: get cipd package revision from file
  fd22f03 (tikuta@chromium.org)
      cas: simplify _version a bit
  f6ae625 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 34b847e00d95 to bcbbe2d4b506
  b19a5af (yuanjunh@google.com)
      [python3] Make recipes doc command py3-compatible
  7b628b8 (iannucci@chromium.org)
      [python3] Add indicator for python3 compat at recipe/module level.
  d731cbd (iannucci@chromium.org)
      Add ability to read + simulate GLOBAL_SHUTDOWN.
  0032604 (tandrii@google.com)
      Make autoroller owner of CAS Client pin.
  f62b45d (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 78702ac003f3 to 76ddc72fae59
  010e03b (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from c277f3162d43 to 1403fab7e195
  1b6e184 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from f8fee322da09 to 68a9d9f74279
  b14cfa0 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 8dce0cb59e09 to 9464003f0708
  bc01d1b (qyearsley@chromium.org)
      [python3 compatibility] Switch to iteritems in recipe engine un...
  cd13c55 (qyearsley@chromium.org)
      recipe engine: Spellcheck and minor formatting
  78cc13b (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 9464003f0708 to 8dd195b8fed9
  fad480e (qyearsley@chromium.org)
      [python3 compatibility] Run some futurize "stage 2" fixers on r...
  89cf3c8 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 8dd195b8fed9 to e14bb15691db
  4abe5ab (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from e14bb15691db to 13eb6a325aaa
  4543597 (martiniss@google.com)
      Improve cas archive default
  e16a16a (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 102bb894249d to 40001c4c5150
  e88454d (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from eba70e5d7b53 to c85e8f0ecb90
  284f8eb (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from c85e8f0ecb90 to 01ae064f288d
  434b4f0 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 6fa1788bbb0e to 713757bf8a41
  8238109 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 8b378ab01c51 to 40f945205c86
  f0f25eb (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from f50bf9c6481d to 63c49027cfa9
  18e4134 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 63c49027cfa9 to 89085d1a792a
  442820a (tikuta@chromium.org)
      tricium: show comment even if it exceeds 50
  d44e046 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from da9c74b88f55 to d425349380f6
  92a7948 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from d425349380f6 to 13d1aa30c73d
  56686d5 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 13d1aa30c73d to d5505d31f87f
  443bf98 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 4f05b72dc873 to dddfb00ee624
  30dbfb4 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from dddfb00ee624 to d60b89d9dffa
  1951b83 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from d60b89d9dffa to e29eacaa51b1
  3606812 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 02e723041f2e to af2dc3835e4f
  46491c0 (iannucci@chromium.org)
      Add RECIPES_DEBUG_SLEEP to have engine do sleep for led.
  bb91c77 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from af2dc3835e4f to 9a1c1dd351da
  8a92136 (iannucci@chromium.org)
      Add function to compute effective python compatibility.
  2ad13e4 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 9a1c1dd351da to 5e2c34b93cdf
  e47c6d4 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 5e2c34b93cdf to aca8d68f3040
  1c85729 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from b53f44dad74f to f483cf4004ef
  e4db17b (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 0862ebb13f0c to 61d5434b44c8
  8d05dc8 (tikuta@chromium.org)
      isolated: remove on_path
  c4b8357 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 9f7beee9fe44 to 91cf324fb7a0
  478f380 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 3fadd3e58f93 to 74b60d9d714f
  af228e7 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 74b60d9d714f to 6808332cfd84

More info is at https://goo.gl/zkKdpD. Use https://goo.gl/noib3a to file a bug.

R=borenet@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Bugdroid-Send-Email: False
Change-Id: I43f528d39adae46c34f695fc92f65b939b0f790d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425144
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2021-07-07 15:15:41 +00:00

266 lines
8.4 KiB
Python
Executable File

#!/bin/sh
# Copyright 2019 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.
# We want to run python in unbuffered mode; however shebangs on linux grab the
# entire rest of the shebang line as a single argument, leading to errors like:
#
# /usr/bin/env: 'python2 -u': No such file or directory
#
# This little shell hack is a triple-quoted noop in python, but in sh it
# evaluates to re-exec'ing this script in unbuffered mode.
# pylint: disable=pointless-string-statement
''''exec python2 -u -- "$0" ${1+"$@"} # '''
# vi: syntax=python
"""Bootstrap script to clone and forward to the recipe engine tool.
*******************
** DO NOT MODIFY **
*******************
This is a copy of https://chromium.googlesource.com/infra/luci/recipes-py/+/main/recipes.py.
To fix bugs, fix in the googlesource repo then run the autoroller.
"""
# pylint: disable=wrong-import-position
import argparse
import errno
import json
import logging
import os
import subprocess
import sys
from collections import namedtuple
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
# 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.
# branch (str) - the branch to fetch for the engine as an absolute ref (e.g.
# refs/heads/main)
EngineDep = namedtuple('EngineDep', 'url revision branch')
class MalformedRecipesCfg(Exception):
def __init__(self, msg, path):
full_message = 'malformed recipes.cfg: %s: %r' % (msg, path)
super(MalformedRecipesCfg, self).__init__(full_message)
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|None): The recipe_engine dependency, or None, if the
current repo IS the recipe_engine.
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)
# If we're running ./recipes.py from the recipe_engine repo itself, then
# return None to signal that there's no EngineDep.
repo_name = pb.get('repo_name')
if not repo_name:
repo_name = pb['project_id']
if repo_name == 'recipe_engine':
return None, pb.get('recipes_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('branch', 'refs/heads/main')
recipes_path = pb.get('recipes_path', '')
# TODO(iannucci): only support absolute refs
if not engine['branch'].startswith('refs/'):
engine['branch'] = 'refs/heads/' + engine['branch']
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)
IS_WIN = sys.platform.startswith(('win', 'cygwin'))
_BAT = '.bat' if IS_WIN else ''
GIT = 'git' + _BAT
VPYTHON = ('vpython' +
('3' if os.getenv('RECIPES_USE_PY3') == 'true' else '') +
_BAT)
CIPD = 'cipd' + _BAT
REQUIRED_BINARIES = {GIT, VPYTHON, CIPD}
def _is_executable(path):
return os.path.isfile(path) and os.access(path, os.X_OK)
# TODO: Use shutil.which once we switch to Python3.
def _is_on_path(basename):
for path in os.environ['PATH'].split(os.pathsep):
full_path = os.path.join(path, basename)
if _is_executable(full_path):
return True
return False
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_engine=/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)
if dep is None:
# we're running from the engine repo already!
return os.path.join(repo_root, recipes_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
branch = dep.branch
# Ensure that we have the recipe engine cloned.
engine_path = os.path.join(recipes_path, '.recipe_deps', 'recipe_engine')
with open(os.devnull, 'w') as NUL:
# Note: this logic mirrors the logic in recipe_engine/fetch.py
_git_check_call(['init', engine_path], stdout=NUL)
try:
_git_check_call(['rev-parse', '--verify',
'%s^{commit}' % revision],
cwd=engine_path,
stdout=NUL,
stderr=NUL)
except subprocess.CalledProcessError:
_git_check_call(['fetch', url, branch],
cwd=engine_path,
stdout=NUL,
stderr=NUL)
try:
_git_check_call(['diff', '--quiet', revision], cwd=engine_path)
except subprocess.CalledProcessError:
index_lock = os.path.join(engine_path, '.git', 'index.lock')
try:
os.remove(index_lock)
except OSError as exc:
if exc.errno != errno.ENOENT:
logging.warn('failed to remove %r, reset will fail: %s', index_lock,
exc)
_git_check_call(['reset', '-q', '--hard', revision], cwd=engine_path)
# If the engine has refactored/moved modules we need to clean all .pyc files
# or things will get squirrely.
_git_check_call(['clean', '-qxf'], cwd=engine_path)
return engine_path
def main():
for required_binary in REQUIRED_BINARIES:
if not _is_on_path(required_binary):
return 'Required binary is not found on PATH: %s' % required_binary
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).decode()
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)
argv = (
[VPYTHON, '-u',
os.path.join(engine_path, 'recipe_engine', 'main.py')] + args)
if IS_WIN:
# No real 'exec' on windows; set these signals to ignore so that they
# propagate to our children but we still wait for the child process to quit.
import signal
signal.signal(signal.SIGBREAK, signal.SIG_IGN)
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN)
return _subprocess_call(argv)
else:
os.execvp(argv[0], argv)
if __name__ == '__main__':
sys.exit(main())