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

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

Issue 2406153003: Change Rietveld.latest_try_jobs to return try job result details. (Closed)
Patch Set: Created 4 years, 2 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
index dd0dd98c650e2c8367343286bb1436c931dea1c8..1d01b2a07f7f99276b4d4085a1203e9ef80705a2 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/net/rietveld.py
@@ -20,17 +20,18 @@ class Rietveld(object):
def __init__(self, web):
self.web = web
- def latest_try_jobs(self, issue_number, builder_names, patchset_number=None):
- """Returns a list of Build objects for jobs on the latest patchset.
+ def latest_try_job_results(self, issue_number, builder_names=None, patchset_number=None):
+ """Returns a list of Build objects for builds on the latest patchset.
Args:
issue_number: A Rietveld issue number.
- builder_names: A collection of builder names to list jobs for.
- patchset_number: Use a specific patchset instead of the latest one.
+ builder_names: A collection of builder names. If specified, only results
+ from the given list of builders will be kept.
+ patchset_number: If given, a specific patchset will be used instead of the latest one.
Returns:
- A list of Build objects for the latest job for each builder, on the
- latest patchset. If none were found, an empty list is returned.
+ A dict mapping Build objects to result dicts for the latest build
+ for each builder on the latest patchset.
"""
try:
if patchset_number:
@@ -39,15 +40,39 @@ class Rietveld(object):
url = self._latest_patchset_url(issue_number)
patchset_data = self._get_json(url)
except (urllib2.URLError, ValueError):
- return []
- jobs = []
- for job in patchset_data['try_job_results']:
- if job['builder'] not in builder_names:
- continue
- jobs.append(Build(
- builder_name=job['builder'],
- build_number=job['buildnumber']))
- return self.filter_latest_jobs(jobs)
+ return {}
+
+ def build(job):
+ return Build(builder_name=job['builder'], build_number=job['buildnumber'])
+
+ results = {build(job): job for job in patchset_data['try_job_results']}
+
+ if builder_names is not None:
+ results = {b: result for b, result in results.iteritems() if b.builder_name in builder_names}
+
+ latest_builds = self._filter_latest_builds(list(results))
+ return {b: result for b, result in results.iteritems() if b in latest_builds}
+
+ def _filter_latest_builds(self, builds):
+ """Filters out a collection of Build objects to include only the latest for each builder.
+
+ Args:
+ jobs: A list of Build objects.
+
+ Returns:
+ A list of Build objects that contains only the latest build for each builder.
+ """
+ builder_to_highest_number = {}
+ for build in builds:
+ if build.build_number > builder_to_highest_number.get(build.builder_name, 0):
+ builder_to_highest_number[build.builder_name] = build.build_number
+
+ def is_latest_build(build):
+ if build.builder_name not in builder_to_highest_number:
+ return False
+ return builder_to_highest_number[build.builder_name] == build.build_number
+
+ return [b for b in builds if is_latest_build(b)]
def changed_files(self, issue_number):
"""Lists the files included in a CL, or None if this can't be determined.
@@ -90,31 +115,3 @@ class Rietveld(object):
def _patchset_url(self, issue_number, patchset_number):
return '%s/%s' % (self._issue_url(issue_number), patchset_number)
-
- def filter_latest_jobs(self, jobs):
- """Filters out the list of jobs to include only the latest for each builder.
-
- Args:
- jobs: A list of Build objects.
-
- Returns:
- A list of Build objects such that only the latest job for each builder
- is kept.
- """
- builder_to_highest_number = {}
- for j in jobs:
- if j.build_number > builder_to_highest_number.get(j.builder_name, 0):
- builder_to_highest_number[j.builder_name] = j.build_number
- return [j for j in jobs if (
- j.builder_name in builder_to_highest_number and
- builder_to_highest_number[j.builder_name] == j.build_number
- )]
-
- def get_latest_try_job_results(self, issue_number):
- """Returns a dict mapping builders to try job results."""
- url = self._latest_patchset_url(issue_number)
- patchset_data = self._get_json(url)
- results = {}
- for job in patchset_data['try_job_results']:
- results[job['builder']] = job['result']
- return results
« 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