Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Pull latest revisions of a W3C test repo and make a local commit.""" | 5 """Pull latest revisions of a W3C test repo and make a local commit.""" |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import time | |
| 8 | 9 |
| 9 from webkitpy.common.webkit_finder import WebKitFinder | 10 from webkitpy.common.webkit_finder import WebKitFinder |
| 10 | 11 |
| 11 # Import destination directories (under LayoutTests/imported/). | 12 # Import destination directories (under LayoutTests/imported/). |
| 12 WPT_DEST_NAME = 'wpt' | 13 WPT_DEST_NAME = 'wpt' |
| 13 CSS_DEST_NAME = 'csswg-test' | 14 CSS_DEST_NAME = 'csswg-test' |
| 14 | 15 |
| 16 # Used for time.sleep(). | |
| 17 FIVE_MINUTES = 300 | |
|
qyearsley
2016/07/06 22:13:29
FIVE_MINUTES is a bad name because if you ever cha
| |
| 18 | |
| 15 | 19 |
| 16 class DepsUpdater(object): | 20 class DepsUpdater(object): |
| 17 | 21 |
| 18 def __init__(self, host): | 22 def __init__(self, host): |
| 19 self.host = host | 23 self.host = host |
| 20 self.executive = host.executive | 24 self.executive = host.executive |
| 21 self.fs = host.filesystem | 25 self.fs = host.filesystem |
| 22 self.finder = WebKitFinder(self.fs) | 26 self.finder = WebKitFinder(self.fs) |
| 23 self.verbose = False | 27 self.verbose = False |
| 24 self.allow_local_commits = False | 28 self.allow_local_commits = False |
| 25 self.keep_w3c_repos_around = False | 29 self.keep_w3c_repos_around = False |
| 26 self.target = None | 30 self.target = None |
| 31 self.auto_update = False | |
| 27 | 32 |
| 28 def main(self, argv=None): | 33 def main(self, argv=None): |
| 29 self.parse_args(argv) | 34 self.parse_args(argv) |
| 30 | 35 |
| 31 if not self.checkout_is_okay(): | 36 if not self.checkout_is_okay(): |
| 32 return 1 | 37 return 1 |
| 33 | 38 |
| 34 self.print_('## Noting the current Chromium commit.') | 39 self.print_('## Noting the current Chromium commit.') |
| 35 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) | 40 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) |
| 36 chromium_commitish = show_ref_output.split()[0] | 41 chromium_commitish = show_ref_output.split()[0] |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 53 | 58 |
| 54 elif self.target == 'css': | 59 elif self.target == 'css': |
| 55 import_commitish = self.update( | 60 import_commitish = self.update( |
| 56 CSS_DEST_NAME, | 61 CSS_DEST_NAME, |
| 57 'https://chromium.googlesource.com/external/w3c/csswg-test.git') | 62 'https://chromium.googlesource.com/external/w3c/csswg-test.git') |
| 58 else: | 63 else: |
| 59 raise AssertionError("Unsupported target %s" % self.target) | 64 raise AssertionError("Unsupported target %s" % self.target) |
| 60 | 65 |
| 61 self.commit_changes_if_needed(chromium_commitish, import_commitish) | 66 self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| 62 | 67 |
| 68 if self.auto_update: | |
| 69 self.run(['git', 'cl', 'upload', '-f']) | |
| 70 self.run(['git', 'cl', 'set-commit', '-d']) | |
|
qyearsley
2016/07/06 22:13:29
If you change '-d' to '--dry-run', then it may be
| |
| 71 while True: | |
| 72 time.sleep(FIVE_MINUTES) | |
| 73 _, out = self.run(['git', 'cl', 'try-results']) | |
| 74 results = self.parse_try_job_results(out) | |
| 75 if results['Started'] != set([]) or results['Scheduled'] != set( []): | |
| 76 continue | |
| 77 if results['Failures'] != set([]): | |
| 78 return 1 | |
| 79 break | |
| 63 return 0 | 80 return 0 |
| 64 | 81 |
| 65 def parse_args(self, argv): | 82 def parse_args(self, argv): |
| 66 parser = argparse.ArgumentParser() | 83 parser = argparse.ArgumentParser() |
| 67 parser.description = __doc__ | 84 parser.description = __doc__ |
| 68 parser.add_argument('-v', '--verbose', action='store_true', | 85 parser.add_argument('-v', '--verbose', action='store_true', |
| 69 help='log what we are doing') | 86 help='log what we are doing') |
| 70 parser.add_argument('--allow-local-commits', action='store_true', | 87 parser.add_argument('--allow-local-commits', action='store_true', |
| 71 help='allow script to run even if we have local comm its') | 88 help='allow script to run even if we have local comm its') |
| 72 parser.add_argument('--keep-w3c-repos-around', action='store_true', | 89 parser.add_argument('--keep-w3c-repos-around', action='store_true', |
| 73 help='leave the w3c repos around that were imported previously.') | 90 help='leave the w3c repos around that were imported previously.') |
| 74 parser.add_argument('target', choices=['css', 'wpt'], | 91 parser.add_argument('target', choices=['css', 'wpt'], |
| 75 help='Target repository. "css" for csswg-test, "wpt " for web-platform-tests.') | 92 help='Target repository. "css" for csswg-test, "wpt " for web-platform-tests.') |
| 93 parser.add_argument('--auto-update', action='store_true', | |
| 94 help='uploads CL and initiates commit queue.') | |
| 76 | 95 |
| 77 args = parser.parse_args(argv) | 96 args = parser.parse_args(argv) |
| 78 self.allow_local_commits = args.allow_local_commits | 97 self.allow_local_commits = args.allow_local_commits |
| 79 self.keep_w3c_repos_around = args.keep_w3c_repos_around | 98 self.keep_w3c_repos_around = args.keep_w3c_repos_around |
| 80 self.verbose = args.verbose | 99 self.verbose = args.verbose |
| 81 self.target = args.target | 100 self.target = args.target |
| 101 self.auto_update = args.auto_update | |
| 82 | 102 |
| 83 def checkout_is_okay(self): | 103 def checkout_is_okay(self): |
| 84 git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_ on_failure=False) | 104 git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_ on_failure=False) |
| 85 if git_diff_retcode: | 105 if git_diff_retcode: |
| 86 self.print_('## Checkout is dirty; aborting.') | 106 self.print_('## Checkout is dirty; aborting.') |
| 87 return False | 107 return False |
| 88 | 108 |
| 89 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA D'])[1] | 109 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA D'])[1] |
| 90 if local_commits and not self.allow_local_commits: | 110 if local_commits and not self.allow_local_commits: |
| 91 self.print_('## Checkout has local commits; aborting. Use --allow-lo cal-commits to allow this.') | 111 self.print_('## Checkout has local commits; aborting. Use --allow-lo cal-commits to allow this.') |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 dest = self.path_from_webkit_base(*comps) | 235 dest = self.path_from_webkit_base(*comps) |
| 216 if self.verbose: | 236 if self.verbose: |
| 217 self.print_('rm -fr %s' % dest) | 237 self.print_('rm -fr %s' % dest) |
| 218 self.fs.rmtree(dest) | 238 self.fs.rmtree(dest) |
| 219 | 239 |
| 220 def path_from_webkit_base(self, *comps): | 240 def path_from_webkit_base(self, *comps): |
| 221 return self.finder.path_from_webkit_base(*comps) | 241 return self.finder.path_from_webkit_base(*comps) |
| 222 | 242 |
| 223 def print_(self, msg): | 243 def print_(self, msg): |
| 224 self.host.print_(msg) | 244 self.host.print_(msg) |
| 245 | |
| 246 def parse_try_job_results(self, results): | |
| 247 """Parses try job results from Rietveld. | |
| 248 | |
| 249 Turns the output from git cl try-results into a usable format. | |
| 250 | |
| 251 Args: | |
| 252 results: The stdout obtained by running git cl try-results | |
| 253 | |
| 254 Returns: | |
| 255 A dict mapping a specified set of results to the builders that | |
| 256 obtained those results. The list is builders is represented as | |
| 257 a set and any bots in bot failures and successes set are removed | |
| 258 from failures | |
| 259 | |
| 260 Raises: | |
| 261 AttributeError: An unexpected result was found | |
| 262 """ | |
| 263 sets = {} | |
| 264 for line in results.splitlines(): | |
| 265 line.strip() | |
| 266 print line | |
| 267 if line[len(line) - 1] == ':': | |
| 268 result_type = line[:len(line) - 1] | |
| 269 sets[result_type] = set() | |
| 270 elif line.split()[0] == 'Total:': | |
| 271 break | |
| 272 else: | |
| 273 sets[result_type].add(line.split()[0]) | |
| 274 print sets | |
| 275 sets['Failures'] -= sets['Successes'] | |
| 276 sets['Started'] -= sets['Successes'] | |
| 277 sets['Started'] -= sets['Failures'] | |
| 278 return sets | |
| OLD | NEW |