GN: Add PRESUBMIT.py check for GN changes + default bots.

Add the GN trybots to the default set and also set them
to be the only bots to run if a CL contains only BUILD.gn
changes.

Update Python exclusions in general and fix a few of the lint
warnings.
The ones in python_charts needs to be disabled since those variables
are actually used when passed via vars() to the template.

BUG=None
TEST=git cl presubmit with the following cases:
A CL with two .gyp changes.
A CL with no changes in .gyp* files.

R=niklas.enbom@webrtc.org, phoglund@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/18719004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6834 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kjellander@webrtc.org 2014-08-06 09:11:18 +00:00
parent 8b033adb19
commit e415864a32
3 changed files with 50 additions and 9 deletions

View File

@ -29,6 +29,7 @@ def _CheckNoIOStreamInHeaders(input_api, output_api):
files) ]
return []
def _CheckNoFRIEND_TEST(input_api, output_api):
"""Make sure that gtest's FRIEND_TEST() macro is not used, the
FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be
@ -47,6 +48,7 @@ def _CheckNoFRIEND_TEST(input_api, output_api):
'gtest\'s FRIEND_TEST() macro. Include testsupport/gtest_prod_util.h and '
'use FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))]
def _CheckApprovedFilesLintClean(input_api, output_api,
source_file_filter=None):
"""Checks that all new or whitelisted .cc and .h files pass cpplint.py.
@ -93,6 +95,24 @@ def _CheckApprovedFilesLintClean(input_api, output_api,
return result
def _CheckGypChanges(input_api, output_api):
source_file_filter = lambda x: input_api.FilterSourceFile(
x, white_list=(r'.+\.(gyp|gypi)$',))
gyp_files = []
for f in input_api.AffectedSourceFiles(source_file_filter):
gyp_files.append(f.LocalPath())
result = []
if gyp_files:
result.append(output_api.PresubmitNotifyResult(
'As you\'re changing GYP files: please make sure corresponding '
'BUILD.gn files are also updated.\nChanged GYP files:',
items=gyp_files))
return result
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
# TODO(kjellander): Use presubmit_canned_checks.PanProjectChecks too.
@ -101,10 +121,14 @@ def _CommonChecks(input_api, output_api):
black_list=(r'^.*gviz_api\.py$',
r'^.*gaeunit\.py$',
# Embedded shell-script fakes out pylint.
r'^build/.*\.py$',
r'^buildtools/.*\.py$',
r'^out.*/.*\.py$',
r'^talk/site_scons/site_tools/talk_linux.py$',
r'^third_party/.*\.py$',
r'^testing/.*\.py$',
r'^third_party/.*\.py$',
r'^tools/clang/.*\.py$',
r'^tools/gn/.*\.py$',
r'^tools/gyp/.*\.py$',
r'^tools/perf_expectations/.*\.py$',
r'^tools/protoc_wrapper/.*\.py$',
@ -117,8 +141,8 @@ def _CommonChecks(input_api, output_api):
r'^tools/valgrind/.*\.py$',
# TODO(phoglund): should arguably be checked.
r'^webrtc/build/.*\.py$',
r'^build/.*\.py$',
r'^out.*/.*\.py$',),
r'^xcodebuild.*/.*\.py$',),
disabled_warnings=['F0401', # Failed to import x
'E0611', # No package y in x
'W0232', # Class has no __init__ method
@ -134,13 +158,16 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckApprovedFilesLintClean(input_api, output_api))
results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
results.extend(_CheckGypChanges(input_api, output_api))
return results
def CheckChangeOnUpload(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
return results
def CheckChangeOnCommit(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
@ -158,6 +185,7 @@ def CheckChangeOnCommit(input_api, output_api):
json_url='http://webrtc-status.appspot.com/current?format=json'))
return results
def GetDefaultTryConfigs(bots=None):
"""Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
@ -166,10 +194,15 @@ def GetDefaultTryConfigs(bots=None):
"""
return { 'tryserver.webrtc': dict((bot, []) for bot in bots)}
# pylint: disable=W0613
def GetPreferredTryMasters(project, change):
files = change.LocalPaths()
android_gn_bots = [
'android_gn',
'android_gn_rel',
]
android_bots = [
'android',
'android_arm64',
@ -177,11 +210,15 @@ def GetPreferredTryMasters(project, change):
'android_apk_rel',
'android_rel',
'android_clang',
]
] + android_gn_bots
ios_bots = [
'ios',
'ios_rel',
]
linux_gn_bots = [
'linux_gn',
'linux_gn_rel',
]
linux_bots = [
'linux',
'linux_asan',
@ -189,7 +226,7 @@ def GetPreferredTryMasters(project, change):
'linux_memcheck',
'linux_rel',
'linux_tsan2',
]
] + linux_gn_bots
mac_bots = [
'mac',
'mac_asan',
@ -207,7 +244,8 @@ def GetPreferredTryMasters(project, change):
]
if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files):
return {}
if all(re.search(r'[\\/]BUILD.gn$', f) for f in files):
return GetDefaultTryConfigs(android_gn_bots + linux_gn_bots)
if all(re.search('\.(m|mm)$|(^|[/_])mac[/_.]', f) for f in files):
return GetDefaultTryConfigs(mac_bots)
if all(re.search('(^|[/_])win[/_.]', f) for f in files):

View File

@ -101,18 +101,21 @@ def main():
# Loading it into gviz_api.DataTable objects and create JSON strings.
description, data = helper.CreateConfigurationTable(test_configurations)
configurations = gviz_api.DataTable(description, data)
json_configurations = configurations.ToJSon()
json_configurations = configurations.ToJSon() # pylint: disable=W0612
description, data = helper.CreateData('ssim')
ssim = gviz_api.DataTable(description, data)
# pylint: disable=W0612
json_ssim_data = ssim.ToJSon(helper.GetOrdering(description))
description, data = helper.CreateData('psnr')
psnr = gviz_api.DataTable(description, data)
# pylint: disable=W0612
json_psnr_data = psnr.ToJSon(helper.GetOrdering(description))
description, data = helper.CreateData('packets_dropped')
packet_loss = gviz_api.DataTable(description, data)
# pylint: disable=W0612
json_packet_loss_data = packet_loss.ToJSon(helper.GetOrdering(description))
description, data = helper.CreateData('bit_rate')
@ -129,6 +132,7 @@ def main():
for row in data:
row['desired_bit_rate'] = desired_bit_rate
bit_rate = gviz_api.DataTable(description, data)
# pylint: disable=W0612
json_bit_rate_data = bit_rate.ToJSon(helper.GetOrdering(description))
# Format the messages list with newlines.

View File

@ -10,7 +10,6 @@
"""Connects all URLs with their respective handlers."""
from google.appengine.ext.webapp import template
import webapp2
import add_coverage_data
@ -19,4 +18,4 @@ import dashboard
app = webapp2.WSGIApplication([('/', dashboard.ShowDashboard),
('/add_coverage_data',
add_coverage_data.AddCoverageData)],
debug=True)
debug=True)