blob: 3ceb67016a293556a551b7c00f4038673c8c5159 [file] [log] [blame]
andrew@webrtc.org2442de12012-01-23 17:45:411# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
niklase@google.comda159d62011-05-30 11:51:348
kjellander986ee082015-06-16 11:32:139import json
kjellander@webrtc.orgaefe61a2014-12-08 13:00:3010import os
kjellander986ee082015-06-16 11:32:1311import platform
kjellander@webrtc.org85759802013-10-22 16:47:4012import re
kjellander986ee082015-06-16 11:32:1313import subprocess
kjellander@webrtc.org3bd41562014-09-01 11:06:3714import sys
kjellander@webrtc.org85759802013-10-22 16:47:4015
16
kjellander@webrtc.org0fcaf992015-11-26 14:24:5217# Directories that will be scanned by cpplint by the presubmit script.
18CPPLINT_DIRS = [
Fredrik Solenbergea073732015-12-01 10:26:3419 'webrtc/audio',
20 'webrtc/call',
kjellander@webrtc.org0fcaf992015-11-26 14:24:5221 'webrtc/video_engine',
22]
23
kjellanderfd595232015-12-04 10:44:0924# List of directories of "supported" native APIs. That means changes to headers
25# will be done in a compatible way following this scheme:
26# 1. Non-breaking changes are made.
27# 2. The old APIs as marked as deprecated (with comments).
28# 3. Deprecation is announced to discuss-webrtc@googlegroups.com and
29# webrtc-users@google.com (internal list).
30# 4. (later) The deprecated APIs are removed.
31# Directories marked as DEPRECATED should not be used. They're only present in
32# the list to support legacy downstream code.
kjellander53047c92015-12-03 07:56:1433NATIVE_API_DIRS = (
34 'talk/app/webrtc',
35 'webrtc',
kjellanderfd595232015-12-04 10:44:0936 'webrtc/base', # DEPRECATED.
37 'webrtc/common_audio/include', # DEPRECATED.
kjellander53047c92015-12-03 07:56:1438 'webrtc/modules/audio_coding/include',
kjellanderfd595232015-12-04 10:44:0939 'webrtc/modules/audio_conference_mixer/include', # DEPRECATED.
kjellander53047c92015-12-03 07:56:1440 'webrtc/modules/audio_device/include',
41 'webrtc/modules/audio_processing/include',
42 'webrtc/modules/bitrate_controller/include',
43 'webrtc/modules/include',
44 'webrtc/modules/remote_bitrate_estimator/include',
45 'webrtc/modules/rtp_rtcp/include',
kjellanderfd595232015-12-04 10:44:0946 'webrtc/modules/rtp_rtcp/source', # DEPRECATED.
kjellander53047c92015-12-03 07:56:1447 'webrtc/modules/utility/include',
48 'webrtc/modules/video_coding/codecs/h264/include',
49 'webrtc/modules/video_coding/codecs/i420/include',
50 'webrtc/modules/video_coding/codecs/vp8/include',
51 'webrtc/modules/video_coding/codecs/vp9/include',
52 'webrtc/modules/video_coding/include',
kjellanderfd595232015-12-04 10:44:0953 'webrtc/system_wrappers/include', # DEPRECATED.
kjellander53047c92015-12-03 07:56:1454 'webrtc/voice_engine/include',
55)
56
57
58def _VerifyNativeApiHeadersListIsValid(input_api, output_api):
59 """Ensures the list of native API header directories is up to date."""
60 non_existing_paths = []
61 native_api_full_paths = [
62 input_api.os_path.join(input_api.PresubmitLocalPath(),
63 *path.split('/')) for path in NATIVE_API_DIRS]
64 for path in native_api_full_paths:
65 if not os.path.isdir(path):
66 non_existing_paths.append(path)
67 if non_existing_paths:
68 return [output_api.PresubmitError(
69 'Directories to native API headers have changed which has made the '
70 'list in PRESUBMIT.py outdated.\nPlease update it to the current '
71 'location of our native APIs.',
72 non_existing_paths)]
73 return []
74
75
76def _CheckNativeApiHeaderChanges(input_api, output_api):
77 """Checks to remind proper changing of native APIs."""
78 files = []
79 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
80 if f.LocalPath().endswith('.h'):
81 for path in NATIVE_API_DIRS:
82 if os.path.dirname(f.LocalPath()) == path:
83 files.append(f)
84
85 if files:
86 return [output_api.PresubmitPromptWarning(
87 'You seem to be changing native API header files. Please make sure '
88 'you:\n'
89 ' 1. Make compatible changes that don\'t break existing clients.\n'
90 ' 2. Mark the old APIs as deprecated.\n'
91 ' 3. Create a timeline and plan for when the deprecated method will '
92 'be removed (preferably 3 months or so).\n'
93 ' 4. Update/inform existing downstream code owners to stop using the '
94 'deprecated APIs: \n'
95 'send announcement to discuss-webrtc@googlegroups.com and '
96 'webrtc-users@google.com.\n'
97 ' 5. (after ~3 months) remove the deprecated API.\n'
98 'Related files:',
99 files)]
100 return []
101
kjellander@webrtc.org0fcaf992015-11-26 14:24:52102
kjellander@webrtc.org51198f12012-02-21 17:53:46103def _CheckNoIOStreamInHeaders(input_api, output_api):
104 """Checks to make sure no .h files include <iostream>."""
105 files = []
106 pattern = input_api.re.compile(r'^#include\s*<iostream>',
107 input_api.re.MULTILINE)
108 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
109 if not f.LocalPath().endswith('.h'):
110 continue
111 contents = input_api.ReadFile(f)
112 if pattern.search(contents):
113 files.append(f)
114
115 if len(files):
Henrik Kjellander57e5fd22015-05-25 10:55:39116 return [output_api.PresubmitError(
kjellander@webrtc.org51198f12012-02-21 17:53:46117 'Do not #include <iostream> in header files, since it inserts static ' +
118 'initialization into every file including the header. Instead, ' +
119 '#include <ostream>. See http://crbug.com/94794',
Henrik Kjellander57e5fd22015-05-25 10:55:39120 files)]
kjellander@webrtc.org51198f12012-02-21 17:53:46121 return []
122
kjellander@webrtc.orge4158642014-08-06 09:11:18123
kjellander@webrtc.org51198f12012-02-21 17:53:46124def _CheckNoFRIEND_TEST(input_api, output_api):
125 """Make sure that gtest's FRIEND_TEST() macro is not used, the
126 FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be
127 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes."""
128 problems = []
129
130 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h'))
131 for f in input_api.AffectedFiles(file_filter=file_filter):
132 for line_num, line in f.ChangedContents():
133 if 'FRIEND_TEST(' in line:
134 problems.append(' %s:%d' % (f.LocalPath(), line_num))
135
136 if not problems:
137 return []
138 return [output_api.PresubmitPromptWarning('WebRTC\'s code should not use '
139 'gtest\'s FRIEND_TEST() macro. Include testsupport/gtest_prod_util.h and '
140 'use FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))]
141
kjellander@webrtc.orge4158642014-08-06 09:11:18142
kjellander@webrtc.org0fcaf992015-11-26 14:24:52143def _IsLintWhitelisted(whitelist_dirs, file_path):
144 """ Checks if a file is whitelisted for lint check."""
145 for path in whitelist_dirs:
146 if os.path.dirname(file_path).startswith(path):
147 return True
148 return False
149
150
mflodman@webrtc.org2a452092012-07-01 05:55:23151def _CheckApprovedFilesLintClean(input_api, output_api,
152 source_file_filter=None):
153 """Checks that all new or whitelisted .cc and .h files pass cpplint.py.
kjellander@webrtc.org51198f12012-02-21 17:53:46154 This check is based on _CheckChangeLintsClean in
155 depot_tools/presubmit_canned_checks.py but has less filters and only checks
156 added files."""
157 result = []
158
159 # Initialize cpplint.
160 import cpplint
161 # Access to a protected member _XX of a client class
162 # pylint: disable=W0212
163 cpplint._cpplint_state.ResetErrorCounts()
164
kjellander@webrtc.org0fcaf992015-11-26 14:24:52165 # Create a platform independent whitelist for the CPPLINT_DIRS.
166 whitelist_dirs = [input_api.os_path.join(*path.split('/'))
167 for path in CPPLINT_DIRS]
168
kjellander@webrtc.org51198f12012-02-21 17:53:46169 # Use the strictest verbosity level for cpplint.py (level 1) which is the
170 # default when running cpplint.py from command line.
171 # To make it possible to work with not-yet-converted code, we're only applying
mflodman@webrtc.org2a452092012-07-01 05:55:23172 # it to new (or moved/renamed) files and files listed in LINT_FOLDERS.
kjellander@webrtc.org51198f12012-02-21 17:53:46173 verbosity_level = 1
174 files = []
175 for f in input_api.AffectedSourceFiles(source_file_filter):
Henrik Kjellander57e5fd22015-05-25 10:55:39176 # Note that moved/renamed files also count as added.
kjellander@webrtc.org0fcaf992015-11-26 14:24:52177 if f.Action() == 'A' or _IsLintWhitelisted(whitelist_dirs, f.LocalPath()):
kjellander@webrtc.org51198f12012-02-21 17:53:46178 files.append(f.AbsoluteLocalPath())
mflodman@webrtc.org2a452092012-07-01 05:55:23179
kjellander@webrtc.org51198f12012-02-21 17:53:46180 for file_name in files:
181 cpplint.ProcessFile(file_name, verbosity_level)
182
183 if cpplint._cpplint_state.error_count > 0:
184 if input_api.is_committing:
185 # TODO(kjellander): Change back to PresubmitError below when we're
186 # confident with the lint settings.
187 res_type = output_api.PresubmitPromptWarning
188 else:
189 res_type = output_api.PresubmitPromptWarning
190 result = [res_type('Changelist failed cpplint.py check.')]
191
192 return result
193
henrike@webrtc.org83fe69d2014-09-30 21:54:26194def _CheckNoRtcBaseDeps(input_api, gyp_files, output_api):
195 pattern = input_api.re.compile(r"base.gyp:rtc_base\s*'")
196 violating_files = []
197 for f in gyp_files:
henrike@webrtc.org36b0c1a2014-10-01 14:40:58198 gyp_exceptions = (
199 'base_tests.gyp',
200 'desktop_capture.gypi',
201 'libjingle.gyp',
henrike@webrtc.org28af6412014-11-04 15:11:46202 'libjingle_tests.gyp',
kjellander@webrtc.orge7237282015-02-26 11:12:17203 'p2p.gyp',
henrike@webrtc.org36b0c1a2014-10-01 14:40:58204 'sound.gyp',
205 'webrtc_test_common.gyp',
206 'webrtc_tests.gypi',
207 )
208 if f.LocalPath().endswith(gyp_exceptions):
209 continue
henrike@webrtc.org83fe69d2014-09-30 21:54:26210 contents = input_api.ReadFile(f)
211 if pattern.search(contents):
212 violating_files.append(f)
213 if violating_files:
214 return [output_api.PresubmitError(
215 'Depending on rtc_base is not allowed. Change your dependency to '
216 'rtc_base_approved and possibly sanitize and move the desired source '
217 'file(s) to rtc_base_approved.\nChanged GYP files:',
218 items=violating_files)]
219 return []
kjellander@webrtc.orge4158642014-08-06 09:11:18220
kjellander@webrtc.orgf68ffca2015-01-27 13:13:24221def _CheckNoSourcesAboveGyp(input_api, gyp_files, output_api):
222 # Disallow referencing source files with paths above the GYP file location.
223 source_pattern = input_api.re.compile(r'sources.*?\[(.*?)\]',
224 re.MULTILINE | re.DOTALL)
kjellander@webrtc.orga33f05e2015-01-29 14:29:45225 file_pattern = input_api.re.compile(r"'((\.\./.*?)|(<\(webrtc_root\).*?))'")
kjellander@webrtc.orgf68ffca2015-01-27 13:13:24226 violating_gyp_files = set()
227 violating_source_entries = []
228 for gyp_file in gyp_files:
229 contents = input_api.ReadFile(gyp_file)
230 for source_block_match in source_pattern.finditer(contents):
kjellander@webrtc.orgc98f6f32015-03-04 07:08:11231 # Find all source list entries starting with ../ in the source block
232 # (exclude overrides entries).
kjellander@webrtc.orgf68ffca2015-01-27 13:13:24233 for file_list_match in file_pattern.finditer(source_block_match.group(0)):
kjellander@webrtc.orgc98f6f32015-03-04 07:08:11234 source_file = file_list_match.group(0)
235 if 'overrides/' not in source_file:
236 violating_source_entries.append(source_file)
237 violating_gyp_files.add(gyp_file)
kjellander@webrtc.orgf68ffca2015-01-27 13:13:24238 if violating_gyp_files:
239 return [output_api.PresubmitError(
240 'Referencing source files above the directory of the GYP file is not '
241 'allowed. Please introduce new GYP targets and/or GYP files in the '
242 'proper location instead.\n'
243 'Invalid source entries:\n'
244 '%s\n'
245 'Violating GYP files:' % '\n'.join(violating_source_entries),
246 items=violating_gyp_files)]
247 return []
248
kjellander@webrtc.orge4158642014-08-06 09:11:18249def _CheckGypChanges(input_api, output_api):
250 source_file_filter = lambda x: input_api.FilterSourceFile(
251 x, white_list=(r'.+\.(gyp|gypi)$',))
252
253 gyp_files = []
254 for f in input_api.AffectedSourceFiles(source_file_filter):
kjellander@webrtc.org3398a4a2014-11-24 10:05:37255 if f.LocalPath().startswith('webrtc'):
256 gyp_files.append(f)
kjellander@webrtc.orge4158642014-08-06 09:11:18257
258 result = []
259 if gyp_files:
260 result.append(output_api.PresubmitNotifyResult(
261 'As you\'re changing GYP files: please make sure corresponding '
262 'BUILD.gn files are also updated.\nChanged GYP files:',
263 items=gyp_files))
henrike@webrtc.org83fe69d2014-09-30 21:54:26264 result.extend(_CheckNoRtcBaseDeps(input_api, gyp_files, output_api))
kjellander@webrtc.orgf68ffca2015-01-27 13:13:24265 result.extend(_CheckNoSourcesAboveGyp(input_api, gyp_files, output_api))
kjellander@webrtc.orge4158642014-08-06 09:11:18266 return result
267
kjellander@webrtc.org3bd41562014-09-01 11:06:37268def _CheckUnwantedDependencies(input_api, output_api):
269 """Runs checkdeps on #include statements added in this
270 change. Breaking - rules is an error, breaking ! rules is a
271 warning.
272 """
273 # Copied from Chromium's src/PRESUBMIT.py.
274
275 # We need to wait until we have an input_api object and use this
276 # roundabout construct to import checkdeps because this file is
277 # eval-ed and thus doesn't have __file__.
278 original_sys_path = sys.path
279 try:
kjellander@webrtc.orgaefe61a2014-12-08 13:00:30280 checkdeps_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
281 'buildtools', 'checkdeps')
282 if not os.path.exists(checkdeps_path):
283 return [output_api.PresubmitError(
284 'Cannot find checkdeps at %s\nHave you run "gclient sync" to '
285 'download Chromium and setup the symlinks?' % checkdeps_path)]
286 sys.path.append(checkdeps_path)
kjellander@webrtc.org3bd41562014-09-01 11:06:37287 import checkdeps
288 from cpp_checker import CppChecker
289 from rules import Rule
290 finally:
291 # Restore sys.path to what it was before.
292 sys.path = original_sys_path
293
294 added_includes = []
295 for f in input_api.AffectedFiles():
296 if not CppChecker.IsCppFile(f.LocalPath()):
297 continue
298
Henrik Kjellander57e5fd22015-05-25 10:55:39299 changed_lines = [line for _, line in f.ChangedContents()]
kjellander@webrtc.org3bd41562014-09-01 11:06:37300 added_includes.append([f.LocalPath(), changed_lines])
301
302 deps_checker = checkdeps.DepsChecker(input_api.PresubmitLocalPath())
303
304 error_descriptions = []
305 warning_descriptions = []
306 for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes(
307 added_includes):
308 description_with_path = '%s\n %s' % (path, rule_description)
309 if rule_type == Rule.DISALLOW:
310 error_descriptions.append(description_with_path)
311 else:
312 warning_descriptions.append(description_with_path)
313
314 results = []
315 if error_descriptions:
316 results.append(output_api.PresubmitError(
317 'You added one or more #includes that violate checkdeps rules.',
318 error_descriptions))
319 if warning_descriptions:
320 results.append(output_api.PresubmitPromptOrNotify(
321 'You added one or more #includes of files that are temporarily\n'
322 'allowed but being removed. Can you avoid introducing the\n'
323 '#include? See relevant DEPS file(s) for details and contacts.',
324 warning_descriptions))
325 return results
326
kjellander@webrtc.orge4158642014-08-06 09:11:18327
Henrik Kjellander8d3ad822015-05-26 17:52:05328def _RunPythonTests(input_api, output_api):
329 def join(*args):
330 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
331
332 test_directories = [
333 join('tools', 'autoroller', 'unittests'),
334 ]
335
336 tests = []
337 for directory in test_directories:
338 tests.extend(
339 input_api.canned_checks.GetUnitTestsInDirectory(
340 input_api,
341 output_api,
342 directory,
343 whitelist=[r'.+_test\.py$']))
344 return input_api.RunTests(tests, parallel=True)
345
346
andrew@webrtc.org53df1362012-01-26 21:24:23347def _CommonChecks(input_api, output_api):
348 """Checks common to both upload and commit."""
niklase@google.comda159d62011-05-30 11:51:34349 results = []
tkchin42f580e2015-11-27 07:18:23350 # Filter out files that are in objc or ios dirs from being cpplint-ed since
351 # they do not follow C++ lint rules.
352 black_list = input_api.DEFAULT_BLACK_LIST + (
353 r".*\bobjc[\\\/].*",
354 )
355 source_file_filter = lambda x: input_api.FilterSourceFile(x, None, black_list)
356 results.extend(_CheckApprovedFilesLintClean(
357 input_api, output_api, source_file_filter))
phoglund@webrtc.org5d3713932013-03-07 09:59:43358 results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
359 black_list=(r'^.*gviz_api\.py$',
360 r'^.*gaeunit\.py$',
fischman@webrtc.org33584f92013-07-25 16:43:30361 # Embedded shell-script fakes out pylint.
Henrik Kjellander14771ac2015-06-02 11:10:04362 r'^build[\\\/].*\.py$',
363 r'^buildtools[\\\/].*\.py$',
364 r'^chromium[\\\/].*\.py$',
365 r'^google_apis[\\\/].*\.py$',
366 r'^net.*[\\\/].*\.py$',
367 r'^out.*[\\\/].*\.py$',
368 r'^testing[\\\/].*\.py$',
369 r'^third_party[\\\/].*\.py$',
370 r'^tools[\\\/]find_depot_tools.py$',
371 r'^tools[\\\/]clang[\\\/].*\.py$',
372 r'^tools[\\\/]generate_library_loader[\\\/].*\.py$',
373 r'^tools[\\\/]gn[\\\/].*\.py$',
374 r'^tools[\\\/]gyp[\\\/].*\.py$',
Henrik Kjellanderd6d27e72015-09-25 20:19:11375 r'^tools[\\\/]isolate_driver.py$',
Henrik Kjellander14771ac2015-06-02 11:10:04376 r'^tools[\\\/]protoc_wrapper[\\\/].*\.py$',
377 r'^tools[\\\/]python[\\\/].*\.py$',
378 r'^tools[\\\/]python_charts[\\\/]data[\\\/].*\.py$',
379 r'^tools[\\\/]refactoring[\\\/].*\.py$',
380 r'^tools[\\\/]swarming_client[\\\/].*\.py$',
381 r'^tools[\\\/]vim[\\\/].*\.py$',
phoglund@webrtc.org5d3713932013-03-07 09:59:43382 # TODO(phoglund): should arguably be checked.
Henrik Kjellander14771ac2015-06-02 11:10:04383 r'^tools[\\\/]valgrind-webrtc[\\\/].*\.py$',
384 r'^tools[\\\/]valgrind[\\\/].*\.py$',
385 r'^tools[\\\/]win[\\\/].*\.py$',
386 r'^xcodebuild.*[\\\/].*\.py$',),
phoglund@webrtc.org5d3713932013-03-07 09:59:43387 disabled_warnings=['F0401', # Failed to import x
388 'E0611', # No package y in x
389 'W0232', # Class has no __init__ method
Henrik Kjellander57e5fd22015-05-25 10:55:39390 ],
391 pylintrc='pylintrc'))
392 # WebRTC can't use the presubmit_canned_checks.PanProjectChecks function since
393 # we need to have different license checks in talk/ and webrtc/ directories.
394 # Instead, hand-picked checks are included below.
Henrik Kjellander63224672015-09-08 06:03:56395
396 # Skip long-lines check for DEPS, GN and GYP files.
397 long_lines_sources = lambda x: input_api.FilterSourceFile(x,
398 black_list=(r'.+\.gyp$', r'.+\.gypi$', r'.+\.gn$', r'.+\.gni$', 'DEPS'))
andrew@webrtc.org2442de12012-01-23 17:45:41399 results.extend(input_api.canned_checks.CheckLongLines(
Henrik Kjellander63224672015-09-08 06:03:56400 input_api, output_api, maxlen=80, source_file_filter=long_lines_sources))
andrew@webrtc.org2442de12012-01-23 17:45:41401 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
402 input_api, output_api))
andrew@webrtc.org53df1362012-01-26 21:24:23403 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
404 input_api, output_api))
405 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner(
406 input_api, output_api))
kjellander53047c92015-12-03 07:56:14407 results.extend(_CheckApprovedFilesLintClean(input_api, output_api))
408 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api))
kjellander@webrtc.org51198f12012-02-21 17:53:46409 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
410 results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
kjellander@webrtc.orge4158642014-08-06 09:11:18411 results.extend(_CheckGypChanges(input_api, output_api))
kjellander@webrtc.org3bd41562014-09-01 11:06:37412 results.extend(_CheckUnwantedDependencies(input_api, output_api))
Henrik Kjellander8d3ad822015-05-26 17:52:05413 results.extend(_RunPythonTests(input_api, output_api))
andrew@webrtc.org53df1362012-01-26 21:24:23414 return results
andrew@webrtc.org2442de12012-01-23 17:45:41415
kjellander@webrtc.orge4158642014-08-06 09:11:18416
andrew@webrtc.org53df1362012-01-26 21:24:23417def CheckChangeOnUpload(input_api, output_api):
418 results = []
419 results.extend(_CommonChecks(input_api, output_api))
Henrik Kjellander57e5fd22015-05-25 10:55:39420 results.extend(
421 input_api.canned_checks.CheckGNFormatted(input_api, output_api))
niklase@google.comda159d62011-05-30 11:51:34422 return results
423
kjellander@webrtc.orge4158642014-08-06 09:11:18424
andrew@webrtc.org2442de12012-01-23 17:45:41425def CheckChangeOnCommit(input_api, output_api):
niklase@google.com1198db92011-06-09 07:07:24426 results = []
andrew@webrtc.org53df1362012-01-26 21:24:23427 results.extend(_CommonChecks(input_api, output_api))
kjellander53047c92015-12-03 07:56:14428 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api))
niklase@google.com1198db92011-06-09 07:07:24429 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
andrew@webrtc.org53df1362012-01-26 21:24:23430 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
431 input_api, output_api))
432 results.extend(input_api.canned_checks.CheckChangeHasDescription(
433 input_api, output_api))
kjellander@webrtc.org51198f12012-02-21 17:53:46434 results.extend(input_api.canned_checks.CheckChangeHasBugField(
435 input_api, output_api))
436 results.extend(input_api.canned_checks.CheckChangeHasTestField(
437 input_api, output_api))
kjellander@webrtc.org12cb88c2014-02-13 11:53:43438 results.extend(input_api.canned_checks.CheckTreeIsOpen(
439 input_api, output_api,
440 json_url='http://webrtc-status.appspot.com/current?format=json'))
niklase@google.com1198db92011-06-09 07:07:24441 return results
kjellander@webrtc.org85759802013-10-22 16:47:40442
kjellander@webrtc.orge4158642014-08-06 09:11:18443
kjellander@webrtc.org85759802013-10-22 16:47:40444# pylint: disable=W0613
kjellander@webrtc.orgc7b8b2f2014-04-03 20:19:36445def GetPreferredTryMasters(project, change):
kjellander986ee082015-06-16 11:32:13446 cq_config_path = os.path.join(
tandrii04465d22015-06-20 11:00:49447 change.RepositoryRoot(), 'infra', 'config', 'cq.cfg')
kjellander986ee082015-06-16 11:32:13448 # commit_queue.py below is a script in depot_tools directory, which has a
449 # 'builders' command to retrieve a list of CQ builders from the CQ config.
450 is_win = platform.system() == 'Windows'
451 masters = json.loads(subprocess.check_output(
452 ['commit_queue', 'builders', cq_config_path], shell=is_win))
kjellander@webrtc.org85759802013-10-22 16:47:40453
kjellander986ee082015-06-16 11:32:13454 try_config = {}
455 for master in masters:
456 try_config.setdefault(master, {})
457 for builder in masters[master]:
458 if 'presubmit' in builder:
459 # Do not trigger presubmit builders, since they're likely to fail
460 # (e.g. OWNERS checks before finished code review), and we're running
461 # local presubmit anyway.
462 pass
463 else:
464 try_config[master][builder] = ['defaulttests']
kjellander@webrtc.org85759802013-10-22 16:47:40465
kjellander986ee082015-06-16 11:32:13466 return try_config