Skip to content

Commit

Permalink
Merge branch 'describe_fix' of git://github.com/eddie-dunn/buildbot
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Sep 27, 2013
2 parents 09ba69e + b4caddf commit 7415c59
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 53 deletions.
20 changes: 18 additions & 2 deletions master/buildbot/process/buildstep.py
Expand Up @@ -460,9 +460,15 @@ class BuildStep(object, properties.PropertiesMixin):
'useProgress',
'doStepIf',
'hideStepIf',
'description',
'descriptionDone',
'descriptionSuffix',
]

name = "generic"
description = None # set this to a list of short strings to override
descriptionDone = None # alternate description when the step is complete
descriptionSuffix = None # extra information to append to suffix
locks = []
progressMetrics = () # 'time' is implicit
useProgress = True # set to False if step is really unpredictable
Expand Down Expand Up @@ -491,9 +497,19 @@ def __new__(klass, *args, **kwargs):
self._factory = _BuildStepFactory(klass, *args, **kwargs)
return self

def describe(self, done=False):
def _describe(self, done=False):
if self.descriptionDone and done:
return self.descriptionDone
elif self.description:
return self.description
return [self.name]

def describe(self, done=False):
desc = self._describe(done)
if self.descriptionSuffix:
desc = desc + self.descriptionSuffix
return desc

def setBuild(self, build):
self.build = build

Expand Down Expand Up @@ -784,7 +800,7 @@ def runCommand(self, c):
c.buildslave = self.buildslave
d = c.run(self, self.remote)
return d

@staticmethod
def _maybeEvaluate(value, *args, **kwargs):
if callable(value):
Expand Down
11 changes: 0 additions & 11 deletions master/buildbot/steps/shell.py
Expand Up @@ -73,10 +73,6 @@ class ShellCommand(buildstep.LoggingBuildStep):
'slaveEnvironment', 'remote_kwargs', 'command',
'description', 'descriptionDone', 'descriptionSuffix']

description = None # set this to a list of short strings to override
descriptionDone = None # alternate description when the step is complete
descriptionSuffix = None # extra information to append to suffix

command = None # set this to a command, or set in kwargs
# logfiles={} # you can also set 'logfiles' to a dictionary, and it
# will be merged with any logfiles= argument passed in
Expand Down Expand Up @@ -160,13 +156,6 @@ def getWorkdir(self):
def setCommand(self, command):
self.command = command

def describe(self, done=False):
desc = self._describe(done)
if self.descriptionSuffix:
desc = desc[:]
desc.extend(self.descriptionSuffix)
return desc

