summaryrefslogtreecommitdiff
path: root/master.cfg
blob: 875ccce8d739a6e4a82e4bbff69f4f2d2a685936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# -*- 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 = {}

####### BUILDSLAVES

# The 'slaves' list defines the set of recognized buildslaves. Each element is
# a BuildSlave object, specifying a unique slave name and password.  The same
# slave name and password must be configured on the slave.
from buildbot.buildslave import BuildSlave
c['slaves'] = [BuildSlave("linux-build-slave", "foobar"),
#               BuildSlave("windows-build-slave", "foobar"),
#               BuildSlave("mac-build-slave", "foobar") 
               ] 
# '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

####### CHANGESOURCES

# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.

import subprocess

def run_cmd(cmd, cwd=None):
    p = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE, cwd=cwd)
    stdout = p.communicate()[0]
    return stdout

# to generate the list of remote branches we
# 1. create bare repositry
# 2. get the list of branches
# 3. delete the repository


#gitflow = []

#clone_cmd = "git clone --bare git://leap.se/leap_client tmp" 
#run_cmd(clone_cmd)
#list_branch_cmd = "git branch --list feature/*"
#stdout = run_cmd(list_branch_cmd, "tmp")
#for line in stdout.split("\n"):
#    if len(line.strip())> 0:
#        gitflow.append(line.strip())
#rm_cmd = "rm -rf tmp"
#run_cmd(rm_cmd)
#branches = ['develop'] + gitflow

# XXX For NOW, only develop branches
branches = ['develop']

from buildbot.changes.gitpoller import GitPoller
from buildbot.changes import pb

c['change_source'] = []
c['change_source'].append(GitPoller(
        'git://leap.se/leap_client',
        workdir="gitpoller-workdir", branches=branches, pollinterval=300))

#c['change_source'].append(pb.PBChangeSource(
#        port=9999, user='laura', passwd='firewalk'))

#git poll branch names to automatically build branches to watch.

####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.  In this
# case, just kick off a 'runtests' build

from buildbot.schedulers.basic import SingleBranchScheduler
from buildbot.schedulers.forcesched import ForceScheduler
from buildbot.schedulers.timed import Nightly
from buildbot.changes import filter

c['schedulers'] = []
c['schedulers'].append(ForceScheduler(
                       name="force",
                       builderNames=["linux-incremental", 
#                                     "windows-incremental",
#                                     "mac-incremental"
                       ]))

for branch in branches:
	c['schedulers'].append(SingleBranchScheduler(
                            name=branch + "-checkin",
                            change_filter=filter.ChangeFilter(branch=branch),
                            treeStableTimer=60,
                            builderNames=["linux-incremental", 
					  "client-linux-quick",
#                                          "windows-incremental",
#                                          "mac-incremental"
                            ]))

c['schedulers'].append(Nightly(
		    name="develop-nightly",
                    branch="develop",
                    hour=4,
		    minute=23,
                    onlyIfChanged=True,
		    builderNames=["client-linux-quick", 
#				  "windows-full",
#				  "mac-full"
                    ]))

####### 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.git import Git
from buildbot.steps.shell import ShellCommand

# XXX TODO lock down accepted commands

class UploadCoverage(ShellCommand):
    def start(self):
    	self.buildername = self.getProperty("buildername")
        self.branch = self.getProperty("branch")
        self.buildnumber = self.getProperty("buildnumber")

        cmd = """ssh -p 4422 buildmaster@lemur.leap.se mkdir -p buildmaster/public_html/coverage/%s/%s/
scp -P 4422 -r docs/covhtml/ buildmaster@lemur.leap.se:buildmaster/public_html/coverage/%s/%s/%s/""" % (
self.buildername, self.branch, 
self.buildername, self.branch, self.buildnumber)
        self.setCommand(cmd)
        ShellCommand.start(self)

    def createSummary(self, log):
        url = "http://lemur.leap.se:8010/coverage/%s/%s/%s/" % (
        self.buildername, self.branch, self.buildnumber)
        self.addURL("coverage", url)

