| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 | |
| 7 """Run the Blink AutoRoll bot for Skia.""" | |
| 8 | |
| 9 | |
| 10 import os | |
| 11 import re | |
| 12 import sys | |
| 13 | |
| 14 from build_step import BuildStep | |
| 15 from py.utils import misc | |
| 16 from py.utils import shell_utils | |
| 17 from slave import slave_utils | |
| 18 from utils import gs_utils | |
| 19 | |
| 20 sys.path.append(misc.BUILDBOT_PATH) | |
| 21 | |
| 22 from site_config import skia_vars | |
| 23 | |
| 24 | |
| 25 DEPS_ROLL_AUTHOR = 'skia-deps-roller@chromium.org' | |
| 26 DEPS_ROLL_NAME = 'Skia DEPS Roller' | |
| 27 HTML_CONTENT = ''' | |
| 28 <html> | |
| 29 <head> | |
| 30 <meta http-equiv="Pragma" content="no-cache"> | |
| 31 <meta http-equiv="Expires" content="-1"> | |
| 32 <meta http-equiv="refresh" content="0; url=%s" /> | |
| 33 </head> | |
| 34 </html> | |
| 35 ''' | |
| 36 ISSUE_URL_TEMPLATE = 'https://codereview.chromium.org/%(issue)s/' | |
| 37 | |
| 38 # TODO(borenet): Find a way to share these filenames (or their full GS URL) with | |
| 39 # the webstatus which links to them. | |
| 40 FILENAME_CURRENT_ATTEMPT = 'depsroll.html' | |
| 41 FILENAME_ROLL_STATUS = 'arb_status.html' | |
| 42 | |
| 43 REGEXP_ISSUE_CREATED = ( | |
| 44 r'Issue created. URL: https://codereview.chromium.org/(?P<issue>\d+)') | |
| 45 REGEXP_ROLL_ACTIVE = ( | |
| 46 r'https://codereview.chromium.org/(?P<issue>\d+)/ is still active') | |
| 47 REGEXP_ROLL_STOPPED = ( | |
| 48 r'https://codereview.chromium.org/(?P<issue>\d+)/: Rollbot was stopped by') | |
| 49 # This occurs when the ARB has "caught up" and has nothing new to roll, or when | |
| 50 # a different roll (typically a manual roll) has already rolled past it. | |
| 51 REGEXP_ROLL_TOO_OLD = r'Already at .+ refusing to roll backwards to .+' | |
| 52 | |
| 53 ROLL_STATUS_IN_PROGRESS = 'In progress - %s' % ISSUE_URL_TEMPLATE | |
| 54 ROLL_STATUS_STOPPED = 'Stopped - %s' % ISSUE_URL_TEMPLATE | |
| 55 ROLL_STATUS_IDLE = 'Idle' | |
| 56 | |
| 57 ROLL_STATUSES = [ | |
| 58 (REGEXP_ISSUE_CREATED, ROLL_STATUS_IN_PROGRESS), | |
| 59 (REGEXP_ROLL_ACTIVE, ROLL_STATUS_IN_PROGRESS), | |
| 60 (REGEXP_ROLL_STOPPED, ROLL_STATUS_STOPPED), | |
| 61 (REGEXP_ROLL_TOO_OLD, ROLL_STATUS_IDLE), | |
| 62 ] | |
| 63 | |
| 64 | |
| 65 class AutoRoll(BuildStep): | |
| 66 """BuildStep which runs the Blink AutoRoll bot.""" | |
| 67 | |
| 68 def _Run(self): | |
| 69 chrome_path = os.path.join(os.pardir, 'src') | |
| 70 with misc.ChDir(chrome_path): | |
| 71 shell_utils.run(['git', 'config', '--local', 'user.name', DEPS_ROLL_NAME]) | |
| 72 shell_utils.run(['git', 'config', '--local', 'user.email', | |
| 73 DEPS_ROLL_AUTHOR]) | |
| 74 | |
| 75 auto_roll = os.path.join(misc.BUILDBOT_PATH, 'third_party', | |
| 76 'chromium_buildbot_tot', 'scripts', 'tools', | |
| 77 'blink_roller', 'auto_roll.py') | |
| 78 | |
| 79 # python auto_roll.py <project> <author> <path to chromium/src> | |
| 80 cmd = ['python', auto_roll, 'skia', DEPS_ROLL_AUTHOR, chrome_path] | |
| 81 | |
| 82 exception = None | |
| 83 try: | |
| 84 output = shell_utils.run(cmd) | |
| 85 except shell_utils.CommandFailedException as e: | |
| 86 output = e.output | |
| 87 # Suppress failure for "refusing to roll backwards." | |
| 88 if not re.search(REGEXP_ROLL_TOO_OLD, output): | |
| 89 exception = e | |
| 90 | |
| 91 bucket_url = gs_utils.GSUtils.with_gs_prefix( | |
| 92 skia_vars.GetGlobalVariable('googlestorage_bucket')) | |
| 93 | |
| 94 match = re.search(REGEXP_ISSUE_CREATED, output) | |
| 95 if match: | |
| 96 issue = match.group('issue') | |
| 97 print 'Found issue #', issue | |
| 98 with open(FILENAME_CURRENT_ATTEMPT, 'w') as f: | |
| 99 f.write(HTML_CONTENT % (ISSUE_URL_TEMPLATE % {'issue': issue})) | |
| 100 slave_utils.GSUtilCopyFile( | |
| 101 filename=FILENAME_CURRENT_ATTEMPT, | |
| 102 gs_base=bucket_url, | |
| 103 subdir=None, | |
| 104 gs_acl='public-read') | |
| 105 | |
| 106 roll_status = None | |
| 107 for regexp, status_msg in ROLL_STATUSES: | |
| 108 match = re.search(regexp, output) | |
| 109 if match: | |
| 110 roll_status = status_msg % match.groupdict() | |
| 111 break | |
| 112 | |
| 113 if roll_status: | |
| 114 with open(FILENAME_ROLL_STATUS, 'w') as f: | |
| 115 f.write(roll_status) | |
| 116 slave_utils.GSUtilCopyFile( | |
| 117 filename=FILENAME_ROLL_STATUS, | |
| 118 gs_base=bucket_url, | |
| 119 subdir=None, | |
| 120 gs_acl='public-read') | |
| 121 | |
| 122 #pylint: disable=E0702 | |
| 123 if exception: | |
| 124 raise exception | |
| 125 | |
| 126 | |
| 127 if '__main__' == __name__: | |
| 128 sys.exit(BuildStep.RunBuildStep(AutoRoll)) | |
| OLD | NEW |