| 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 json |
| 8 import time | 9 import time |
| 9 | 10 |
| 10 from webkitpy.common.webkit_finder import WebKitFinder | 11 from webkitpy.common.webkit_finder import WebKitFinder |
| 11 | 12 |
| 12 # Import destination directories (under LayoutTests/imported/). | 13 # Import destination directories (under LayoutTests/imported/). |
| 13 WPT_DEST_NAME = 'wpt' | 14 WPT_DEST_NAME = 'wpt' |
| 14 CSS_DEST_NAME = 'csswg-test' | 15 CSS_DEST_NAME = 'csswg-test' |
| 15 | 16 |
| 16 POLL_DELAY_SECONDS = 300 | 17 POLL_DELAY_SECONDS = 300 |
| 17 | 18 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 elif self.target == 'css': | 59 elif self.target == 'css': |
| 59 import_commitish = self.update( | 60 import_commitish = self.update( |
| 60 CSS_DEST_NAME, | 61 CSS_DEST_NAME, |
| 61 'https://chromium.googlesource.com/external/w3c/csswg-test.git') | 62 'https://chromium.googlesource.com/external/w3c/csswg-test.git') |
| 62 else: | 63 else: |
| 63 raise AssertionError("Unsupported target %s" % self.target) | 64 raise AssertionError("Unsupported target %s" % self.target) |
| 64 | 65 |
| 65 self.commit_changes_if_needed(chromium_commitish, import_commitish) | 66 self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| 66 if self.auto_update: | 67 if self.auto_update: |
| 67 try_bots = self.host.builders.all_try_builder_names() | 68 try_bots = self.host.builders.all_try_builder_names() |
| 69 data_file_path = self.finder.path_from_webkit_base('Tools', 'Scripts
', 'webkitpy', 'w3c', 'directory_owners.json') |
| 70 with open(data_file_path) as data_file: |
| 71 directory_dict = self.parse_directory_owners(json.load(data_file
)) |
| 72 self.print_('## Gathering directory owners email to CC') |
| 73 _, out = self.run(['git', 'diff', 'master', '--name-only']) |
| 74 email_list = self.generate_email_list(out, directory_dict) |
| 68 self.print_('## Uploading change list.') | 75 self.print_('## Uploading change list.') |
| 69 self.check_run(['git', 'cl', 'upload', '-f', '-m', 'W3C auto test im
porter']) | 76 self.check_run(['git', 'cl', 'upload', '-f', '-m', 'W3C auto test im
porter'] + ['--cc' + email for email in email_list]) |
| 70 self.print_('## Triggering try jobs.') | 77 self.print_('## Triggering try jobs.') |
| 71 for try_bot in try_bots: | 78 for try_bot in try_bots: |
| 72 self.run(['git', 'cl', 'try', '-b', try_bot]) | 79 self.run(['git', 'cl', 'try', '-b', try_bot]) |
| 73 self.print_('## Waiting for Try Job Results') | 80 self.print_('## Waiting for Try Job Results') |
| 74 has_failing_results = False | 81 has_failing_results = False |
| 75 while True: | 82 while True: |
| 76 time.sleep(POLL_DELAY_SECONDS) | 83 time.sleep(POLL_DELAY_SECONDS) |
| 77 _, out = self.run(['git', 'cl', 'try-results']) | 84 _, out = self.run(['git', 'cl', 'try-results']) |
| 78 results = self.parse_try_job_results(out) | 85 results = self.parse_try_job_results(out) |
| 79 if results.get('Started') or results.get('Scheduled'): | 86 if results.get('Started') or results.get('Scheduled'): |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 line = line.strip() | 297 line = line.strip() |
| 291 if line[-1] == ':': | 298 if line[-1] == ':': |
| 292 result_type = line[:-1] | 299 result_type = line[:-1] |
| 293 sets[result_type] = set() | 300 sets[result_type] = set() |
| 294 elif line.split()[0] == 'Total:': | 301 elif line.split()[0] == 'Total:': |
| 295 break | 302 break |
| 296 else: | 303 else: |
| 297 sets[result_type].add(line.split()[0]) | 304 sets[result_type].add(line.split()[0]) |
| 298 return sets | 305 return sets |
| 299 | 306 |
| 307 def generate_email_list(self, changed_files, directory_dict): |
| 308 """Generates a list of emails to be cc'd for current import. |
| 309 |
| 310 Takes output from git diff master --name-only and gets the |
| 311 directories and generates list of contact emails. |
| 312 |
| 313 Args: |
| 314 changed_files: A string with newline-separated file paths relative |
| 315 to the repository root. |
| 316 directory_dict: A mapping of directories in the LayoutTests/imported |
| 317 folder to the email address of the point of contact. |
| 318 |
| 319 Returns: |
| 320 A list of the email addresses to be notified for the current |
| 321 import. |
| 322 """ |
| 323 email_list = [] |
| 324 directories = set() |
| 325 for line in changed_files.splitlines(): |
| 326 layout_tests_relative_path = self.fs.relpath(self.finder.layout_test
s_dir(), self.finder.chromium_base()) |
| 327 test_path = self.fs.relpath(line, layout_tests_relative_path) |
| 328 test_path = self.fs.dirname(test_path) |
| 329 test_path = test_path.strip('../') |
| 330 if test_path in directory_dict and test_path not in directories: |
| 331 email_list.append(directory_dict[test_path]) |
| 332 directories.add(test_path) |
| 333 return email_list |
| 334 |
| 300 def check_run(self, command): | 335 def check_run(self, command): |
| 301 return_code, out = self.run(command) | 336 return_code, out = self.run(command) |
| 302 if return_code: | 337 if return_code: |
| 303 raise Exception('%s failed with exit code %d.' % ' '.join(command),
return_code) | 338 raise Exception('%s failed with exit code %d.' % ' '.join(command),
return_code) |
| 304 return out | 339 return out |
| 340 |
| 341 @staticmethod |
| 342 def parse_directory_owners(decoded_data_file): |
| 343 directory_dict = {} |
| 344 for dict_set in decoded_data_file: |
| 345 if dict_set['notification-email']: |
| 346 directory_dict[dict_set['directory']] = dict_set['notification-e
mail'] |
| 347 return directory_dict |
| OLD | NEW |