Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: PRESUBMIT.py

Issue 2135063003: Do not use the deprecated CQ_EXTRA_TRYBOTS (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 5
6 """Top-level presubmit script for Skia. 6 """Top-level presubmit script for Skia.
7 7
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
9 for more details about the presubmit API built into gcl. 9 for more details about the presubmit API built into gcl.
10 """ 10 """
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 output_api.PresubmitNotifyResult( 430 output_api.PresubmitNotifyResult(
431 'Trybots do not yet work for non-master branches. ' 431 'Trybots do not yet work for non-master branches. '
432 'Automatically added \'NOTRY=true\' to the CL\'s description')) 432 'Automatically added \'NOTRY=true\' to the CL\'s description'))
433 if not re.search( 433 if not re.search(
434 r'^NOPRESUBMIT=true$', new_description, re.M | re.I): 434 r'^NOPRESUBMIT=true$', new_description, re.M | re.I):
435 new_description += "\nNOPRESUBMIT=true" 435 new_description += "\nNOPRESUBMIT=true"
436 results.append( 436 results.append(
437 output_api.PresubmitNotifyResult( 437 output_api.PresubmitNotifyResult(
438 'Branch changes do not run the presubmit checks.')) 438 'Branch changes do not run the presubmit checks.'))
439 439
440 # Automatically set CQ_EXTRA_TRYBOTS if any of the changed files here begin 440 # Automatically set CQ_INCLUDE_TRYBOTS if any of the changed files here
441 # with the paths of interest. 441 # begin with the paths of interest.
442 cq_master_to_trybots = collections.defaultdict(set) 442 cq_master_to_trybots = collections.defaultdict(set)
443 for affected_file in change.AffectedFiles(): 443 for affected_file in change.AffectedFiles():
444 affected_file_path = affected_file.LocalPath() 444 affected_file_path = affected_file.LocalPath()
445 for path_prefix, extra_bots in PATH_PREFIX_TO_EXTRA_TRYBOTS.iteritems(): 445 for path_prefix, extra_bots in PATH_PREFIX_TO_EXTRA_TRYBOTS.iteritems():
446 if affected_file_path.startswith(path_prefix): 446 if affected_file_path.startswith(path_prefix):
447 results.append( 447 results.append(
448 output_api.PresubmitNotifyResult( 448 output_api.PresubmitNotifyResult(
449 'Your CL modifies the path %s.\nAutomatically adding %s to ' 449 'Your CL modifies the path %s.\nAutomatically adding %s to '
450 'the CL description.' % (affected_file_path, extra_bots))) 450 'the CL description.' % (affected_file_path, extra_bots)))
451 _MergeCQExtraTrybotsMaps( 451 _MergeCQExtraTrybotsMaps(
452 cq_master_to_trybots, _GetCQExtraTrybotsMap(extra_bots)) 452 cq_master_to_trybots, _GetCQExtraTrybotsMap(extra_bots))
453 if cq_master_to_trybots: 453 if cq_master_to_trybots:
454 new_description = _AddCQExtraTrybotsToDesc( 454 new_description = _AddCQExtraTrybotsToDesc(
455 cq_master_to_trybots, new_description) 455 cq_master_to_trybots, new_description)
456 456
457 # If the description has changed update it. 457 # If the description has changed update it.
458 if new_description != original_description: 458 if new_description != original_description:
459 rietveld_obj.update_description(issue, new_description) 459 rietveld_obj.update_description(issue, new_description)
460 460
461 return results 461 return results
462 462
463 463
464 def _AddCQExtraTrybotsToDesc(cq_master_to_trybots, description): 464 def _AddCQExtraTrybotsToDesc(cq_master_to_trybots, description):
465 """Adds the specified master and trybots to the CQ_EXTRA_TRYBOTS keyword. 465 """Adds the specified master and trybots to the CQ_INCLUDE_TRYBOTS keyword.
466 466
467 If the keyword already exists in the description then it appends to it only 467 If the keyword already exists in the description then it appends to it only
468 if the specified values do not already exist. 468 if the specified values do not already exist.
469 If the keyword does not exist then it creates a new section in the 469 If the keyword does not exist then it creates a new section in the
470 description. 470 description.
471 """ 471 """
472 match = re.search(r'^CQ_EXTRA_TRYBOTS=(.*)$', description, re.M | re.I) 472 match = re.search(r'^CQ_INCLUDE_TRYBOTS=(.*)$', description, re.M | re.I)
473 if match: 473 if match:
474 original_trybots_map = _GetCQExtraTrybotsMap(match.group(1)) 474 original_trybots_map = _GetCQExtraTrybotsMap(match.group(1))
475 _MergeCQExtraTrybotsMaps(cq_master_to_trybots, original_trybots_map) 475 _MergeCQExtraTrybotsMaps(cq_master_to_trybots, original_trybots_map)
476 new_description = description.replace( 476 new_description = description.replace(
477 match.group(0), _GetCQExtraTrybotsStr(cq_master_to_trybots)) 477 match.group(0), _GetCQExtraTrybotsStr(cq_master_to_trybots))
478 else: 478 else:
479 new_description = description + "\n%s" % ( 479 new_description = description + "\n%s" % (
480 _GetCQExtraTrybotsStr(cq_master_to_trybots)) 480 _GetCQExtraTrybotsStr(cq_master_to_trybots))
481 return new_description 481 return new_description
482 482
483 483
484 def _MergeCQExtraTrybotsMaps(dest_map, map_to_be_consumed): 484 def _MergeCQExtraTrybotsMaps(dest_map, map_to_be_consumed):
485 """Merges two maps of masters to trybots into one.""" 485 """Merges two maps of masters to trybots into one."""
486 for master, trybots in map_to_be_consumed.iteritems(): 486 for master, trybots in map_to_be_consumed.iteritems():
487 dest_map[master].update(trybots) 487 dest_map[master].update(trybots)
488 return dest_map 488 return dest_map
489 489
490 490
491 def _GetCQExtraTrybotsMap(cq_extra_trybots_str): 491 def _GetCQExtraTrybotsMap(cq_extra_trybots_str):
492 """Parses the CQ_EXTRA_TRYBOTS str and returns a map of masters to trybots.""" 492 """Parses CQ_INCLUDE_TRYBOTS str and returns a map of masters to trybots."""
493 cq_master_to_trybots = collections.defaultdict(set) 493 cq_master_to_trybots = collections.defaultdict(set)
494 for section in cq_extra_trybots_str.split(';'): 494 for section in cq_extra_trybots_str.split(';'):
495 if section: 495 if section:
496 master, bots = section.split(':') 496 master, bots = section.split(':')
497 cq_master_to_trybots[master].update(bots.split(',')) 497 cq_master_to_trybots[master].update(bots.split(','))
498 return cq_master_to_trybots 498 return cq_master_to_trybots
499 499
500 500
501 def _GetCQExtraTrybotsStr(cq_master_to_trybots): 501 def _GetCQExtraTrybotsStr(cq_master_to_trybots):
502 """Constructs the CQ_EXTRA_TRYBOTS str from a map of masters to trybots.""" 502 """Constructs the CQ_INCLUDE_TRYBOTS str from a map of masters to trybots."""
503 sections = [] 503 sections = []
504 for master, trybots in cq_master_to_trybots.iteritems(): 504 for master, trybots in cq_master_to_trybots.iteritems():
505 sections.append('%s:%s' % (master, ','.join(trybots))) 505 sections.append('%s:%s' % (master, ','.join(trybots)))
506 return 'CQ_EXTRA_TRYBOTS=%s' % ';'.join(sections) 506 return 'CQ_INCLUDE_TRYBOTS=%s' % ';'.join(sections)
507 507
508 508
509 def CheckChangeOnCommit(input_api, output_api): 509 def CheckChangeOnCommit(input_api, output_api):
510 """Presubmit checks for the change on commit. 510 """Presubmit checks for the change on commit.
511 511
512 The following are the presubmit checks: 512 The following are the presubmit checks:
513 * Check change has one and only one EOL. 513 * Check change has one and only one EOL.
514 * Ensures that the Skia tree is open in 514 * Ensures that the Skia tree is open in
515 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' 515 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution'
516 state and an error if it is in 'Closed' state. 516 state and an error if it is in 'Closed' state.
517 """ 517 """
518 results = [] 518 results = []
519 results.extend(_CommonChecks(input_api, output_api)) 519 results.extend(_CommonChecks(input_api, output_api))
520 results.extend( 520 results.extend(
521 _CheckTreeStatus(input_api, output_api, json_url=( 521 _CheckTreeStatus(input_api, output_api, json_url=(
522 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) 522 SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
523 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) 523 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
524 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) 524 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api))
525 return results 525 return results
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698