Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 """Presubmit script for changes affecting tools/perf/. | 5 """Presubmit script for changes affecting tools/perf/. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import os | 11 import os |
| 12 import re | |
| 12 import sys | 13 import sys |
| 13 | 14 |
| 14 PYLINT_BLACKLIST = [] | 15 PYLINT_BLACKLIST = [] |
| 15 PYLINT_DISABLED_WARNINGS = [ | 16 PYLINT_DISABLED_WARNINGS = [ |
| 16 'R0923', # Interface not implemented | 17 'R0923', # Interface not implemented |
| 17 'R0201', # Method could be a function | 18 'R0201', # Method could be a function |
| 18 'E1101', # Non-existent member is accessed. | 19 'E1101', # Non-existent member is accessed. |
| 19 ] | 20 ] |
| 20 | 21 |
| 21 | 22 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 def CheckChangeOnUpload(input_api, output_api): | 79 def CheckChangeOnUpload(input_api, output_api): |
| 79 report = [] | 80 report = [] |
| 80 report.extend(_CommonChecks(input_api, output_api)) | 81 report.extend(_CommonChecks(input_api, output_api)) |
| 81 return report | 82 return report |
| 82 | 83 |
| 83 | 84 |
| 84 def CheckChangeOnCommit(input_api, output_api): | 85 def CheckChangeOnCommit(input_api, output_api): |
| 85 report = [] | 86 report = [] |
| 86 report.extend(_CommonChecks(input_api, output_api)) | 87 report.extend(_CommonChecks(input_api, output_api)) |
| 87 return report | 88 return report |
| 89 | |
| 90 | |
| 91 def _IsBenchmarksModified(change_list): | |
|
qyearsley
2015/04/08 00:07:13
Should the argument be called change or change_lis
prasadv
2015/04/08 00:15:48
Done.
| |
| 92 """Checks whether CL contains any modification to Telemetry benchmarks.""" | |
| 93 for affected_file in change_list.AffectedFiles(): | |
| 94 affected_file_path = affected_file.LocalPath() | |
| 95 file_path, _ = os.path.splitext(affected_file_path) | |
| 96 if (os.path.join('tools', 'perf', 'benchmarks') in file_path or | |
| 97 os.path.join('tools', 'perf', 'measurements') in file_path): | |
| 98 return True | |
| 99 return False | |
| 100 | |
| 101 | |
| 102 def PostUploadHook(cl, change, output_api): | |
| 103 """git cl upload will call this hook after the issue is created/modified. | |
| 104 | |
| 105 This hook adds extra try bots list to the CL description in order to run | |
| 106 Telemetry benchmarks on Perf trybots in addtion to CQ trybots if the CL | |
| 107 contains any changes to Telemetry benchmarks. | |
| 108 """ | |
| 109 benchmarks_modified = _IsBenchmarksModified(change) | |
| 110 rietveld_obj = cl.RpcServer() | |
| 111 issue = cl.issue | |
| 112 original_description = rietveld_obj.get_description(issue) | |
| 113 if not benchmarks_modified or re.search( | |
| 114 r'^CQ_EXTRA_TRYBOTS=.*', original_description, re.M | re.I): | |
| 115 return [] | |
| 116 | |
| 117 results = [] | |
| 118 bots = [ | |
| 119 'linux_perf_bisect', | |
| 120 'mac_perf_bisect', | |
| 121 'win_perf_bisect', | |
| 122 'android_nexus5_perf_bisect' | |
| 123 ] | |
| 124 bots = ['tryserver.chromium.perf:%s' % s for s in bots] | |
| 125 bots_string = ';'.join(bots) | |
| 126 description = original_description | |
| 127 description += '\nCQ_EXTRA_TRYBOTS=%s' % bots_string | |
| 128 results.append(output_api.PresubmitNotifyResult( | |
| 129 'Automatically added Perf trybots to run Telemetry benchmarks on CQ.')) | |
| 130 | |
| 131 if description != original_description: | |
| 132 rietveld_obj.update_description(issue, description) | |
| 133 | |
| 134 return results | |
| OLD | NEW |