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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py

Issue 2069863002: Add a webkit-patch command which gets a list of relevant try jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix import in multicommandtool_unittest Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py
new file mode 100644
index 0000000000000000000000000000000000000000..bc4bdbf84a94f924a1f79493bb3095b98a0f9ea7
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py
@@ -0,0 +1,60 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utility functions to communicate with Rietveld."""
+
+import collections
+import json
+
+
+TryJob = collections.namedtuple('TryJob', ('builder_name', 'master_name', 'build_number'))
+
+
+def latest_try_jobs(issue_number, builder_names, web, patchset_number=None):
+ """Returns a list of TryJob objects for jobs on the latest patchset.
+
+ Args:
+ issue_number: A Rietveld issue number.
+ builder_names: Builders that we're interested in; try jobs for only
+ these builders will be listed.
+ web: webkitpy.common.net.web.Web object (which can be mocked out).
+ patchset_number: Use a specific patchset instead of the latest one.
+
+ Returns:
+ A list of TryJob objects.
+ """
+ if patchset_number:
+ url = _patchset_url(issue_number, patchset_number)
+ else:
+ url = _latest_patchset_url(issue_number, web)
+ patchset_data = _get_json(url, web)
+ assert 'try_job_results' in patchset_data
+ jobs = []
+ for job in patchset_data['try_job_results']:
+ if job['builder'] not in builder_names:
+ continue
+ jobs.append(TryJob(
+ builder_name=job['builder'],
+ master_name=job['master'],
+ build_number=job['buildnumber']))
+ return jobs
+
+
+def _latest_patchset_url(issue_number, web):
+ issue_data = _get_json(_issue_url(issue_number), web)
+ latest_patchset_number = issue_data["patchsets"][-1]
+ return _patchset_url(issue_number, latest_patchset_number)
+
+
+def _get_json(url, web):
+ assert not isinstance(web, tuple), web
qyearsley 2016/06/15 21:34:15 Note, this was a debugging statement, removing now
+ return json.loads(web.get_binary(url))
wkorman 2016/06/15 17:43:17 Maybe catch error and deal gracefully, returning e
qyearsley 2016/06/15 21:34:15 Advantages of catching errors and printing error m
wkorman 2016/06/22 01:22:44 Looks ok to me, there are a few other places in we
+
+
+def _issue_url(issue_number):
+ return 'https://codereview.chromium.org/api/%s' % issue_number
wkorman 2016/06/15 17:43:17 Perhaps move string to BASE_CODEREVIEW_URL constan
qyearsley 2016/06/15 21:34:15 Done.
+
+
+def _patchset_url(issue_number, patchset_number):
+ return '%s/%s' % (_issue_url(issue_number), patchset_number)
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698