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

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: Created 5 years, 10 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
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
11 import os 11 import os
12 import sys 12 import sys
13 13
14 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path
aiolos (Not reviewing) 2015/02/24 18:53:07 PRESUBMIT scripts aren't supposed to have side eff
nednguyen 2015/02/24 19:28:33 Done.
15
16 from telemetry.util import cloud_storage
17
14 PYLINT_BLACKLIST = [] 18 PYLINT_BLACKLIST = []
15 PYLINT_DISABLED_WARNINGS = [ 19 PYLINT_DISABLED_WARNINGS = [
16 'R0923', # Interface not implemented 20 'R0923', # Interface not implemented
17 'R0201', # Method could be a function 21 'R0201', # Method could be a function
18 'E1101', # Non-existent member is accessed. 22 'E1101', # Non-existent member is accessed.
19 ] 23 ]
20 24
21 25
22 def _CommonChecks(input_api, output_api): 26 def _CommonChecks(input_api, output_api):
23 """Performs common checks, which includes running pylint.""" 27 """Performs common checks, which includes running pylint."""
24 results = [] 28 results = []
25 old_sys_path = sys.path 29 results.extend(input_api.canned_checks.RunPylint(
26 try: 30 input_api, output_api,
27 # Modules in tools/perf depend on telemetry. 31 black_list=PYLINT_BLACKLIST,
28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path 32 disabled_warnings=PYLINT_DISABLED_WARNINGS))
29 results.extend(input_api.canned_checks.RunPylint( 33 results.extend(_CheckJson(input_api, output_api))
30 input_api, output_api, 34 results.extend(_CheckWprShaFiles(input_api, output_api))
31 black_list=PYLINT_BLACKLIST,
32 disabled_warnings=PYLINT_DISABLED_WARNINGS))
33 results.extend(_CheckJson(input_api, output_api))
34 finally:
35 sys.path = old_sys_path
36 return results 35 return results
37 36
38 37
38 def _CheckWprShaFiles(input_api, output_api):
39 """ Check whether the wpr sha files have matching URLs """
slamm 2015/02/24 19:22:59 No spaces immediately inside triple quotes. """Ch
nednguyen 2015/02/24 19:28:33 Done.
40 results = []
41 for affected_file in input_api.AffectedFiles(include_deletes=False):
42 filename = affected_file.AbsoluteLocalPath()
43 if not filename.endswith('wpr.sha1'):
44 continue
45 wpr_file_exist_on_cloud = False
dtu 2015/02/24 19:12:47 nit: wpr_file_exists_in_cloud
slamm 2015/02/24 19:22:59 How about the following? is_wpr_file_uploaded or
nednguyen 2015/02/24 19:28:33 Done.
nednguyen 2015/02/24 19:28:33 Done.
46 expected_hash = cloud_storage.ReadHash(filename)
47 for bucket in cloud_storage.SUPPORTED_BUCKETS:
48 wpr_file_exist_on_cloud = (wpr_file_exist_on_cloud or
49 cloud_storage.Exists(bucket, expected_hash))
slamm 2015/02/24 19:22:59 is_wpr_file_uploaded = any(cloud_storage.Exists(bu
nednguyen 2015/02/24 19:28:33 Nice, I like this.
50 if not wpr_file_exist_on_cloud:
51 wpr_filename = filename[:-5]
52 results.append(output_api.PresubmitError(
aiolos (Not reviewing) 2015/02/24 18:19:45 Should this be a warning instead of an error? Peop
nednguyen 2015/02/24 18:24:40 If they don't commit or upload, then this PRESUBMI
dtu 2015/02/24 19:12:47 I think this is fine. I guess you have to be caref
53 'No URLs matched for wpr sha file %s.\n'
54 'You can upload your new wpr archive file with the command:\n'
55 'depot_tools/upload_to_google_storage.py --bucket '
56 '<Your pageset\'s bucket> %s.\nFor more info: see '
57 'http://www.chromium.org/developers/telemetry/'
58 'record_a_page_set#TOC-Upload-the-recording-to-Cloud-Storage' %
59 (filename, wpr_filename)))
60 return results
61
62
39 def _CheckJson(input_api, output_api): 63 def _CheckJson(input_api, output_api):
40 """Checks whether JSON files in this change can be parsed.""" 64 """Checks whether JSON files in this change can be parsed."""
41 for affected_file in input_api.AffectedFiles(include_deletes=False): 65 for affected_file in input_api.AffectedFiles(include_deletes=False):
42 filename = affected_file.AbsoluteLocalPath() 66 filename = affected_file.AbsoluteLocalPath()
43 if os.path.splitext(filename)[1] != '.json': 67 if os.path.splitext(filename)[1] != '.json':
44 continue 68 continue
45 try: 69 try:
46 input_api.json.load(open(filename)) 70 input_api.json.load(open(filename))
47 except ValueError: 71 except ValueError:
48 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)] 72 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)]
49 return [] 73 return []
50 74
51 75
52 def CheckChangeOnUpload(input_api, output_api): 76 def CheckChangeOnUpload(input_api, output_api):
53 report = [] 77 report = []
54 report.extend(_CommonChecks(input_api, output_api)) 78 report.extend(_CommonChecks(input_api, output_api))
55 return report 79 return report
56 80
57 81
58 def CheckChangeOnCommit(input_api, output_api): 82 def CheckChangeOnCommit(input_api, output_api):
59 report = [] 83 report = []
60 report.extend(_CommonChecks(input_api, output_api)) 84 report.extend(_CommonChecks(input_api, output_api))
61 return report 85 return report
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/util/cloud_storage.py » ('j') | tools/telemetry/telemetry/util/cloud_storage.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698