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

Side by Side Diff: appengine/findit/waterfall/buildbot.py

Issue 2400453002: [Findit] Retrieve recent builds of a given builder. (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 unified diff | Download patch
« no previous file with comments | « no previous file | appengine/findit/waterfall/test/buildbot_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import contextlib 5 import contextlib
6 from datetime import datetime 6 from datetime import datetime
7 import gzip 7 import gzip
8 import logging
8 import json 9 import json
9 import re 10 import re
10 import urllib 11 import urllib
11 12
12 import cloudstorage as gcs 13 import cloudstorage as gcs
13 14
14 from waterfall.build_info import BuildInfo 15 from waterfall.build_info import BuildInfo
15 16
16 17
17 _MASTER_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)' 18 _MASTER_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)'
18 '(/.*)?$') 19 '(/.*)?$')
19 20
20 _BUILD_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/' 21 _BUILD_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/'
21 'builders/([^/]+)/builds/([\d]+)(/.*)?$') 22 'builders/([^/]+)/builds/([\d]+)(/.*)?$')
22 23
23 _STEP_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/' 24 _STEP_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/'
24 'builders/([^/]+)/builds/([\d]+)/steps/' 25 'builders/([^/]+)/builds/([\d]+)/steps/'
25 '([^/]+)(/.*)?$') 26 '([^/]+)(/.*)?$')
26 27
27 # These values are buildbot constants used for Build and BuildStep. 28 # These values are buildbot constants used for Build and BuildStep.
28 # This line was copied from buildbot/master/buildbot/status/results.py. 29 # This line was copied from buildbot/master/buildbot/status/results.py.
29 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, CANCELLED = range(7) 30 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, CANCELLED = range(7)
30 31
31 32
33 def GetRecentCompletedBuilds(master_name, builder_name, http_client):
34 """Returns a sorted list of recent completed builds for the given builder.
35
36 Sorted by completed time, newer builds at beginning of the returned list.
37 """
38 url = 'https://build.chromium.org/p/%s/json/builders/' % master_name
39 status_code, data = http_client.Get(url)
40 if status_code != 200:
41 logging.error('Failed to retrieve recent builds for %s/%s',
42 master_name, builder_name)
43 return []
44 data_json = json.loads(data)
45 metadata = data_json.get(builder_name, {})
46 cachedBuilds = metadata.get('cachedBuilds', [])
47 currentBuilds = metadata.get('currentBuilds', [])
48 return sorted(set(cachedBuilds) - set(currentBuilds), reverse=True)
49
50
32 def GetMasterNameFromUrl(url): 51 def GetMasterNameFromUrl(url):
33 """Parses the given url and returns the master name.""" 52 """Parses the given url and returns the master name."""
34 if not url: 53 if not url:
35 return None 54 return None
36 55
37 match = _MASTER_URL_PATTERN.match(url) 56 match = _MASTER_URL_PATTERN.match(url)
38 if not match: 57 if not match:
39 return None 58 return None
40 return match.group(1) 59 return match.group(1)
41 60
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 # the annotating step like "steps" fail too. Such annotating steps have a 255 # the annotating step like "steps" fail too. Such annotating steps have a
237 # log with name "preamble". 256 # log with name "preamble".
238 continue 257 continue
239 258
240 if step_result in (SUCCESS, WARNINGS): 259 if step_result in (SUCCESS, WARNINGS):
241 build_info.passed_steps.append(step_name) 260 build_info.passed_steps.append(step_name)
242 elif step_result == FAILURE: 261 elif step_result == FAILURE:
243 build_info.failed_steps.append(step_name) 262 build_info.failed_steps.append(step_name)
244 263
245 return build_info 264 return build_info
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/waterfall/test/buildbot_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698