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

Side by Side Diff: master/skia_master_scripts/skia_build_step.py

Issue 175523003: Raise Exception instead of failure when some steps fail. (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Include ALL the factory config files Created 6 years, 9 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
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """ Skia-specific subclass of BuildStep """ 5 """ Skia-specific subclass of BuildStep """
6 6
7 7
8 from buildbot.status.logfile import STDOUT 8 from buildbot.status.logfile import STDOUT
9 from master.log_parser import retcode_command 9 from master.log_parser import retcode_command
10 import re 10 import re
11 11
12 12
13 class SkiaBuildStep(retcode_command.ReturnCodeCommand): 13 class SkiaBuildStep(retcode_command.ReturnCodeCommand):
14 """ BuildStep wrapper for Skia. Allows us to define properties of BuildSteps 14 """ BuildStep wrapper for Skia. Allows us to define properties of BuildSteps
15 to be used by ShouldDoStep. This is necessary because the properties referred 15 to be used by ShouldDoStep. This is necessary because the properties referred
16 to by BuildStep.getProperty() are scoped for the entire duration of the build. 16 to by BuildStep.getProperty() are scoped for the entire duration of the build.
17 """ 17 """
18 def __init__(self, is_upload_step=False, is_rebaseline_step=False, 18 def __init__(self, is_upload_step=False, is_rebaseline_step=False,
19 get_props_from_stdout=None, **kwargs): 19 get_props_from_stdout=None, exception_on_failure=False,
20 **kwargs):
20 """ Instantiates a new SkiaBuildStep. 21 """ Instantiates a new SkiaBuildStep.
21 22
22 is_upload_step: boolean indicating whether this step should be skipped when 23 is_upload_step: boolean indicating whether this step should be skipped when
23 the buildbot is not performing uploads. 24 the buildbot is not performing uploads.
24 is_rebaseline_step: boolean indicating whether this step is required for 25 is_rebaseline_step: boolean indicating whether this step is required for
25 rebaseline-only builds. 26 rebaseline-only builds.
26 get_props_from_stdout: optional dictionary. Keys are strings indicating 27 get_props_from_stdout: optional dictionary. Keys are strings indicating
27 build properties to set based on the output of this step. Values are 28 build properties to set based on the output of this step. Values are
28 strings containing regular expressions for parsing the property from 29 strings containing regular expressions for parsing the property from
29 the output of the step. 30 the output of the step.
31 exception_on_failure: boolean indicating whether to raise an exception if
32 this step fails. This causes the step to go purple instead of red, and
33 causes the build to stop. Should be used if the build step's failure is
34 typically transient or results from an infrastructure failure rather
35 than a code change.
30 """ 36 """
31 self._is_upload_step = is_upload_step 37 self._is_upload_step = is_upload_step
32 self._is_rebaseline_step = is_rebaseline_step 38 self._is_rebaseline_step = is_rebaseline_step
33 self._get_props_from_stdout = get_props_from_stdout 39 self._get_props_from_stdout = get_props_from_stdout
40 self._exception_on_failure = exception_on_failure
34 41
35 # self._changed_props will be a dictionary containing the build properties 42 # self._changed_props will be a dictionary containing the build properties
36 # which were updated by this BuildStep. Those properties will be displayed 43 # which were updated by this BuildStep. Those properties will be displayed
37 # in the label for this step. 44 # in the label for this step.
38 self._changed_props = None 45 self._changed_props = None
39 46
40 retcode_command.ReturnCodeCommand.__init__(self, **kwargs) 47 retcode_command.ReturnCodeCommand.__init__(self, **kwargs)
41 self.name = ''.join(self.description) 48 self.name = ''.join(self.description)
42 49
43 def IsUploadStep(self): 50 def IsUploadStep(self):
44 return self._is_upload_step 51 return self._is_upload_step
45 52
46 def IsRebaselineStep(self): 53 def IsRebaselineStep(self):
47 return self._is_rebaseline_step 54 return self._is_rebaseline_step
48 55
49 def commandComplete(self, cmd): 56 def commandComplete(self, cmd):
50 """ Override of BuildStep's commandComplete method which allows us to parse 57 """ Override of BuildStep's commandComplete method which allows us to parse
51 build properties from the output of this step. """ 58 build properties from the output of this step. """
59 if cmd.rc and self._exception_on_failure:
60 raise Exception('Command marked exception_on_failure failed.')
52 if self._get_props_from_stdout and cmd.rc == 0: 61 if self._get_props_from_stdout and cmd.rc == 0:
53 log = cmd.logs['stdio'] 62 log = cmd.logs['stdio']
54 stdout = ''.join(log.getChunks([STDOUT], onlyText=True)) 63 stdout = ''.join(log.getChunks([STDOUT], onlyText=True))
55 self._changed_props = {} 64 self._changed_props = {}
56 for prop, regex in self._get_props_from_stdout.iteritems(): 65 for prop, regex in self._get_props_from_stdout.iteritems():
57 matches = re.search(regex, stdout) 66 matches = re.search(regex, stdout)
58 if not matches: 67 if not matches:
59 raise Exception('Unable to parse %s from stdout.' % prop) 68 raise Exception('Unable to parse %s from stdout.' % prop)
60 groups = matches.groups() 69 groups = matches.groups()
61 if len(groups) != 1: 70 if len(groups) != 1:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 # If this step uploads results (and thus overwrites the most recently uploaded 112 # If this step uploads results (and thus overwrites the most recently uploaded
104 # results), only run it on scheduled builds (i.e. most recent revision) or if 113 # results), only run it on scheduled builds (i.e. most recent revision) or if
105 # the "force_upload" property was set. 114 # the "force_upload" property was set.
106 if step.IsUploadStep() and \ 115 if step.IsUploadStep() and \
107 not _HasProperty(step, 'scheduler') and \ 116 not _HasProperty(step, 'scheduler') and \
108 not _HasProperty(step, 'force_upload'): 117 not _HasProperty(step, 'force_upload'):
109 return False 118 return False
110 119
111 # Unless we have determined otherwise, run the step. 120 # Unless we have determined otherwise, run the step.
112 return True 121 return True
OLDNEW
« no previous file with comments | « master/skia_master_scripts/factory.py ('k') | tools/tests/factory_configuration/expected/Build-Mac10.6-GCC-x86-Debug » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698