Fix unit tests for Python in a twistd instance
[OpenSRF.git] / examples / buildbot.cfg
1 # -*- python -*-
2 # vim: set syntax=python:et:ts=4:sw=4:
3
4 # This is a sample buildmaster config file. It must be installed as
5 # 'master.cfg' in your buildmaster's base directory.
6
7 # This is the dictionary that the buildmaster pays attention to. We also use
8 # a shorter alias to save typing.
9 c = BuildmasterConfig = {}
10
11 ####### BUILDSLAVES
12
13 # The 'slaves' list defines the set of recognized buildslaves. Each element is
14 # a BuildSlave object, specifying a username and password.  The same username and
15 # password must be configured on the slave.
16 from buildbot.buildslave import BuildSlave
17 c['slaves'] = [
18     BuildSlave("opensrf-slave", "XXX", max_builds=1),
19     BuildSlave("eg-slave", "XXX", max_builds=1),
20     BuildSlave("eg-u804", "XXX", max_builds=1),
21     BuildSlave("eg-u1004", "XXX", max_builds=1)
22 ]
23
24 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
25 # This must match the value configured into the buildslaves (with their
26 # --master option)
27 c['slavePortnum'] = XXX
28
29 # Branches and distros to build
30 osrf_branches = ('trunk', 'rel_1_6', 'rel_2_0')
31 osrf_distros = ({'ubuntu-10.04-x86_64': 'opensrf-slave'})
32 eg_branches = ('trunk', 'rel_1_6_1', 'rel_2_0', 'rel_2_1')
33 eg_distros = (
34     {'debian-6.00-x86_64': 'eg-slave'}, # UPEI
35     {'ubuntu-8.04-x86': 'eg-u804'},     # GPLS
36     {'ubuntu-10.04-x86': 'eg-u1004'}    # GPLS
37 )
38
39 ####### CHANGESOURCES
40
41 # the 'change_source' setting tells the buildmaster how it should find out
42 # about source code changes.  Here we point to OpenSRF:
43 def split_file_branches_trunk(path):
44     pieces = path.split('/')
45     if pieces[0] == 'trunk':
46         return ('trunk', '/'.join(pieces[1:]))
47     elif pieces[0] == 'branches':
48         return ('/'.join(pieces[0:2]),
49                 '/'.join(pieces[2:]))
50     else:
51         return None
52
53 from buildbot.changes import svnpoller
54 c['change_source'] = (
55         svnpoller.SVNPoller(
56                 project='OpenSRF',
57                 svnurl='svn://svn.open-ils.org/OpenSRF',
58                 split_file=svnpoller.split_file_branches,
59                 pollinterval=600),
60         svnpoller.SVNPoller(
61                 project='Evergreen',
62                 svnurl='svn://svn.open-ils.org/ILS',
63                 split_file=svnpoller.split_file_branches,
64                 pollinterval=600)
65 )
66
67 ####### FILTERS
68 from buildbot.schedulers.filter import ChangeFilter
69 trunk_filter = ChangeFilter(project='OpenSRF', branch=None)
70 rel_1_6_filter = ChangeFilter(project='OpenSRF', branch="branches/rel_1_6")
71 rel_2_0_filter = ChangeFilter(project='OpenSRF', branch="branches/rel_2_0")
72 eg_rel_1_6_1_filter = ChangeFilter(project='Evergreen', branch="branches/rel_1_6_1")
73 eg_rel_2_0_filter = ChangeFilter(project='Evergreen', branch="branches/rel_2_0")
74 eg_rel_2_1_filter = ChangeFilter(project='Evergreen', branch="branches/rel_2_1")
75 eg_trunk_filter = ChangeFilter(project='Evergreen', branch=None)
76
77 ####### SCHEDULERS
78
79 # Configure the Schedulers, which decide how to react to incoming changes.  In this
80 # case, just kick off a 'runtests' build
81
82 from buildbot.scheduler import Scheduler
83 c['schedulers'] = []
84 c['schedulers'].append(Scheduler(name="osrf-trunk-full",
85             treeStableTimer=300,
86             change_filter=trunk_filter,
87             builderNames=["osrf-trunk-ubuntu-10.04-x86_64"]))
88
89 c['schedulers'].append(Scheduler(name="osrf-rel_1_6",
90             treeStableTimer=300,
91             change_filter=rel_1_6_filter,
92             builderNames=["osrf-rel_1_6-ubuntu-10.04-x86_64"]))
93
94 c['schedulers'].append(Scheduler(name="osrf-rel_2_0",
95             treeStableTimer=300,
96             change_filter=rel_2_0_filter,
97             builderNames=["osrf-rel_2_0-ubuntu-10.04-x86_64"]))
98
99 c['schedulers'].append(Scheduler(name="evergreen-rel_1_6_1",
100             treeStableTimer=300,
101             change_filter=eg_rel_1_6_1_filter,
102             builderNames=[
103                 "evergreen-rel_1_6_1-debian-6.00-x86_64",
104                 "evergreen-rel_1_6_1-ubuntu-8.04-x86",
105                 "evergreen-rel_1_6_1-ubuntu-10.04-x86"
106             ]))
107
108 c['schedulers'].append(Scheduler(name="evergreen-rel_2_0",
109             treeStableTimer=300,
110             change_filter=eg_rel_2_0_filter,
111             builderNames=[
112                 "evergreen-rel_2_0-debian-6.00-x86_64",
113                 "evergreen-rel_2_0-ubuntu-8.04-x86",
114                 "evergreen-rel_2_0-ubuntu-10.04-x86"
115             ]))
116
117 c['schedulers'].append(Scheduler(name="evergreen-rel_2_1",
118             treeStableTimer=300,
119             change_filter=eg_rel_2_1_filter,
120             builderNames=[
121                 "evergreen-rel_2_1-debian-6.00-x86_64",
122                 "evergreen-rel_2_1-ubuntu-8.04-x86",
123                 "evergreen-rel_2_1-ubuntu-10.04-x86"
124             ]))
125
126 c['schedulers'].append(Scheduler(name="evergreen-trunk",
127             treeStableTimer=300,
128             change_filter=eg_trunk_filter,
129             builderNames=[
130                 "evergreen-trunk-debian-6.00-x86_64",
131                 "evergreen-trunk-ubuntu-8.04-x86",
132                 "evergreen-trunk-ubuntu-10.04-x86"
133             ]))
134
135 ####### BUILDERS
136
137 # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
138 # what steps, and which slaves can execute them.  Note that any particular build will
139 # only take place on one slave.
140
141 from buildbot.process.factory import BuildFactory
142 from buildbot.steps import source 
143 from buildbot.steps import shell
144 from buildbot.steps import python
145 from buildbot.steps import python_twisted
146
147 osrf_factory = BuildFactory()
148 # check out the source
149 osrf_factory.addStep(source.SVN(
150             baseURL='svn://svn.open-ils.org/OpenSRF/',
151             defaultBranch='trunk',
152             mode='copy'))
153
154 # bootstrap the code
155 osrf_factory.addStep(shell.ShellCommand(command=["./autogen.sh"]))
156
157 # configure (default args for now)
158 osrf_factory.addStep(shell.Configure())
159
160 # compile the code
161 osrf_factory.addStep(shell.Compile(command=["make"]))
162
163 # run the Perl unit tests
164 osrf_factory.addStep(shell.PerlModuleTest(workdir="build/src/perl"))
165
166 # run the Python unit tests (available after rel_1_6)
167 def has_python_unit_test(step):
168     return step.build.getProperty('branch') != 'branches/rel_1_6'
169
170 osrf_factory.addStep(python_twisted.Trial(
171     doStepIf=has_python_unit_test,
172     testpath="build",
173     tests="src/python/tests/json_test.py"))
174
175 # report on the Python code
176 osrf_factory.addStep(python.PyLint(
177     env={"PYTHONPATH": ["src/python"]},
178     flunkOnFailure=False,
179     command=["pylint", 
180         "--output-format=parseable",
181         "src/python/opensrf.py",
182         "src/python/osrf/app.py",
183         "src/python/osrf/cache.py",
184         "src/python/osrf/conf.py",
185         "src/python/osrf/const.py",
186         "src/python/osrf/ex.py",
187         "src/python/osrf/gateway.py",
188         "src/python/osrf/http_translator.py",
189         "src/python/osrf/json.py",
190         "src/python/osrf/log.py",
191         "src/python/osrf/net_obj.py",
192         "src/python/osrf/net.py",
193         "src/python/osrf/server.py",
194         "src/python/osrf/ses.py",
195         "src/python/osrf/set.py",
196         "src/python/osrf/stack.py",
197         "src/python/osrf/system.py",
198         "src/python/osrf/xml_obj.py",
199         "src/python/osrf/apps/example.py"]))
200
201 eg_factory = BuildFactory()
202 # check out the source
203 eg_factory.addStep(source.SVN(
204             baseURL='svn://svn.open-ils.org/ILS/',
205             defaultBranch='trunk',
206             mode='copy'))
207
208 # bootstrap the code
209 eg_factory.addStep(shell.ShellCommand(command=["./autogen.sh"]))
210
211 # configure (default args for now)
212 eg_factory.addStep(shell.Configure())
213
214 # compile the code
215 eg_factory.addStep(shell.Compile(command=["make"]))
216
217 perldir = 'build/Open-ILS/src/perlmods'
218 class PerlModuleTestMFHDMadness(shell.PerlModuleTest):
219     'Override PerlModuleTest with nonstandard library location for testlib.pm'
220     command = ['prove', '--lib', 'lib', '-I', 'lib/OpenILS/Utils/MFHD/test', '-r', 't']
221     total = 0
222
223 def has_perl_unit_tests(step):
224     'Only run Perl tests if there are tests'
225     if (step.build.getProperty('branch') == 'branches/rel_1_6_1'):
226         return False
227     elif (step.build.getProperty('branch') == 'branches/rel_2_0'):
228         return False
229     return True
230
231 # run the Perl unit tests
232 eg_factory.addStep(PerlModuleTestMFHDMadness(
233     doStepIf=has_perl_unit_tests,
234     workdir=perldir)
235 )
236
237 # report on the Python code
238 eg_factory.addStep(python.PyLint(
239     env={"PYTHONPATH": ["Open-ILS/src/python"]},
240     flunkOnFailure=False,
241     command=["pylint", 
242         "--output-format=parseable",
243         "Open-ILS/src/python/setup.py",
244         "Open-ILS/src/python/oils/const.py",
245         "Open-ILS/src/python/oils/event.py",
246         "Open-ILS/src/python/oils/__init__.py",
247         "Open-ILS/src/python/oils/org.py",
248         "Open-ILS/src/python/oils/srfsh.py",
249         "Open-ILS/src/python/oils/system.py",
250         "Open-ILS/src/python/oils/utils/csedit.py",
251         "Open-ILS/src/python/oils/utils/idl.py",
252         "Open-ILS/src/python/oils/utils/__init__.py",
253         "Open-ILS/src/python/oils/utils/utils.py"
254     ]
255 ))
256
257 from buildbot.config import BuilderConfig
258
259 c['builders'] = []
260
261 for branch in osrf_branches:
262     for distro, slave in osrf_distros:
263         build = "osrf-%s-%s" % (branch, distro)
264         c['builders'].append(name=build, slavenames=slave, factory=osrf_factory)
265         
266 for branch in eg_branches:
267     for distro, slave in eg_distros:
268         build = "evergreen-%s-%s" % (branch, distro)
269         c['builders'].append(name=build, slavenames=slave, factory=eg_factory)
270
271 ####### STATUS TARGETS
272
273 # 'status' is a list of Status Targets. The results of each build will be
274 # pushed to these targets. buildbot/status/*.py has a variety to choose from,
275 # including web pages, email senders, and IRC bots.
276
277 c['status'] = []
278
279 from buildbot.status import html
280 from buildbot.status.web import auth, authz
281
282 users = [('XXX', 'XXX'), ('XXX', 'XXX')]
283 authz_cfg = authz.Authz(
284     auth=auth.BasicAuth(users),
285     # change any of these to True to enable; see the manual for more
286     # options
287     gracefulShutdown = False,
288     forceBuild = 'auth', # use this to test your slave once it is set up
289     forceAllBuilds = False,
290     pingBuilder = False,
291     stopBuild = False,
292     stopAllBuilds = False,
293     cancelPendingBuild = False,
294 )
295 c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
296
297 # Send mail when a build is broken
298 from buildbot.status.mail import MailNotifier
299 mn = MailNotifier(
300     fromaddr="buildbot@testing.esilibrary.com",
301     sendToInterestedUsers=False,
302     mode='problem',
303     extraRecipients=["dan@coffeecode.net","open-ils-dev@list.georgialibraries.org"])
304
305 # Uncomment to actually send mail
306 # c['status'].append(mn)
307
308 ####### PROJECT IDENTITY
309
310 # the 'projectName' string will be used to describe the project that this
311 # buildbot is working on. For example, it is used as the title of the
312 # waterfall HTML page. The 'projectURL' string will be used to provide a link
313 # from buildbot HTML pages to your project's home page.
314
315 c['projectName'] = "Evergreen and OpenSRF"
316 c['projectURL'] = "http://evergreen-ils.org/"
317
318 # the 'buildbotURL' string should point to the location where the buildbot's
319 # internal web server (usually the html.WebStatus page) is visible. This
320 # typically uses the port number set in the Waterfall 'status' entry, but
321 # with an externally-visible host name which the buildbot cannot figure out
322 # without some help.
323
324 c['buildbotURL'] = "http://testing.evergreen-ils.org/buildbot/"
325
326 ####### DB URL
327
328 # This specifies what database buildbot uses to store change and scheduler
329 # state.  You can leave this at its default for all but the largest
330 # installations.
331 c['db_url'] = "sqlite:///state.sqlite"
332