Commit c6231602 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

Run lint-luci-milo.py as presubmit on luci-milo.cfg changes.

Bug: none
Change-Id: I4cd719751f4962bd80c7f9b6531535e15a1d3d99
Reviewed-on: https://chromium-review.googlesource.com/c/1340520
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608943}
parent c9bc1de1
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Enforces luci-milo.cfg consistency.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details on the presubmit API built into depot_tools.
"""
def _CheckLintLuciMiloCfg(input_api, output_api):
if ('infra/config/global/luci-milo.cfg' not in input_api.LocalPaths() and
'infra/config/global/lint-luci-milo.py' not in input_api.LocalPaths()):
return []
return input_api.RunTests([input_api.Command(
name='lint-luci-milo',
cmd=[input_api.python_executable, 'lint-luci-milo.py'],
kwargs={},
message=output_api.PresubmitError)])
def CheckChangeOnUpload(input_api, output_api):
return _CheckLintLuciMiloCfg(input_api, output_api)
def CheckChangeOnCommit(input_api, output_api):
return _CheckLintLuciMiloCfg(input_api, output_api)
......@@ -28,12 +28,14 @@ def compare_builders(name, main_builders, sub_builders):
sub_names = [', '.join(builder.name) for builder in sub_builders]
if main_names != sub_names:
print '%s: bot name lists different:' % name
print ('bot name lists different between main waterfall ' +
'and stand-alone %s waterfall:' % name)
print '\n'.join(difflib.unified_diff(main_names, sub_names,
fromfile='main', tofile='sub',
fromfile='main', tofile=name,
lineterm=''))
print
return
return False
return True
def main():
......@@ -51,9 +53,13 @@ def main():
subwaterfall = builder.category.split('|', 1)[0]
subwaterfalls[subwaterfall].append(builder)
all_good = True
for console in project.consoles:
if console.id in subwaterfalls:
compare_builders(console.id, subwaterfalls[console.id], console.builders)
if not compare_builders(console.id, subwaterfalls[console.id],
console.builders):
all_good = False
return 0 if all_good else 1
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment