Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: tools/perf/PRESUBMIT.py

Issue 954753002: [Telemetry] Add PRESUBMIT check to prevent .sha file uploaded without archive file uploaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix redundant BUCKET_ALIASES assignment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/util/cloud_storage.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Presubmit script for changes affecting tools/perf/. 5 """Presubmit script for changes affecting tools/perf/.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
(...skipping 13 matching lines...) Expand all
24 results = [] 24 results = []
25 old_sys_path = sys.path 25 old_sys_path = sys.path
26 try: 26 try:
27 # Modules in tools/perf depend on telemetry. 27 # Modules in tools/perf depend on telemetry.
28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path 28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path
29 results.extend(input_api.canned_checks.RunPylint( 29 results.extend(input_api.canned_checks.RunPylint(
30 input_api, output_api, 30 input_api, output_api,
31 black_list=PYLINT_BLACKLIST, 31 black_list=PYLINT_BLACKLIST,
32 disabled_warnings=PYLINT_DISABLED_WARNINGS)) 32 disabled_warnings=PYLINT_DISABLED_WARNINGS))
33 results.extend(_CheckJson(input_api, output_api)) 33 results.extend(_CheckJson(input_api, output_api))
34 results.extend(_CheckWprShaFiles(input_api, output_api))
34 finally: 35 finally:
35 sys.path = old_sys_path 36 sys.path = old_sys_path
36 return results 37 return results
37 38
38 39
40 def _CheckWprShaFiles(input_api, output_api):
41 """Check whether the wpr sha files have matching URLs."""
42 from telemetry.util import cloud_storage
43 results = []
44 for affected_file in input_api.AffectedFiles(include_deletes=False):
45 filename = affected_file.AbsoluteLocalPath()
46 if not filename.endswith('wpr.sha1'):
47 continue
48 expected_hash = cloud_storage.ReadHash(filename)
49 is_wpr_file_uploaded = any(
50 cloud_storage.Exists(bucket, expected_hash)
51 for bucket in cloud_storage.BUCKET_ALIASES.itervalues())
52 if not is_wpr_file_uploaded:
53 wpr_filename = filename[:-5]
54 results.append(output_api.PresubmitError(
55 'There is no URLs matched for wpr sha file %s.\n'
56 'You can upload your new wpr archive file with the command:\n'
57 'depot_tools/upload_to_google_storage.py --bucket '
58 '<Your pageset\'s bucket> %s.\nFor more info: see '
59 'http://www.chromium.org/developers/telemetry/'
60 'record_a_page_set#TOC-Upload-the-recording-to-Cloud-Storage' %
61 (filename, wpr_filename)))
62 return results
63
64
39 def _CheckJson(input_api, output_api): 65 def _CheckJson(input_api, output_api):
40 """Checks whether JSON files in this change can be parsed.""" 66 """Checks whether JSON files in this change can be parsed."""
41 for affected_file in input_api.AffectedFiles(include_deletes=False): 67 for affected_file in input_api.AffectedFiles(include_deletes=False):
42 filename = affected_file.AbsoluteLocalPath() 68 filename = affected_file.AbsoluteLocalPath()
43 if os.path.splitext(filename)[1] != '.json': 69 if os.path.splitext(filename)[1] != '.json':
44 continue 70 continue
45 try: 71 try:
46 input_api.json.load(open(filename)) 72 input_api.json.load(open(filename))
47 except ValueError: 73 except ValueError:
48 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)] 74 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)]
49 return [] 75 return []
50 76
51 77
52 def CheckChangeOnUpload(input_api, output_api): 78 def CheckChangeOnUpload(input_api, output_api):
53 report = [] 79 report = []
54 report.extend(_CommonChecks(input_api, output_api)) 80 report.extend(_CommonChecks(input_api, output_api))
55 return report 81 return report
56 82
57 83
58 def CheckChangeOnCommit(input_api, output_api): 84 def CheckChangeOnCommit(input_api, output_api):
59 report = [] 85 report = []
60 report.extend(_CommonChecks(input_api, output_api)) 86 report.extend(_CommonChecks(input_api, output_api))
61 return report 87 return report
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/util/cloud_storage.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698