Created
October 25, 2016 16:51
-
-
Save sa2ajj/8af23c89e8700df292d4cd100ecb173a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import defer | |
from buildbot.process.buildstep import BuildStep | |
from buildbot.status.results import FAILURE | |
from buildbot.status.results import SUCCESS | |
class CheckForFailures(BuildStep): | |
""" | |
this step fails when any of the given build steps fail | |
""" | |
name = 'check_failures' | |
description = 'Checking' | |
descriptionDone = 'Checked' | |
renderables = ( | |
'important_steps', | |
) | |
def __init__(self, important_steps=None, **kwargs): | |
assert isinstance(important_steps, (list, tuple)) | |
assert all(isinstance(step, str) for step in important_steps) | |
BuildStep.__init__(self, **kwargs) | |
assert important_steps is not None | |
# 0.8.x does not support rendering of sets, hence keep the original list/tuple in a hope it's not a set | |
self.important_steps = important_steps | |
@defer.inlineCallbacks | |
def run(self): | |
""" | |
check the build's steps and fail if any has failed | |
""" | |
# let's hope self.important_steps was rendered properly | |
important_steps = set(self.important_steps) | |
failed_steps = set() | |
for step in self.build.build_status.getSteps(): | |
if step.isFinished() and step.getResults()[0] == FAILURE: | |
failed_steps.add(step.getName()) | |
if important_steps & failed_steps: | |
yield defer.returnValue(FAILURE) | |
else: | |
yield defer.returnValue(SUCCESS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment