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 POLL_DELAY_SECONDS = 300 | |
| 17 | |
| 15 | 18 |
| 16 class DepsUpdater(object): | 19 class DepsUpdater(object): |
| 17 | 20 |
| 18 def __init__(self, host): | 21 def __init__(self, host): |
| 19 self.host = host | 22 self.host = host |
| 20 self.executive = host.executive | 23 self.executive = host.executive |
| 21 self.fs = host.filesystem | 24 self.fs = host.filesystem |
| 22 self.finder = WebKitFinder(self.fs) | 25 self.finder = WebKitFinder(self.fs) |
| 23 self.verbose = False | 26 self.verbose = False |
| 24 self.allow_local_commits = False | 27 self.allow_local_commits = False |
| 25 self.keep_w3c_repos_around = False | 28 self.keep_w3c_repos_around = False |
| 26 self.target = None | 29 self.target = None |
| 30 self.auto_update = False | |
| 27 | 31 |
| 28 def main(self, argv=None): | 32 def main(self, argv=None): |
| 29 self.parse_args(argv) | 33 self.parse_args(argv) |
| 30 | 34 |
| 31 if not self.checkout_is_okay(): | 35 if not self.checkout_is_okay(): |
| 32 return 1 | 36 return 1 |
| 33 | 37 |
| 34 self.print_('## Noting the current Chromium commit.') | 38 self.print_('## Noting the current Chromium commit.') |
| 35 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) | 39 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) |
| 36 chromium_commitish = show_ref_output.split()[0] | 40 chromium_commitish = show_ref_output.split()[0] |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 53 | 57 |
| 54 elif self.target == 'css': | 58 elif self.target == 'css': |
| 55 import_commitish = self.update( | 59 import_commitish = self.update( |
| 56 CSS_DEST_NAME, | 60 CSS_DEST_NAME, |
| 57 'https://chromium.googlesource.com/external/w3c/csswg-test.git') | 61 'https://chromium.googlesource.com/external/w3c/csswg-test.git') |
| 58 else: | 62 else: |
| 59 raise AssertionError("Unsupported target %s" % self.target) | 63 raise AssertionError("Unsupported target %s" % self.target) |
| 60 | 64 |
| 61 self.commit_changes_if_needed(chromium_commitish, import_commitish) | 65 self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| 62 | 66 |
| 67 if self.auto_update: | |
| 68 self.run(['git', 'cl', 'upload', '-f']) | |
| 69 self.run(['git', 'cl', 'set-commit', '--dry-run']) | |
| 70 while True: | |
| 71 time.sleep(POLL_DELAY_SECONDS) | |
| 72 _, out = self.run(['git', 'cl', 'try-results']) | |
| 73 results = self.parse_try_job_results(out) | |
| 74 if results['Started'] != set([]) or results['Scheduled'] != set( []): | |
| 75 continue | |
| 76 if results['Failures'] != set([]): | |
|
qyearsley
2016/07/07 21:04:09
Note, this would be the same as if you changed it
| |
| 77 return 1 | |
| 78 break | |
| 79 self.run(['git', 'cl', 'land', '-f']) | |
|
qyearsley
2016/07/07 21:04:09
Possible other things to consider: if one of the c
| |
| 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 It's a dict mapping result type (e.g. Success, Failure) | |
|
qyearsley
2016/07/07 21:04:09
No need to include "It's" -- this can just be a no
| |
| 256 to list of bots with that result type. The list of builders | |
| 257 is represented as a set and any bots with both success and | |
| 258 failure results are not included in failures. | |
| 259 | |
| 260 | |
|
qyearsley
2016/07/07 21:04:09
Extra blank line can be removed.
| |
| 261 Raises: | |
| 262 AttributeError: An unexpected result was found. | |
| 263 """ | |
| 264 sets = {} | |
| 265 for line in results.splitlines(): | |
| 266 line = line.strip() | |
| 267 if line[-1] == ':': | |
| 268 result_type = 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 |