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

Unified Diff: infra/tools/builder_alerts/buildbot.py

Issue 475943002: Add time and state to builder revision data (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Add tests and address comments Created 6 years, 4 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
Index: infra/tools/builder_alerts/buildbot.py
diff --git a/infra/tools/builder_alerts/buildbot.py b/infra/tools/builder_alerts/buildbot.py
index 7f138b1ce7fa129d21f36eb27299da9a9091ca03..c30359fe9f216930c7ed104990397d052bdc19aa 100644
--- a/infra/tools/builder_alerts/buildbot.py
+++ b/infra/tools/builder_alerts/buildbot.py
@@ -178,10 +178,20 @@ def revisions_from_build(build_json): # pragma: no cover
revisions[repo_name] = revision
return revisions
+def latest_update_time_for_builder(last_build):
+ last_update = float(0)
eseidel 2014/08/18 16:35:43 None?
leviw_travelin_and_unemployed 2014/08/18 18:39:02 Sure!
+ if last_build['times'][1] != None:
+ last_update = float(last_build['times'][1])
+ else:
+ for step in last_build['steps']:
+ step_time = float(step['times'][0])
+ last_update = max(step_time, last_update)
+ return last_update
+
# "line too long" pylint: disable=C0301
-def latest_revisions_for_master(cache, master_url, master_json): # pragma: no cover
- latest_revisions = collections.defaultdict(dict)
+def latest_builder_info_for_master(cache, master_url, master_json): # pragma: no cover
+ latest_builder_info = collections.defaultdict(dict)
master_name = master_name_from_url(master_url)
for builder_name, builder_json in master_json['builders'].items():
# recent_builds can include current builds
@@ -190,9 +200,12 @@ def latest_revisions_for_master(cache, master_url, master_json): # pragma: no c
last_finished_id = sorted(recent_builds - active_builds, reverse=True)[0]
last_build = fetch_build_json(cache,
master_url, builder_name, last_finished_id)
- latest_revisions[master_name][builder_name] = \
- revisions_from_build(last_build)
- return latest_revisions
+ latest_builder_info[master_name][builder_name] = {
+ 'revisions': revisions_from_build(last_build),
+ 'state': builder_json['state'],
+ 'lastUpdateTime': latest_update_time_for_builder(last_build),
eseidel 2014/08/18 16:35:43 What does 0 mean here?
leviw_travelin_and_unemployed 2014/08/18 18:39:02 It should never actually be zero. It should be Non
+ }
+ return latest_builder_info
def warm_build_cache(cache, master_url, builder_name,

Powered by Google App Engine
This is Rietveld 408576698