# factories are responsible for creating new Build instances
#cp_script = ShellCommand(name='Copy script',
#               description='copy script (need to push  this XXX!)',
#               #command=['cp', 'pkg/scripts/install_venv.py', 'pkg/'])
#               command=['cp', '/home/buildslave/scripts/install_venv.py', 'pkg/'])

#skip_pyside = ShellCommand(name='Skip pyside',
#               description='workaround for skipping pyside',
#               command=['sed', '-i', 's/PySide/#PySide/', 'pkg/requirements.pip'])

#add_missing_dep = ShellCommand(name='Extra dep',
#               description='workaround for missing deps XXX -- push',
#               command=['sed', '-i', '$ a\oauth', 'pkg/requirements.pip'])

#install_virt = ShellCommand(name='Installing Virtual Environment',
#               env={'LEAP_VENV_SKIP_PYSIDE': '1'},
#               description='Installing Virtual Environment',
#               command=['python', 'pkg/install_venv.py'])

# XXX Workaround for long installs --- should add another builder
# that works inside a permanent virtualenv, using venvwrapper...
install_virt = ShellCommand(name='Installing Virtual Environment',
               env={'LEAP_VENV_SKIP_PYSIDE': '1'},
               description='Installing Virtual Environment',
               command=['cp', '-r', '/home/buildslave/venv/.venv', '.'])

develop_mode = ShellCommand(name='run in develop mode',
               description='yet another workaround for namespace package weirdness',
               command=['pkg/tools/with_venv.sh', 'python', 'setup.py', 'develop'])

install_leap = ShellCommand(name='install leap into virtualenv',
               description='yet another workaround for namespace package weirdness',
               command=['pkg/tools/with_venv.sh', 'python', 'setup.py', 'install'])

make_resources = ShellCommand(name='compile qt resources',
               description='generates locales and ui files',
               command=['make'])

run_tests = ShellCommand(name='Running Tests', description='Running tests',
            command=['pkg/tools/with_venv.sh', './run_tests.sh', '--coverage'])
#run_tests = ShellCommand(name='Running Tests', description='Running tests',
#            command=['pkg/tools/with_venv.sh', 'nosetests', 
#            'src/leap', '--exclude-dir=src/leap/soledad/',
#            '--exclude-dir=src/leap/common/'])

# XXX  will need to introduce xvfb-run again...
#run_tests = ShellCommand(name='Running Tests', description='Running tests',
#            command=['pkg/tools/with_venv.sh', 'xvfb-run', 'nosetests', 
#            '--with-coverage', '--cover-package=leap-client', 'leap'])

#run_mail_tests = ShellCommand(name='Running Mail Tests', description='Running mail tests',
#                 command=['pkg/tools/with_venv.sh', 'trial', '--coverage',
#                 'leap.email.smtp.tests']) 
#run_soledad_tests = ShellCommand(name='Running Soledad Tests', description='Running soledad tests',
#           env={'LD_PRELOAD':'/usr/local/lib/libsqlite3.so'}, 
#           command=['pkg/tools/with_venv.sh', 'nose2', '-v', 'leap.soledad.tests'])

run_tox = ShellCommand(name='Running tox', description='Running tox',
          command=['pkg/tools/with_venv.sh', 'tox', '-v'])
run_pep8 = ShellCommand(name='Running pep8', description='Running pep8',
           command=['pkg/tools/with_venv.sh', 'pep8', 
           '--ignore=E202,W602 --exclude=ui_*,*_rc.py,_version.py --repeat',
           'src/leap'])
run_coverage = ShellCommand(name='Running coverage', description='Running coverage',
               command=['pkg/tools/with_venv.sh', 'coverage', 'html', 
           '-d', 'docs/covhtml', '-i', '--include=src/leap/*',
           '--omit=src/leap/base/tests/*,src/leap/eip/tests/*,src/leap/gui/tests/*,/src/leap/util/tests/*'],
           haltOnFailure=True)

