Fetchez le Python

Technical blog on the Python programming language, in a pure Frenglish style

Pimp my buildbot !

Edit : this post is a bit deprecated, the project is now called collective.buildbot. See: http://pypi.python.org/pypi/collective.buildbot

When a project team use Test-Driven Development to build the code (everyone should), the next step is to set up automate builds, as explained in continous integration.

This is where Buildbot is great. It is easy and flexible to install, even more since Twisted has been eggified. A few easy_install steps are now sufficient to create a buildbot waterfall. Configuring a buildbot requires writing a few Python scripts though, and this has to be done everytime a project starts.

In my work, I need to be able to set buildbots in a matter of minutes, and they are always similar. They just need a buildmaster, a buildslave, and a few rules.

A first attempt to make things easier is to write a Python Paste script that generates default files. This is not very flexible though, as upgrades are still a bit tedious.

A more interesting solution is to provide zc.buildout recipes that take care of buildmaster and buildslave generation, through a very simple configuration file.

We have started this project, in order to be able to launch buildbot within a buildout.

The project has three parts:

  • iw.buildbot: a thin layer on the top of Buildbot that allows to drive it with configuration files, instead of Python code. In other words, it makes buildbot configuration based on declarative configuration file and dynamic Python code, instead of declarative Python code.
  • iw.recipe.buildmaster: a zc.buildout recipe that creates a buildbot instance together with configuration files.

The result is that creating a buildbot is done in a few lines in the buildout.cfg file:

[buildout]
parts =
  buildmaster
  linux_debian

[buildmaster]
recipe = iw.recipe.buildmaster
project-name = Ingeniweb Public buildbot
project-url = http://ingeniweb.com
port = 8999
wport = 9000
url = http://buildbot.ingeniweb.com
slaves =
  linux_debian    xxxxx
projects =
  iw.recipes 

[linux_debian]
recipe = iw.recipe.buildslave
host = localhost
port = ${buildmaster:port}
password = xxxx 

[iw.recipes]
slave-name=linux_debian
base-url=http://ingeniweb.svn.sourceforge.net
repository=/svnroot/ingeniweb/projects/iw.recipes/
branch=buildout
build-sequence =
    python bootstrap.py
    bin/buildout 

test-sequence =
    bin/test -v --exit-with-status
  • buildmaster defines the project name and url, the buildbot web port, slave port and url, and a list of slaves and projects.
  • each project has his own section, where the Subversion path is defined, as well as the build sequence and the test sequence.
  • each slave is defined in its section

From there other buildouts can be created to group packages to be tested, and to define a script that can be used for tests. For Zope applications, that would be zopectl of course, as long as it is used with –exit-with-status.

This is the case for iw.recipes: it grabs all iw.recipes.* eggs to hook them to a testrunner.

The result can be see here: http://buildbot.ingeniweb.com

The next steps are to make sure everything works fine under Windows, and see how things goes in various projects, then make it work with all kinds of VCS and schedulers.

I will probably propose a sprint task on this in Paris sprint and see if the package meets interest.

Filed under: plone, python, quality, sprint, zope

9 Responses

  1. Godefroid Chapelle says:

    Very nice work !

    Why do you specify repository in two pieces like :

    repository=/svnroot/ingeniweb/projects/iw.recipes/
    branch=buildout

    instead of simpler and more flexible

    repository=/svnroot/ingeniweb/projects/iw.recipes/buildout

  2. Tarek Ziadé says:

    @Godefroid: Thanks !

    Because at this time, I pass those parameters directly to buildbot, and this is how the Subversion step object gets them. This not flexible at all and will be changed soon, providing a “VCS” parameter (hg, svn, etc) together with extra parameters. The current version is hardcoded to wokr with Svn;

  3. [...] Jean-Francois (and Kai yesterday) are working on “Pimp my Buildbot“: configure and launch a complete buildbot system in a matter of minutes, using a simple [...]

  4. [...] in plone, python, quality, sprint, zope tagged buildbot, community at 9:24 am by Tarek Ziadé The Pimp my Buildbot project that was started here at Ingeniweb some time ago, to be able to set up a buildbot in a [...]

  5. [...] 21, 2008 at 21:13 (software engineering) (buildbot, testing) Some time ago Tarek Ziade started a project to make it easier to configure and set up a Buildbot environment using zc.buildout. During the [...]

  6. x-ip says:

    Good article! … i’ll take a look how this works with us ^.^” … thanks a lot for share the knowledge!

  7. digasm says:

    I’m a little confused with this.

    How exactly would I use this script to create my own buildbot ?

  8. Tarek Ziadé says:

    @digasm: You need to build a buildout, look at zc.buildout on PyPI. collective.buildbot is a set of recipes that will let you define a buildbot in a buildout configuration file.

  9. Gostixel says:

    Хм,несогласен с предыдущими блоггерами
    ) Bye

Leave a Reply