OLD | NEW |
| (Empty) |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import json | |
6 import uuid | |
7 | |
8 # This is a wrapper class of revision that stores its build path and | |
9 # queries its status. Part of the code are adapted from the RevisionState | |
10 # class from auto-bisect module | |
11 class BuildState(object): | |
12 | |
13 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION = range(5) | |
14 | |
15 def __init__(self, api, commit_hash, with_patch): | |
16 super(BuildState, self).__init__() | |
17 self.api = api | |
18 self.commit_hash = str(commit_hash) | |
19 if api.m.properties.get('is_test'): | |
20 self._patch_hash = with_patch * '123456' | |
21 else: | |
22 self._patch_hash = with_patch * str(uuid.uuid4()) # pragma: no cover | |
23 self.build_id = None | |
24 if with_patch: | |
25 self.bucket = 'chrome-perf-tryjob' | |
26 else: | |
27 self.bucket = 'chrome-perf' | |
28 self.build_file_path = self._get_build_file_path() | |
29 | |
30 def _get_build_file_path(self): | |
31 revision_suffix = '%s.zip' % (self.commit_hash + self._patch_hash) | |
32 return self._get_platform_gs_prefix() + revision_suffix | |
33 | |
34 def _get_platform_gs_prefix(self): # pragma: no cover | |
35 bot_name = self.api.m.properties.get('buildername', '') | |
36 if 'win' in bot_name: | |
37 if any(b in bot_name for b in ['x64', 'gpu']): | |
38 return 'gs://%s/Win x64 Builder/full-build-win32_' % self.bucket | |
39 return 'gs://%s/Win Builder/full-build-win32_' % self.bucket | |
40 if 'android' in bot_name: | |
41 if 'nexus9' in bot_name: | |
42 return 'gs://%s/android_perf_rel_arm64/full-build-linux_' % self.bucket | |
43 return 'gs://%s/android_perf_rel/full-build-linux_' % self.bucket | |
44 if 'mac' in bot_name: | |
45 return 'gs://%s/Mac Builder/full-build-mac_' % self.bucket | |
46 return 'gs://%s/Linux Builder/full-build-linux' % self.bucket | |
47 | |
48 def is_completed(self): | |
49 result = self.api.m.buildbucket.get_build(self.build_id) | |
50 return result.stdout['status'] == 'COMPLETED' | |
51 | |
52 def is_build_archived(self): # pragma: no cover | |
53 result = self.api.m.buildbucket.get_build(self.build_id) | |
54 return result.stdout['result'] == 'SUCCESS' | |
OLD | NEW |