Add presubmit check that runs 'lucicfg validate <script>'.

R=tandrii@chromium.org
BUG=925532

Change-Id: I72ab6108cf43353e36ddeccd705acdd04716f785
Reviewed-on: https://chromium-review.googlesource.com/c/1448634
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
changes/34/1448634/3
Vadim Shtayura 6 years ago committed by Commit Bot
parent 50b187ca83
commit 39b0b8e32a

@ -1432,3 +1432,37 @@ def CheckChangedLUCIConfigs(input_api, output_api):
out_f = output_api.PresubmitNotifyResult
outputs.append(out_f('Config validation: %s' % msg['text']))
return outputs
def CheckLucicfgGenOutput(input_api, output_api, entry_script):
"""Verifies configs produced by `lucicfg` are up-to-date and pass validation.
Runs the check unconditionally, regardless of what files are modified. Examine
input_api.AffectedFiles() yourself before using CheckLucicfgGenOutput if this
is a concern.
Assumes `lucicfg` binary is in PATH and the user is logged in.
Args:
entry_script: path to the entry-point *.star script responsible for
generating a single config set. Either absolute or relative to the
currently running PRESUBMIT.py script.
Returns:
A list of input_api.Command objects containing verification commands.
"""
return [
input_api.Command(
'lucicfg validate "%s"' % entry_script,
[
'lucicfg' if not input_api.is_windows else 'lucicfg.bat',
'validate', entry_script,
'-log-level', 'debug' if input_api.verbose else 'warning',
],
{
'stderr': input_api.subprocess.STDOUT,
'shell': input_api.is_windows, # to resolve *.bat
'cwd': input_api.PresubmitLocalPath(),
},
output_api.PresubmitError)
]

@ -1664,7 +1664,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
'GetPythonUnitTests', 'GetPylint',
'GetUnitTests', 'GetUnitTestsInDirectory', 'GetUnitTestsRecursively',
'CheckCIPDManifest', 'CheckCIPDPackages', 'CheckCIPDClientDigests',
'CheckChangedLUCIConfigs',
'CheckChangedLUCIConfigs', 'CheckLucicfgGenOutput',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit_canned_checks, members)

Loading…
Cancel
Save