Sunday, 19 June 2011

Oh wonderfull build bot

I have several SVN projects here at home and a few that I follow out on
the big wide web. My problem is tracking updates and then building them.
The solution, buildbot.
Now I can have it do the grunt work of polling update and building. I
then watch all this in one single web site. If there is a problem then
it lets me know.
The biggest problem was how to watch serveral repos and only rebuild the
changed one.

All solved :)
so here is my master.cfg


# -*- python -*-
# ex: set syntax=python:
# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.
# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
#k = BuildmasterConfig = {}
####### BUILDSLAVES
# The 'slaves' list defines the set of recognized buildslaves. Each element is
# a BuildSlave object, specifying a username and password.  The same username and
# password must be configured on the slave.
from buildbot.buildslave import BuildSlave
c['slaves'] = [BuildSlave("example-slave", "password"),
BuildSlave("embedded-slave", "password")
]
#k['slaves'] = [BuildSlave("example-slave", "pass")]
# 'slavePortnum' defines the TCP port to listen on for connections from slaves.
# This must match the value configured into the buildslaves (with their
# --master option)
c['slavePortnum'] = 9989
#k['slavePortnum'] = 9989
c['debugPassword'] = "pass"
####### CHANGESOURCES
# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.  Here we point to the buildbot clone of pyflakes.
from buildbot.changes.gitpoller import GitPoller
c['change_source'] = GitPoller(
  'git://github.com/buildbot/pyflakes.git',
branch='master', pollinterval=1200)
from buildbot.changes.svnpoller import SVNPoller
c['change_source'] = SVNPoller(
"svn://localhost/data/svn/CRC_check/CRC_check/trunk/"
, pollinterval=60)
c['change_source'] = SVNPoller(
"svn://localhost/data/svn/hermes-kernel/linux-2.6.39.1/"
, pollinterval=60)
c['change_source'] = [SVNPoller(
"svn://localhost/data/svn/CRC_check/CRC_check/trunk/"
, cachepath="/tmp/crc"
, pollinterval=60
),
SVNPoller(
"svn://localhost/data/svn/hermes-kernel/linux-2.6.39.1/"
, cachepath="/tmp/linux"
, pollinterval=60),
SVNPoller(
"http://domuslink.googlecode.com/svn/trunk/"
, cachepath="/tmp/domus"
, pollinterval=60),
GitPoller(
'git://heyu.org/heyu.git'
, pollinterval=60)
]
####### Filters
from buildbot.changes.filter import ChangeFilter
####### SCHEDULERS
# Configure the Schedulers, which decide how to react to incoming
changes.  In this
# case, just kick off a 'runtests' build
from buildbot.schedulers.filter import ChangeFilter
from buildbot.scheduler import Scheduler
c['schedulers'] = []
c['schedulers'].append(Scheduler(name="crc",
change_filter=ChangeFilter(repository="svn://localhost/data/svn/CRC_check/CRC_check/trunk"),
treeStableTimer=None,
builderNames=["runtests"]))
#c['schedulers'] = []
c['schedulers'].append(Scheduler(name="linux",
change_filter=ChangeFilter(repository="svn://localhost/data/svn/hermes-kernel/linux-2.6.39.1"),
treeStableTimer=None,
builderNames=["linux-2.6.39.1"]))
c['schedulers'].append(Scheduler(name="Domus.Link",
change_filter=ChangeFilter(repository="http://domuslink.googlecode.com/svn/trunk"),
treeStableTimer=None,
builderNames=["Domus.Link"]))
c['schedulers'].append(Scheduler(name="heyu", 
change_filter=ChangeFilter(repository="git://heyu.org/heyu.git"),
treeStableTimer=None,
builderNames=["heyu"]))
####### BUILDERS
# The 'builders' list defines the Builders, which tell Buildbot how to
perform a build:
# what steps, and which slaves can execute them.  Note that any
particular build will
# only take place on one slave.
from buildbot.process.factory import BuildFactory
from buildbot.steps.source import Git
from buildbot.steps.source import SVN
from buildbot.steps.shell import ShellCommand
factory = BuildFactory()
# check out the source
factory.addStep(SVN('svn://localhost/data/svn/CRC_check/CRC_check/trunk/', mode='copy'))
factory.addStep(ShellCommand(command=["cc","procrc.c","-o","procrc"],workdir="build/",usePTY=True))
factory.addStep(ShellCommand(command=["cc","crc.c","crcmodel.c","-o","crc"],workdir="build/",usePTY=True))
f = BuildFactory()
f.addStep(SVN('svn://localhost/data/svn/hermes-kernel/linux-2.6.39.1/',
mode='update'))
f.addStep(ShellCommand(command=["make","defconfig"]))
f.addStep(ShellCommand(command=["make"]))
Domus = BuildFactory()
Domus.addStep(SVN('http://domuslink.googlecode.com/svn/trunk/',
mode='copy'))
heyu = BuildFactory()
heyu.addStep(Git(repourl='git://heyu.org/heyu.git', mode='update'))
heyu.addStep(ShellCommand(command=["./Configure"],workdir="build/",usePTY=True))
heyu.addStep(ShellCommand(command=["make"],workdir="build/",usePTY=True))
heyu.addStep(ShellCommand(command=["/usr/local/bin/heyu","stop"],workdir="build/",usePTY=True))
heyu.addStep(ShellCommand(command=["make","install"],workdir="build/",usePTY=True))
heyu.addStep(ShellCommand(command=["/usr/local/bin/heyu","start"],workdir="build/",usePTY=True))

from buildbot.config import BuilderConfig
c['builders'] = []
c['builders'].append(
BuilderConfig(name="runtests",
slavenames=["example-slave"],
factory=factory))
#k['builders'] = []
c['builders'].append(
BuilderConfig(name="linux-2.6.39.1",
slavenames=["example-slave"],
factory=f))
c['builders'].append(
BuilderConfig(name="Domus.Link",
slavenames=["embedded-slave"],
factory=Domus))

c['builders'].append(
BuilderConfig(name="heyu",
slavenames=["embedded-slave"],
factory=heyu))
####### STATUS TARGETS
# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# including web pages, email senders, and IRC bots.
c['status'] = []
from buildbot.status import html
from buildbot.status.web import auth, authz
authz_cfg=authz.Authz(
# change any of these to True to enable; see the manual for more
# options
gracefulShutdown = False,
forceBuild = True, # use this to test your slave once it is set up
forceAllBuilds = False,
pingBuilder = False,
stopBuild = False,
stopAllBuilds = False,
cancelPendingBuild = False,
)
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
####### PROJECT IDENTITY
# the 'projectName' string will be used to describe the project that
this
# buildbot is working on. For example, it is used as the title of the
# waterfall HTML page. The 'projectURL' string will be used to provide a
link
# from buildbot HTML pages to your project's home page.
c['projectName'] = "one man and a fe electrons"
c['projectURL'] = "http://"
# the 'buildbotURL' string should point to the location where the
buildbot's
# internal web server (usually the html.WebStatus page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry,
but
# with an externally-visible host name which the buildbot cannot figure
out
# without some help.
c['buildbotURL'] = "http://localhost:8010/"
####### DB URL
# This specifies what database buildbot uses to store change and
scheduler
# state.  You can leave this at its default for all but the largest
# installations.
c['db_url'] = "sqlite:///state.sqlite"