f1 = BuildFactory()
f1.addStep(Git(repourl='git://leap.se/leap_client', mode='incremental', branch='develop'))
#f1.addStep(cp_script)
#f1.addStep(skip_pyside)
f1.addStep(install_virt)
f1.addStep(run_tests)
#f1.addStep(run_mail_tests)
#f1.addStep(run_soledad_tests)
f1.addStep(run_tox)
f1.addStep(run_pep8)
f1.addStep(run_coverage)
f1.addStep(UploadCoverage(name='Uploading coverage', description='Uploading coverage'))

def get_client_quick_builder():
    f = BuildFactory()
    # aka "CLIENT LINUX QUICK"
    f.addStep(Git(repourl='git://leap.se/leap_client', mode='full', branch='develop'))
    #f.addStep(Git(repourl='git://github.com/kalikaneko/leap_client.git', mode='full', branch='ci-testing'))
    #f.addStep(cp_script)
    #f.addStep(skip_pyside)
    #f.addStep(add_missing_dep)
    f.addStep(install_virt)
    f.addStep(make_resources)
    #f.addStep(develop_mode)
    #f.addStep(install_leap)
    f.addStep(run_tests)
    #f.addStep(run_mail_tests)
    #f.addStep(run_soledad_tests)

    # no tox on quick builder
    #f.addStep(run_tox)

    f.addStep(run_pep8)
    #f.addStep(run_coverage)
    f.addStep(UploadCoverage(name='Uploading coverage', description='Uploading coverage'))
    b = {'name': "client-linux-quick",
         'slavename': "linux-build-slave",
         'builddir': "client_linux_quick",
         'factory': f,
    }
    return b

# multiple buildslaves in a builder provide redundancy
# Difft platforms, OSes, versions, libraries should have dfft Builders
b1 = {'name': "linux-incremental",
      'slavename': "linux-build-slave",
      'builddir': "linux-incremental",
      'factory': f1,
      }
#b2 = {'name': "windows-incremental",
#      'slavename': "windows-build-slave",
#      'builddir': "windows-incremental",
#      'factory': f1,
#      }
#b3 = {'name': "mac-incremental",
#      'slavename': "mac-build-slave",
#      'builddir': "mac-incremental",
#      'factory': f1,
#      }
#b4 = {'name': "linux-full",
#      'slavename': "linux-build-slave",
#      'builddir': "linux-full",
#      'factory': f2,
#      }
#b5 = {'name': "client-linux-quick",
#      'slavename': "linux-build-slave",
#      'builddir': "client_linux_quick",
#      'factory': get_client_quick_builder(),
#      }
#b5 = {'name': "windows-full",
#      'slavename': "windows-build-slave",
#      'builddir': "windows-full",
#      'factory': f2,
#      }
#b6 = {'name': "mac-full",
#      'slavename': "mac-build-slave",
#      'builddir': "mac-full",
#      'factory': f2,
#      }

#c['builders'] = [b1, b2, b3, b4, b5, b6]
# b5 = get_client_quick_builder()]
c['builders'] = [b1, get_client_quick_builder()]

####### 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 authz, auth

authz_cfg=authz.Authz(
    # change any of these to True to enable; see the manual for more
    # options
    auth=auth.BasicAuth([("foobar","foobar")]),
    gracefulShutdown = False,
    forceBuild = 'auth', # 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))

# Our dear polkabot! ....

from buildbot.status import words

BBOT_NICK = "polkabot"
BBOT_CHANNELS = ["#borogoves"]
c['status'].append(words.IRC(
	host="irc.indymedia.org",
	nick=BBOT_NICK,
        channels=BBOT_CHANNELS,
	allowForce=True,
        notify_events={
#                             'started': 1,
#                             'finished': 1,
#                             'failure': 1,
        }
))
#c['status'].append(words.IRC(host="chat.freenode.net", nick="leap-buildbot",
#                             channels=["#leap-dev"]))


####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot
# installation's html.WebStatus home page (linked to the
# 'titleURL') and is embedded in the title of the waterfall HTML page.

c['title'] = "LEAP"
c['titleURL'] = "https://leap.se"

# 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://lemur.leap.se:8010/"

####### DB URL

c['db'] = {
    # This specifies what database buildbot uses to store its state.  You can leave
    # this at its default for all but the largest installations.
    'db_url' : "sqlite:///state.sqlite",
}