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

Side by Side Diff: PRESUBMIT.py

Issue 155354: Enforce presubmit check of try run. Add a nice message to give feedback to th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Top-level presubmit script for Chromium. 6 """Top-level presubmit script for Chromium.
7 7
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
9 details on the presubmit API built into gcl. 9 details on the presubmit API built into gcl.
10 """ 10 """
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if not input_api.change.issue or not input_api.change.patchset: 75 if not input_api.change.issue or not input_api.change.patchset:
76 return outputs 76 return outputs
77 url = "http://codereview.chromium.org/%d/get_build_results/%d" % ( 77 url = "http://codereview.chromium.org/%d/get_build_results/%d" % (
78 input_api.change.issue, input_api.change.patchset) 78 input_api.change.issue, input_api.change.patchset)
79 try: 79 try:
80 connection = input_api.urllib2.urlopen(url) 80 connection = input_api.urllib2.urlopen(url)
81 # platform|status|url 81 # platform|status|url
82 values = [item.split('|', 2) for item in connection.read().splitlines()] 82 values = [item.split('|', 2) for item in connection.read().splitlines()]
83 connection.close() 83 connection.close()
84 statuses = map(lambda x: x[1], values) 84 statuses = map(lambda x: x[1], values)
85 message = None
85 if 'failure' in statuses: 86 if 'failure' in statuses:
86 failures = filter(lambda x: x[1] != 'success', values) 87 failures = filter(lambda x: x[1] != 'success', values)
87 long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2]) 88 long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2])
88 for item in failures) 89 for item in failures)
89 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is 90 message = 'You had try job failures. Are you sure you want to check-in?\n'
90 # stable enough and it seems to work fine.
91 message = 'You had try job failures. Are you sure you want to check-in?'
92 outputs.append(output_api.PresubmitNotifyResult(message=message,
93 long_text=long_text))
94 elif 'pending' in statuses or len(values) != 3: 91 elif 'pending' in statuses or len(values) != 3:
95 long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2]) 92 long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2])
96 for item in values) 93 for item in values)
97 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is 94 message = 'You should try the patch first (and wait for it to finish).\n'
98 # stable enough and it seems to work fine. 95 if message:
99 message = 'You should try the patch first (and wait for it to finish).' 96 message += (
100 outputs.append(output_api.PresubmitNotifyResult(message=message, 97 'Is try server wrong or broken? Please notify maruel@chromium.org. '
101 long_text=long_text)) 98 'Thanks.\n')
99 outputs.append(output_api.PresubmitPromptWarning(message=message,
100 long_text=long_text))
102 except input_api.urllib2.HTTPError, e: 101 except input_api.urllib2.HTTPError, e:
103 if e.code == 404: 102 if e.code == 404:
104 # Fallback to no try job. 103 # Fallback to no try job.
105 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is 104 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is
106 # stable enough and it seems to work fine. 105 # stable enough and it seems to work fine.
107 outputs.append(output_api.PresubmitNotifyResult( 106 outputs.append(output_api.PresubmitNotifyResult(
108 'You should try the patch first.')) 107 'You should try the patch first.'))
109 else: 108 else:
110 # Another HTTP error happened, warn the user. 109 # Another HTTP error happened, warn the user.
111 # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work 110 # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work
(...skipping 22 matching lines...) Expand all
134 text) 133 text)
135 if match: 134 if match:
136 long_text = match.group(1).strip() 135 long_text = match.group(1).strip()
137 except IOError: 136 except IOError:
138 pass 137 pass
139 return [output_api.PresubmitPromptWarning("The tree is closed.", 138 return [output_api.PresubmitPromptWarning("The tree is closed.",
140 long_text=long_text)] 139 long_text=long_text)]
141 except IOError: 140 except IOError:
142 pass 141 pass
143 return [] 142 return []
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698