def _describe(self, done=False):
"""Return a list of short strings to describe this step, for the
status display. This uses the first few words of the shell command.
Expand Down
28 changes: 28 additions & 0 deletions master/buildbot/test/unit/test_process_buildstep.py
Expand Up @@ -215,6 +215,34 @@ def createException(*args, **kwargs):
d.addCallback(lambda _ : self.assertTrue(called[0]))
return d

def test_describe(self):
description = ['oogaBooga']
descriptionDone = ['oogaBooga done!']
step = buildstep.BuildStep(description=description,
descriptionDone=descriptionDone)
self.assertEqual(step.describe(), description)
self.assertEqual(step.describe(done=True), descriptionDone)

step2 = buildstep.BuildStep()
self.assertEqual(step2.describe(), [step2.name])
self.assertEqual(step2.describe(done=True), [step2.name])

def test_describe_suffix(self):
description = ['oogaBooga']
descriptionDone = ['oogaBooga done!']
descriptionSuffix = ['oogaBooga suffix']

step = buildstep.BuildStep(description=description,
descriptionDone=descriptionDone,
descriptionSuffix=descriptionSuffix)
self.assertEqual(step.describe(), description + descriptionSuffix)
self.assertEqual(step.describe(done=True),
descriptionDone + descriptionSuffix)

step2 = buildstep.BuildStep(descriptionSuffix=descriptionSuffix)
self.assertEqual(step2.describe(), [step2.name] + descriptionSuffix)
self.assertEqual(step2.describe(done=True),
[step2.name] + descriptionSuffix)

class TestLoggingBuildStep(unittest.TestCase):

Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/test/unit/test_steps_master.py
Expand Up @@ -207,8 +207,8 @@ def tearDown(self):
def test_simple(self):
self.setupStep(master.SetProperty(property="testProperty", value=Interpolate("sch=%(prop:scheduler)s, slave=%(prop:slavename)s")))
self.properties.setProperty('scheduler', 'force', source='SetProperty', runtime=True)
self.properties.setProperty('slavename', 'testSlave', source='SetPropery', runtime=True)
self.expectOutcome(result=SUCCESS, status_text=["SetProperty"])
self.properties.setProperty('slavename', 'testSlave', source='SetProperty', runtime=True)
self.expectOutcome(result=SUCCESS, status_text=["Set"])
self.expectProperty('testProperty', 'sch=force, slave=testSlave', source='SetProperty')
return self.runStep()

Expand All @@ -224,6 +224,6 @@ def test_simple(self):
self.setupStep(master.LogRenderable(content=Interpolate('sch=%(prop:scheduler)s, slave=%(prop:slavename)s')))
self.properties.setProperty('scheduler', 'force', source='TestSetProperty', runtime=True)
self.properties.setProperty('slavename', 'testSlave', source='TestSetProperty', runtime=True)
self.expectOutcome(result=SUCCESS, status_text=['LogRenderable'])
self.expectOutcome(result=SUCCESS, status_text=['Logged'])
self.expectLogfile('Output', pprint.pformat('sch=force, slave=testSlave'))
return self.runStep()
14 changes: 13 additions & 1 deletion master/docs/developer/cls-buildsteps.rst
Expand Up @@ -9,7 +9,7 @@ This section describes the base classes. The "leaf" classes are described in :d
BuildStep
---------

.. py:class:: BuildStep(name, locks, haltOnFailure, flunkOnWarnings, flunkOnFailure, warnOnWarnings, warnOnFailure, alwaysRun, progressMetrics, useProgress, doStepIf, hideStepIf)
.. py:class:: BuildStep(name, description, descriptionDone, descriptionSuffix, locks, haltOnFailure, flunkOnWarnings, flunkOnFailure, warnOnWarnings, warnOnFailure, alwaysRun, progressMetrics, useProgress, doStepIf, hideStepIf)
All constructor arguments must be given as keyword arguments.
Each constructor parameter is copied to the corresponding attribute.
Expand All @@ -18,6 +18,18 @@ BuildStep
The name of the step.

.. py:attribute:: description
The description of the step.

.. py:attribute:: descriptionDone
The description of the step after it has finished.

.. py:attribute:: descriptionSuffix
Any extra information to append to the description.

.. py:attribute:: locks
List of locks for this step; see :ref:`Interlocks`.
Expand Down
84 changes: 48 additions & 36 deletions master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -92,6 +92,53 @@ Arguments common to all :class:`BuildStep` subclasses:
if ``True``, this build step will always be run, even if a previous buildstep
with ``haltOnFailure=True`` has failed.

.. index:: Buildstep Parameter; description

``description``
This will be used to describe the command (on the Waterfall display)
while the command is still running. It should be a single
imperfect-tense verb, like `compiling` or `testing`. The preferred
form is a list of short strings, which allows the HTML
displays to create narrower columns by emitting a <br> tag between each
word. You may also provide a single string.

.. index:: Buildstep Parameter; descriptionDone

``descriptionDone``
This will be used to describe the command once it has finished. A
simple noun like `compile` or `tests` should be used. Like
``description``, this may either be a list of short strings or a
single string.

If neither ``description`` nor ``descriptionDone`` are set, the
actual command arguments will be used to construct the description.
This may be a bit too wide to fit comfortably on the Waterfall
display.

All subclasses of :py:class:`BuildStep` will contain the description
attributes. Consequently, you could add a :py:class:`ShellCommand`
step like so:

::

from buildbot.steps.shell import ShellCommand
f.addStep(ShellCommand(command=["make", "test"],
description=["testing"],
descriptionDone=["tests"]))

.. index:: Buildstep Parameter; descriptionSuffix

``descriptionSuffix``
This is an optional suffix appended to the end of the description (ie,
after ``description`` and ``descriptionDone``). This can be used to distinguish
between build steps that would display the same descriptions in the waterfall.
This parameter may be set to list of short strings, a single string, or ``None``.

For example, a builder might use the ``Compile`` step to build two different
codebases. The ``descriptionSuffix`` could be set to `projectFoo` and `projectBar`,
respectively for each step, which will result in the full descriptions
`compiling projectFoo` and `compiling projectBar` to be shown in the waterfall.

.. index:: Buildstep Parameter; doStepIf

``doStepIf``
Expand Down Expand Up @@ -950,7 +997,7 @@ The :bb:step`Darcs` build step performs a `Darcs <http://darcs.net/>`_
checkout or update. ::

from buildbot.steps.source.darcs import Darcs
factory.addStep(Darcs(repourl='http://path/to/repo',
factory.addStep(Darcs(repourl='http://path/to/repo',
mode='full', method='clobber', retry=(10, 1)))

Darcs step takes the following arguments:
Expand Down Expand Up @@ -1860,41 +1907,6 @@ The :bb:step:`ShellCommand` arguments are:
if the command takes longer than this many seconds, it will be
killed. This is disabled by default.

``description``
This will be used to describe the command (on the Waterfall display)
while the command is still running. It should be a single
imperfect-tense verb, like `compiling` or `testing`. The preferred
form is a list of short strings, which allows the HTML
displays to create narrower columns by emitting a <br> tag between each
word. You may also provide a single string.

``descriptionDone``
This will be used to describe the command once it has finished. A
simple noun like `compile` or `tests` should be used. Like
``description``, this may either be a list of short strings or a
single string.

If neither ``description`` nor ``descriptionDone`` are set, the
actual command arguments will be used to construct the description.
This may be a bit too wide to fit comfortably on the Waterfall
display. ::

from buildbot.steps.shell import ShellCommand
f.addStep(ShellCommand(command=["make", "test"],
description=["testing"],
descriptionDone=["tests"]))

``descriptionSuffix``
This is an optional suffix appended to the end of the description (ie,
after ``description`` and ``descriptionDone``). This can be used to distinguish
between build steps that would display the same descriptions in the waterfall.
This parameter may be set to list of short strings, a single string, or ``None``.

For example, a builder might use the ``Compile`` step to build two different
codebases. The ``descriptionSuffix`` could be set to `projectFoo` and `projectBar`,
respectively for each step, which will result in the full descriptions
`compiling projectFoo` and `compiling projectBar` to be shown in the waterfall.

``logEnviron``
If this option is ``True`` (the default), then the step's logfile will describe the
environment variables on the slave. In situations where the environment is not
Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -14,6 +14,8 @@ Master
Features
~~~~~~~~

* The attributes ``description``, ``descriptionDone`` and ``descriptionSuffix`` have been moved from :py:class:`ShellCommand` to its superclass :py:class:`BuildStep` so that any class that inherits from :py:class:`BuildStep` can provide a suitable description of itself.

* A new :py:class:`FlattenList` Renderable has been added which can flatten nested lists.

* Builder configurations can now include a ``description``, which will appear in the web UI to help humans figure out what the builder does.
Expand Down

0 comments on commit 7415c59

Please sign in to comment.