| 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 | |
| 13 import sys | 12 import sys |
| 14 | 13 |
| 15 | 14 |
| 16 def _CommonChecks(input_api, output_api): | 15 def _CommonChecks(input_api, output_api): |
| 17 """Performs common checks, which includes running pylint.""" | 16 """Performs common checks, which includes running pylint.""" |
| 18 results = [] | 17 results = [] |
| 19 | 18 |
| 20 results.extend(_CheckWprShaFiles(input_api, output_api)) | 19 results.extend(_CheckWprShaFiles(input_api, output_api)) |
| 21 results.extend(_CheckJson(input_api, output_api)) | 20 results.extend(_CheckJson(input_api, output_api)) |
| 22 results.extend(input_api.RunTests(input_api.canned_checks.GetPylint( | 21 results.extend(input_api.RunTests(input_api.canned_checks.GetPylint( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 def CheckChangeOnUpload(input_api, output_api): | 88 def CheckChangeOnUpload(input_api, output_api): |
| 90 report = [] | 89 report = [] |
| 91 report.extend(_CommonChecks(input_api, output_api)) | 90 report.extend(_CommonChecks(input_api, output_api)) |
| 92 return report | 91 return report |
| 93 | 92 |
| 94 | 93 |
| 95 def CheckChangeOnCommit(input_api, output_api): | 94 def CheckChangeOnCommit(input_api, output_api): |
| 96 report = [] | 95 report = [] |
| 97 report.extend(_CommonChecks(input_api, output_api)) | 96 report.extend(_CommonChecks(input_api, output_api)) |
| 98 return report | 97 return report |
| 99 | |
| 100 | |
| 101 def _AreBenchmarksModified(change): | |
| 102 """Checks whether CL contains any modification to Telemetry benchmarks.""" | |
| 103 for affected_file in change.AffectedFiles(): | |
| 104 file_path = affected_file.LocalPath() | |
| 105 # Changes to unittest files should not count. | |
| 106 if file_path.endswith('test.py'): | |
| 107 continue | |
| 108 if (os.path.join('tools', 'perf', 'benchmarks') in file_path or | |
| 109 os.path.join('tools', 'perf', 'measurements') in file_path): | |
| 110 return True | |
| 111 return False | |
| 112 | |
| 113 | |
| 114 def PostUploadHook(cl, change, output_api): | |
| 115 """git cl upload will call this hook after the issue is created/modified. | |
| 116 | |
| 117 This hook adds extra try bots list to the CL description in order to run | |
| 118 Telemetry benchmarks on Perf trybots in addition to CQ trybots if the CL | |
| 119 contains any changes to Telemetry benchmarks. | |
| 120 """ | |
| 121 benchmarks_modified = _AreBenchmarksModified(change) | |
| 122 rietveld_obj = cl.RpcServer() | |
| 123 issue = cl.issue | |
| 124 original_description = rietveld_obj.get_description(issue) | |
| 125 if not benchmarks_modified or re.search( | |
| 126 r'^CQ_INCLUDE_TRYBOTS=.*', original_description, re.M | re.I): | |
| 127 return [] | |
| 128 | |
| 129 results = [] | |
| 130 bots = [ | |
| 131 'linux_perf_cq', | |
| 132 'mac_retina_perf_cq', | |
| 133 'winx64_10_perf_cq' | |
| 134 ] | |
| 135 bots = ['master.tryserver.chromium.perf:%s' % s for s in bots] | |
| 136 bots_string = ';'.join(bots) | |
| 137 description = original_description | |
| 138 description += '\nCQ_INCLUDE_TRYBOTS=%s' % bots_string | |
| 139 results.append(output_api.PresubmitNotifyResult( | |
| 140 'Automatically added Perf trybots to run Telemetry benchmarks on CQ.')) | |
| 141 | |
| 142 if description != original_description: | |
| 143 rietveld_obj.update_description(issue, description) | |
| 144 | |
| 145 return results | |
| OLD | NEW |