summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 17:31:51 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 17:31:51 +0000
commit70ac49883a4e9b48a875110ff342feb1a8724813 (patch)
tree09a8379a484bf34b5d8086365799820de182be24 /PRESUBMIT.py
parentc579342792a7a130b2a58f071afac80ef0202252 (diff)
downloadchromium_src-70ac49883a4e9b48a875110ff342feb1a8724813.zip
chromium_src-70ac49883a4e9b48a875110ff342feb1a8724813.tar.gz
chromium_src-70ac49883a4e9b48a875110ff342feb1a8724813.tar.bz2
Add try job status check on commit.
It acts as an advisory presubmit check for now since the try server isn't that stable. BUG=none TEST=gcl commit warns the user when a pending change hasn't passed the try job. Review URL: http://codereview.chromium.org/119295 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rwxr-xr-xPRESUBMIT.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 40be7b7..e5b2472 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -63,6 +63,7 @@ def CheckChangeOnCommit(input_api, output_api):
input_api, output_api,
'http://chromium-status.appspot.com/status', '0'
))
+ results.extend(CheckTryJobExecution(input_api, output_api))
return results
@@ -147,3 +148,46 @@ def LocalChecks(input_api, output_api, max_cols=80):
'These files should end in one (and only one) newline character:',
items=eof_files))
return results
+
+
+def CheckTryJobExecution(input_api, output_api):
+ url = "http://codereview.chromium.org/%d/get_build_results/%d" % (
+ input_api.change.issue, input_api.change.patchset)
+ outputs = []
+ try:
+ connection = input_api.urllib2.urlopen(url)
+ # platform|status|url
+ values = [item.split('|', 2) for item in connection.read().splitlines()]
+ connection.close()
+ statuses = map(lambda x: x[1], values)
+ if 'failure' in statuses:
+ failures = filter(lambda x: x[1] != 'success', values)
+ long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2])
+ for item in failures)
+ # TODO(maruel): Change to a PresubmitPromptWarning once the try server is
+ # stable enough and it seems to work fine.
+ message = 'You had try job failures. Are you sure you want to check-in?'
+ outputs.append(output_api.PresubmitNotifyResult(message=message,
+ long_text=long_text))
+ elif 'pending' in statuses or len(values) != 3:
+ long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2])
+ for item in values)
+ # TODO(maruel): Change to a PresubmitPromptWarning once the try server is
+ # stable enough and it seems to work fine.
+ message = 'You should try the patch first (and wait for it to finish).'
+ outputs.append(output_api.PresubmitNotifyResult(message=message,
+ long_text=long_text))
+ except input_api.urllib2.HTTPError, e:
+ if e.code == 404:
+ # Fallback to no try job.
+ # TODO(maruel): Change to a PresubmitPromptWarning once the try server is
+ # stable enough and it seems to work fine.
+ outputs.append(output_api.PresubmitNotifyResult(
+ 'You should try the patch first.'))
+ else:
+ # Another HTTP error happened, warn the user.
+ # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work
+ # fine.
+ outputs.append(output_api.PresubmitNotifyResult(
+ 'Got %s while looking for try job status.' % str(e)))
+ return outputs