mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[PRESUBMIT] Add cipd package checks for all known manifests.
This also improves the cipd manifest canned check to produce unique names in order to debug PRESUBMIT's more easily. Adds onto https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/708354 R=maruel@chromium.org, tandrii@chromium.org, vadimsh@chromium.org Bug: Change-Id: I9f086996998608092a4d23f5c98fbac34117a9e4 Reviewed-on: https://chromium-review.googlesource.com/811445 Reviewed-by: Vadim Shtayura <vadimsh@chromium.org> Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
0afcd10430
commit
7d47eb5495
38
PRESUBMIT.py
38
PRESUBMIT.py
@@ -12,6 +12,16 @@ import fnmatch
|
||||
import os
|
||||
|
||||
|
||||
ENSURE_FILE_TEMPLATE = r'''
|
||||
$VerifiedPlatform linux-386 linux-amd64 linux-arm64 linux-armv6l linux-mips64
|
||||
$VerifiedPlatform linux-ppc64 linux-ppc64le linux-s390x
|
||||
$VerifiedPlatform mac-amd64
|
||||
$VerifiedPlatform windows-386 windows-amd64
|
||||
|
||||
%s %s
|
||||
'''
|
||||
|
||||
|
||||
def DepotToolsPylint(input_api, output_api):
|
||||
"""Gather all the pylint logic into one place to make it self-contained."""
|
||||
white_list = [
|
||||
@@ -59,6 +69,34 @@ def CommonChecks(input_api, output_api, tests_to_black_list):
|
||||
tests.extend(unit_tests)
|
||||
else:
|
||||
print('Warning: not running unit tests on Windows')
|
||||
|
||||
# Validate CIPD manifests.
|
||||
root = input_api.os_path.normpath(
|
||||
input_api.os_path.abspath(input_api.PresubmitLocalPath()))
|
||||
rel_file = lambda rel: input_api.os_path.join(root, rel)
|
||||
cipd_manifests = set(rel_file(input_api.os_path.join(*x)) for x in (
|
||||
('cipd_manifest.txt',),
|
||||
('bootstrap', 'win', 'manifest.txt'),
|
||||
('bootstrap', 'win', 'manifest_bleeding_edge.txt'),
|
||||
|
||||
# Also generate a file for the cipd client itself.
|
||||
('cipd_client_version',),
|
||||
))
|
||||
affected_manifests = input_api.AffectedFiles(
|
||||
include_deletes=False,
|
||||
file_filter=lambda x:
|
||||
input_api.os_path.normpath(x.AbsoluteLocalPath()) in cipd_manifests)
|
||||
for path in affected_manifests:
|
||||
path = path.AbsoluteLocalPath()
|
||||
if path.endswith('.txt'):
|
||||
tests.append(input_api.canned_checks.CheckCIPDManifest(
|
||||
input_api, output_api, path=path))
|
||||
else:
|
||||
pkg = 'infra/tools/cipd/${platform}'
|
||||
ver = input_api.ReadFile(path)
|
||||
tests.append(input_api.canned_checks.CheckCIPDManifest(
|
||||
input_api, output_api, content=ENSURE_FILE_TEMPLATE % (pkg, ver)))
|
||||
|
||||
results.extend(input_api.RunTests(tests))
|
||||
return results
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
# string "cpython" and ends with the CIPD tag "version:VERSION". It uses this
|
||||
# to extract VERSION.
|
||||
|
||||
$VerifiedPlatform windows-386 windows-amd64
|
||||
|
||||
@Subdir python
|
||||
infra/python/cpython/windows-386 version:2.7.6
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
# string "cpython" and ends with the CIPD tag "version:VERSION". It uses this
|
||||
# to extract VERSION.
|
||||
|
||||
$VerifiedPlatform windows-386 windows-amd64
|
||||
|
||||
@Subdir python
|
||||
infra/python/cpython/${platform} version:2.7.13.chromium7
|
||||
|
||||
|
||||
@@ -1165,15 +1165,22 @@ def CheckCIPDManifest(input_api, output_api, path=None, content=None):
|
||||
if path:
|
||||
assert content is None, 'Cannot provide both "path" and "content".'
|
||||
cmd += ['-ensure-file', path]
|
||||
name = 'Check CIPD manifest %r' % path
|
||||
elif content:
|
||||
assert path is None, 'Cannot provide both "path" and "content".'
|
||||
cmd += ['-ensure-file=-']
|
||||
kwargs['stdin'] = content
|
||||
# quick and dirty parser to extract checked packages.
|
||||
packages = [
|
||||
l.split()[0] for l in (ll.strip() for ll in content.splitlines())
|
||||
if ' ' in l and not l.startswith('$')
|
||||
]
|
||||
name = 'Check CIPD packages from string: %r' % (packages,)
|
||||
else:
|
||||
raise Exception('Exactly one of "path" or "content" must be provided.')
|
||||
|
||||
return input_api.Command(
|
||||
'Check CIPD manifest',
|
||||
name,
|
||||
cmd,
|
||||
kwargs,
|
||||
output_api.PresubmitError)
|
||||
|
||||
Reference in New Issue
Block a user