[cipd] Add presubmit support for checking *.digests file.

Not enabling it yet, since PRESUBMIT.py uses presubmit_canned_checks.py from
depot_tools at HEAD, not from a CL (thus enabling this check in this CL will
make it fail the presubmit).

R=nodir@chromium.org
BUG=870166

Change-Id: I97802ec37f1f7513dfca3950f7f38a5c51ab0350
Reviewed-on: https://chromium-review.googlesource.com/1227432
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
This commit is contained in:
Vadim Shtayura
2018-09-14 22:17:02 +00:00
committed by Commit Bot
parent dfedcc0666
commit 2174136d25
3 changed files with 37 additions and 2 deletions

View File

@@ -1181,6 +1181,29 @@ def CheckCIPDPackages(input_api, output_api, platforms, packages):
return CheckCIPDManifest(input_api, output_api, content='\n'.join(manifest))
def CheckCIPDClientDigests(input_api, output_api, client_version_file):
"""Verifies that *.digests file was correctly regenerated.
<client_version_file>.digests file contains pinned hashes of the CIPD client.
It is consulted during CIPD client bootstrap and self-update. It should be
regenerated each time CIPD client version file changes.
Args:
client_version_file (str): Path to a text file with CIPD client version.
"""
cmd = [
'cipd' if not input_api.is_windows else 'cipd.bat',
'selfupdate-roll', '-check', '-version-file', client_version_file,
]
if input_api.verbose:
cmd += ['-log-level', 'debug']
return input_api.Command(
'Check CIPD client_version_file.digests file',
cmd,
{'shell': True} if input_api.is_windows else {}, # to resolve cipd.bat
output_api.PresubmitError)
def CheckVPythonSpec(input_api, output_api, file_filter=None):
"""Validates any changed .vpython files with vpython verification tool.

View File

@@ -18,7 +18,7 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# This version is from Aug 2018. Digests were generated using:
# cipd selfupdate-roll -version-file tmp \
# -version git_revision:ea6c07cfcb596be6b63a1e6deb95bba79524b0c8
# cat tmp.cat
# cat tmp.digests
OLD_VERSION = 'git_revision:ea6c07cfcb596be6b63a1e6deb95bba79524b0c8'
OLD_DIGESTS = """
linux-386 sha256 ee90bd655b90baf7586ab80c289c00233b96bfac3fa70e64cc5c48feb1998971

View File

@@ -1777,7 +1777,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
'GetCodereviewOwnerAndReviewers',
'GetPythonUnitTests', 'GetPylint',
'GetUnitTests', 'GetUnitTestsInDirectory', 'GetUnitTestsRecursively',
'CheckCIPDManifest', 'CheckCIPDPackages',
'CheckCIPDManifest', 'CheckCIPDPackages', 'CheckCIPDClientDigests',
'CheckChangedLUCIConfigs',
]
# If this test fails, you should add the relevant test.
@@ -2935,6 +2935,18 @@ class CannedChecksUnittest(PresubmitTestsBase):
'stderr': subprocess.STDOUT,
})
def testCheckCIPDClientDigests(self):
input_api = self.MockInputApi(None, False)
input_api.verbose = True
self.mox.ReplayAll()
command = presubmit_canned_checks.CheckCIPDClientDigests(
input_api, presubmit.OutputApi, client_version_file='ver')
self.assertEquals(command.cmd, [
'cipd', 'selfupdate-roll', '-check', '-version-file', 'ver',
'-log-level', 'debug',
])
def testCannedCheckVPythonSpec(self):
change = presubmit.Change('a', 'b', self.fake_root_dir, None, 0, 0, None)
input_api = self.MockInputApi(change, False)