-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmaster.cfg
2159 lines (2003 loc) · 84.3 KB
/
master.cfg
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# ex: set syntax=python:
# vim: ft=python
# NIpy buildBOT Master Instance config
#
# [ TODO ] (in no particular order)
# - combine multiple steps into one (if possible)
# - rename steps to be more concise and informative
# - generate numpy version based templates
# - what's up with the buildout not using ~/.buildout/default.cfg and not caching
# * we may need to set some properties for this to work
# - install more versions of python on the slaves
# - have slaves report back their configuration (so we have them doing the right builders)
# - if possible, forcebuild every builder on a particular slave (to check that it can)
# - hookup with git post-commit hooks (instead of relying on poller)
""" A brief tour of buildbot
To remind myself
A ChangeSource looks for Changes.
In our case we are using GitPoller ChangeSource to look for changes in our git
repositories.
When ChangeSource finds changes, it broadcasts them to all Schedulers. Each
Scheduler must decide if it wants to react to a Change. It generally does this
by filtering changes to select changes it will act on.
We use SingleBranchSchedulers for this. These obviously respond only to
changes in one branch of a repository. .schedulers() outputs list of
SingleBranchSchedulers with each linked to builders corresponding to each
branch if there are more than one.
A BuildSet is the association of (information about what changes need to be
tested) and (Builders on which to test)
If a Scheduler selects changes for action, it sends BuildSets to the system
(the BuildMaster). Therefore, a Scheduler needs to know its Builders. It gets
these by name (string).
For each BuildSet, the (changes to be tested) are sent to each Builder. Each
of these requests is BuildRequest.
A Builder accepts a BuildRequest and runs it on a BuildSlave. It does this by
using its own BuildFactory instance to make Builds.
A Builder can have more than one associated BuildSlave. In this case each
associated BuildSlave is assumed to produce identical results, and the Builder
can therefore choose at whim which BuildSlave to use.
A Build has one or more Steps that should be run with a given (changes to be
tested).
One type of build Step is a Trigger, which activates a triggerable Scheduler,
which can react any way it likes, including sending further BuildSets.
"""
import re
# This is convenient for splitting sh commands into lists
import shlex
# Buildbot objects
from buildbot.locks import MasterLock
from buildbot.buildslave import BuildSlave
from buildbot.changes.gitpoller import GitPoller
from buildbot.schedulers.filter import ChangeFilter
from buildbot.schedulers.forcesched import (ForceScheduler,
StringParameter)
from buildbot.schedulers.basic import (SingleBranchScheduler)
from buildbot.schedulers import timed
from buildbot.schedulers.triggerable import Triggerable
from buildbot.schedulers.trysched import Try_Jobdir
from buildbot.process.factory import BuildFactory
from buildbot.steps.source.git import Git
from buildbot.steps.shell import ShellCommand, SetPropertyFromCommand
from buildbot.steps.transfer import FileDownload, DirectoryUpload
from buildbot.steps.trigger import Trigger
from buildbot.process.properties import Property, Interpolate
from buildbot.config import BuilderConfig
HTTP_SERVER_URL='https://nipy.bic.berkeley.edu/scipy_installers/'
# Directory for cached downloads of files needed by buildbots
HTTP_CACHE_URL = HTTP_SERVER_URL + 'buildbot-files/'
# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
"""
Load local setup from python module
Local setup is:
* master_url : str; URL that the master serves on. Putting this in the setup
allows us to run master on another machine for debugging
* slave_portnum : int; slave port number, as above
* slave_passes : dict; key, value pairs of (slave name, password) giving slave
names and slave password.
Don't store local_setup in version control with real passwords ! Use
secret_passwords.py instead, and don't put in version control.
"""
import local_setup
reload(local_setup) # so buildbot reconfig refreshes these parameters
# pip installs that should always be '--ignore-installed'
PIP_IGNORE_INSTALLS = ('nose', 'sphinx')
# Check parameters in setup
for attr_name in ('slave_passes', 'master_url', 'slave_port'):
assert hasattr(local_setup, attr_name)
# Fetch any secret passwords. We're using this trick so it is harder to save
# the secret passwords accidentally into version control
try:
import secret_passwords
reload(secret_passwords)
except ImportError:
pass
else:
for slavename, password in secret_passwords.slave_passes.items():
local_setup.slave_passes[slavename] = password
# Check that slave names are unique
if len(set(local_setup.slave_passes)) != len(local_setup.slave_passes):
raise ValueError('Slave names must be unique')
####### BUILDSLAVES
# Slave groups
linux_64_slaves = ['tom-standard']
debian_ppc_slaves = ['debian-ppc-64']
sparc_slaves_sid = ['nd-bb-slave-sparc-sid', 'nd-bb-slave-sparc64-sid']
sparc_slaves_wheezy = ['nd-bb-slave-sparc-wheezy', 'nd-bb-slave-sparc64-wheezy']
sparc_slaves = ['nd-bb-slave-sparc']
osx_tiger_ppc_slaves = ['osx-mini']
osx_snowleopard_slaves = ['osx-10.6']
osx_lion_slaves = ['osx-10.7']
osx_yosemite_slaves = ['mac-pro']
win7_32_slaves = ['win7-32-mini']
win7_64_slaves = ['win-2008-64']
win10_64_slaves = ['win10']
win2016_slaves = ['win2016']
arm_slaves = ['arm-raspberry-pi']
fedora_slaves = ['i20-fedora']
osx_wheel_slaves = ['osx-10.6-clean']
# Locks to prevent resource exhaustion which might need to be defined
# for some slaves. It seems that locks need to be given to BuildSlave
# at __init__ time, so let's construct the mapping first: slave -> [locks]
# which are later used while initiating BuildSlave's
def add_lock(slave_locks, slavenames, lock, *accessargs):
"""Add a LockAccess's to a lock to the list of slaves
"""
for name in slavenames:
if not (name in slave_locks):
slave_locks[name] = []
slave_locks[name].append(lock.access(*accessargs))
slave_locks = {}
# vagus sparc box has only 4 CPUs, thus we should not run more than 4
# jobs in parallel
add_lock(slave_locks,
['nd-bb-slave-sparc'+suf for suf in ['', '-wheezy', '-sid']],
MasterLock("vagus", maxCount=4), 'counting')
# lingual sparc box has only 2 CPUs, thus we should not run more than 2
# jobs in parallel
add_lock(slave_locks,
['nd-bb-slave-sparc64'+suf for suf in ['-wheezy', '-sid']],
MasterLock("lingual", maxCount=2), 'counting')
# wheel slave does awful things to /usr/local, should only run one job at a
# time
add_lock(slave_locks,
osx_wheel_slaves,
MasterLock("wheel-usr-local", maxCount=1), 'counting')
# These are working desktops, so throttle them to keep the machines calm
add_lock(slave_locks,
['tom-standard'],
MasterLock("working-desktops", maxCount=1), 'counting')
# 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.
slaves = [BuildSlave(slave_name, slave_pass, locks=slave_locks.get(slave_name, None))
for slave_name, slave_pass in local_setup.slave_passes.items()]
# slave names must be unique
c['slaves'] = slaves
# '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'] = local_setup.slave_port
# Helper functions and constants
def sanitize_branch_name(name):
return name.replace('/', '+')
def is_one_default_branch(branches, branch):
return (len(branches) < 2 and (branch in (None, 'master', 'HEAD')))
def get_branch_builder_name(builder, branches, branch=None):
if branch is None or is_one_default_branch(branches, branch):
return builder
else:
return '%s_%s' % (builder, sanitize_branch_name(branch))
def pyorg_pybin(pyver):
return (
'/Library/Frameworks/Python.framework/Versions/{0}/bin/python{0}'.format(
pyver))
def needs_ignore_installed(pkg_spec):
# True if packages in this `pkg_spec` need ``--ignore-installed``
for spec in pkg_spec:
pkg_name = re.split('[\[ =<>!,]*', spec)[0]
if pkg_name in PIP_IGNORE_INSTALLS:
return True
return False
def do_pip_install(factory, pip_depends, env, pip_args=None):
if pip_args is None:
pip_args = []
for pkg_spec in pip_depends:
if isinstance(pkg_spec, basestring):
pkg_spec = [pkg_spec]
cmd = ['pip', 'install'] + list(pip_args)
# We sometimes need the 'ignore-installed' flag to force pip to install
# the programs in the virtualenv. Otherwise pip finds the programs
# (like 'nose') already installed; these then call the system python
# and we don't get the virtualenv python.
if needs_ignore_installed(pkg_spec):
cmd += ['--ignore-installed']
factory.addStep(
ShellCommand(command=cmd + list(pkg_spec), env=env))
def make_virtualenv(factory, python=None, install_pip=True,
sys_site_packages=False):
# Obviously requires virtualenv on the slave
# Because of the bug in elderly easy_install, it would take into
# account settings present in setup.cfg and might try to install
# under /usr/lib as happened with fail2ban bot. So deploy virtualenv
# while stepping into a new clean directory.
venv_params = ['--system-site-packages'] if sys_site_packages else []
venv_params += ['--clear', '../venv']
if not python is None:
venv_params = ['--python=' + python] + venv_params
factory.addStep(ShellCommand(command=['virtualenv'] + venv_params,
workdir='build/mk_venv'))
# Now we need the venv binary directory
factory.addStep(FileDownload('slave_scripts/bs_tools.py',
'bs_tools.py'))
factory.addStep(SetPropertyFromCommand(command=[
'python', 'bs_tools.py', 'path-prepend-str', 'venv'],
property='venv_script_dir'))
factory.addStep(SetPropertyFromCommand(command=[
'python', 'bs_tools.py', 'abspath', 'venv'],
property='venv_dir'))
# Set env, with virtualenv in front of the path
env={'PATH': Interpolate("%(prop:venv_script_dir)s${PATH}")}
workdir = Interpolate("%(prop:venv_dir)s")
if install_pip:
# Upgrade pip if necessary for wheel installs
factory.addStep(ShellCommand(
command=['pip', 'install', '--ignore-installed', 'pip>=6'],
env=env))
return env, workdir
def add_bs_tools(factory):
# Put bs_tools into properties in case someone needs it
factory.addStep(SetPropertyFromCommand(
command = ['python', 'bs_tools.py', 'abspath', 'bs_tools.py'],
property = 'bs_tools'))
class GithubBot(object):
""" Class to make buildbot stuff based round a github repo
"""
def __init__(self,
organization,
repo,
test_cmd,
doc_build_cmd=None,
built_doc_src=None,
pip_depends=(),
doc_pip_depends=('sphinx',),
src_subdir=None,
download_dir=None,
build_timeout=None,
test_env=None,
test_dir=None,
branches=["master"],
):
# using easy_install on packages that are already in
# system-site-packages causes the system path to get promoted above the
# virtualenv path, and usually causes a terrible mess. so prefer pip
# if at all possible.
self.organization = organization
self.repo = repo
self.git_url = "git://github.com/%s/%s.git" % (organization, repo)
self.test_cmd = test_cmd
self.test_env = test_env
self.test_dir = test_dir
self.doc_build_cmd = doc_build_cmd
self.built_doc_src = built_doc_src
# Dependencies for install / test
self.pip_depends = pip_depends # pip
self.doc_pip_depends = doc_pip_depends # pip installs for docs
self.src_subdir = src_subdir # Subdirectory containing source
if download_dir is None:
download_dir = '%s-dist' % repo
self.download_dir = download_dir
self.build_timeout = build_timeout
self.branches = branches
@property
def project(self):
return "%s" % (self.repo,)
def poller(self, branches=None, interval=300):
if branches is None:
branches = self.branches
return GitPoller(
self.git_url,
project=self.project,
category=self.project,
workdir = "%s-%s-%s" % (self.organization, self.repo, sanitize_branch_name('_'.join(branches))),
branches=branches,
pollinterval=interval)
def _get_scheduler(self, branch_buildernames, branches, branch):
# we need a closure to maintain the function comparing to the
# actual target branch
def _branch_fn(b):
return lambda b_: b_==b
branch_fn = _branch_fn(branch)
return SingleBranchScheduler(
name=get_branch_builder_name(self.project, branches, branch),
change_filter=ChangeFilter(
repository=self.git_url,
project=self.project,
category=self.project,
branch_fn=branch_fn),
treeStableTimer=None,
builderNames=branch_buildernames)
def schedulers(self, buildernames, branches=None):
if isinstance(buildernames, basestring):
buildernames = [buildernames]
if branches is None:
branches = self.branches
# Create a separate scheduler per each branch linking it
# to correspondingly named builders
return [self._get_scheduler(
[get_branch_builder_name(n, branches, branch)
for n in buildernames],
branches, branch)
for branch in branches]
def nightly_scheduler(self,
buildernames,
name_suff,
hour = 2, minute = 23,
ifchanged=True,
branch='master',
):
""" Make a timed scheduler for this repo """
if isinstance(buildernames, basestring):
buildernames = [buildernames]
name = "%s-%s-nightly-%s" % (self.organization, self.repo, name_suff)
changefilter = ChangeFilter(repository=self.git_url,
project=self.project,
category=self.project)
return timed.Nightly(name=name,
branch=branch,
builderNames=buildernames,
change_filter=changefilter,
hour=hour,
minute=minute,
onlyIfChanged=ifchanged)
def _code_build_factory(self,
python=None,
pip_depends=None,
pre_build_cmds=(),
branch=None,
install_pip=None):
if pip_depends is None:
pip_depends = self.pip_depends
factory = BuildFactory()
git_kwargs = {'branch': branch} if branch is not None else {}
factory.addStep(Git(repourl=self.git_url,
mode='full',
retry=(15, 5),
**git_kwargs))
# Make virtualenv, return environment, workdir of venv
my_env, workdir = make_virtualenv(
factory, python,
install_pip=bool(install_pip or pip_depends),
sys_site_packages=True)
# Any pre-building commands
for cmd in pre_build_cmds:
factory.addStep(ShellCommand(command=cmd))
# Add install and runtime dependencies
do_pip_install(factory, pip_depends, my_env)
# Show pip enviroment
factory.addStep(ShellCommand(command=['pip', 'freeze'], env=my_env))
# Work out working directory for install
if not self.src_subdir is None:
factory.addStep(SetPropertyFromCommand(command=[
'python', 'bs_tools.py', 'abspath', self.src_subdir],
property='src_path'))
build_workdir = Interpolate("%(prop:src_path)s")
else:
build_workdir = None
return factory, my_env, workdir, build_workdir
def factory(self,
test_cmd=None,
python=None,
pip_depends=None,
pre_build_cmds=(),
post_cmds=(),
test_env=None,
test_dir=None,
install_cmd=('python', 'setup.py', 'install'),
install_wd=None,
branch=None,
):
if test_cmd is None:
test_cmd = self.test_cmd
if test_env is None:
test_env = self.test_env
if test_dir is None:
test_dir = self.test_dir
factory, env, workdir, build_workdir = self._code_build_factory(
python, pip_depends, pre_build_cmds, branch=branch)
# Additional options for ShellCommands, if provided. To not
# rely on knowing internal logic (either handles None as the
# default value), we explicitly construct a dictionary only
# with the specified options
kwargs = {}
if self.build_timeout:
kwargs['timeout'] = self.build_timeout
# Install into virtualenv
if install_wd is None:
install_wd = build_workdir
if install_cmd is not None:
factory.addStep(ShellCommand(
command=install_cmd,
env=env,
workdir=install_wd,
**kwargs))
# Test
if test_env:
env = dict(env.items() + test_env.items())
if test_dir:
# allow for interpolations using known know variables
test_dir_env = {'workdir': workdir, 'build_workdir': build_workdir}
test_dir_env.update(env)
test_dir = test_dir % test_dir_env
else:
test_dir = workdir
if isinstance(test_cmd, dict):
# must be mapping branches to test_cmd
test_cmd = test_cmd[branch]
factory.addStep(ShellCommand(command=test_cmd,
env=env, workdir=test_dir, **kwargs))
for cmd in post_cmds:
factory.addStep(
ShellCommand(command=shlex.split(cmd, posix=True),
env=env,
workdir=workdir,
**kwargs))
return factory
def bdist_factory(self,
bdist_type,
test_cmd=None,
python=None,
pip_depends=None,
pre_build_cmds=()):
if test_cmd is None:
test_cmd = self.test_cmd
factory, env, workdir, build_workdir = self._code_build_factory(
python, pip_depends, pre_build_cmds, install_pip=True)
# Build binary format(s)
if python is None: # Use virtualenv python
my_python = 'python'
build_env = env
else: # Use specified python
my_python = python
# Insert virtualenv into PYTHONPATH for building using virtualenv
# dependencies
factory.addStep(SetPropertyFromCommand(command=shlex.split(
'python bs_tools.py get-python-lib'),
property='venv_python_lib', env=env))
build_env = env.copy()
build_env['PYTHONPATH'] = Interpolate("%(prop:venv_python_lib)s")
if bdist_type == 'egg':
factory.addStep(ShellCommand(
command=[my_python, 'setup.py', 'bdist_egg'],
env=build_env,
workdir=build_workdir))
# Make a mpkg for good measure
factory.addStep(ShellCommand(
command=[my_python, 'setup.py', 'bdist_mpkg'],
env=build_env,
workdir=build_workdir))
installer = ['easy_install']
elif bdist_type == 'exe':
factory.addStep(ShellCommand(
command=[my_python, 'setup.py', 'bdist', '--formats=wininst'],
env=build_env,
workdir=build_workdir))
installer = ['easy_install']
elif bdist_type == 'whl':
# Install bdist_wheel command
do_pip_install(factory, ("wheel>=0.21",), env=build_env)
# Make wheel - always use virtualenv python
factory.addStep(ShellCommand(
command=['python', 'setup.py', 'bdist_wheel'],
env=build_env,
workdir=build_workdir))
installer = ['pip', 'install']
else:
raise ValueError('What is this?: ' + bdist_type)
# Find binary installer file
factory.addStep(SetPropertyFromCommand(
command=['python', 'bs_tools.py',
'glob', 'dist', '*.' + bdist_type],
property='bdist_file'))
# Install into virtualenv
factory.addStep(ShellCommand(
command = installer + [Interpolate('%(prop:bdist_file)s')],
env=env))
# Test
kwargs = dict(env=env,
workdir=workdir,
haltOnFailure=True)
if self.build_timeout is not None:
kwargs['timeout'] = self.build_timeout
factory.addStep(
ShellCommand(
command=test_cmd,
**kwargs))
# Upload
factory.addStep(DirectoryUpload(slavesrc="dist",
masterdest="public_html/" + self.download_dir))
return factory
def doc_factory(self,
doc_build_cmd=None,
built_doc_src=None,
doc_doctest_cmd=None):
if doc_build_cmd is None:
doc_build_cmd = self.doc_build_cmd
if built_doc_src is None:
built_doc_src = self.built_doc_src
if None in (doc_build_cmd, built_doc_src):
raise ValueError("Need defined build command and doc source")
factory, my_env, workdir, build_workdir = self._code_build_factory()
# Install into virtualenv
kwargs = {}
if self.build_timeout:
kwargs['timeout'] = self.build_timeout
factory.addStep(ShellCommand(
command=['python', 'setup.py', 'install'],
env=my_env,
workdir=build_workdir,
**kwargs))
# Add install and runtime dependencies
do_pip_install(factory, self.doc_pip_depends, my_env)
if not doc_doctest_cmd is None:
factory.addStep(ShellCommand(command=doc_doctest_cmd, env=my_env))
factory.addStep(ShellCommand(command=doc_build_cmd, env=my_env))
factory.addStep(DirectoryUpload(slavesrc=built_doc_src,
masterdest="public_html/nightly/" + self.repo + '/doc'))
return factory
def build_builders(self, name_slavenames,
test_cmd=None,
python=None,
pip_depends=None,
pre_build_cmds=(),
post_cmds=(),
install_cmd=('python', 'setup.py', 'install'),
install_wd=None,
branches=None,
schedulers=None, # get a new scheduler assigned per each branch
):
if branches is None:
branches = self.branches
builders = []
for branch in branches:
branch_builders = self._factory_builders(
self.factory(test_cmd,
python,
pip_depends,
pre_build_cmds=pre_build_cmds,
post_cmds=post_cmds,
install_cmd=install_cmd,
install_wd=install_wd,
branch=branch),
name_slavenames,
None if is_one_default_branch(branches, branch) else branch)
# assign those to a new unique scheduler if that was requested
if schedulers is not None:
schedulers.append(
self._get_scheduler([b.name for b in branch_builders],
branches, branch))
builders += branch_builders
return builders
def _factory_builders(self, factory, name_slavenames, branch=None):
builders = []
for name, slavelist in name_slavenames:
if isinstance(slavelist, basestring):
slavelist = [slavelist]
if branch is not None:
name=get_branch_builder_name(name, [None, None], branch)
builders.append(BuilderConfig(
name=name,
slavenames=slavelist,
factory=factory))
return builders
def build_doc_builders(self,
name_slavenames,
doc_build_cmd=None,
built_doc_src=None,
doc_doctest_cmd=None):
factory = self.doc_factory(doc_build_cmd, built_doc_src, doc_doctest_cmd)
return self._factory_builders(factory, name_slavenames)
def nptest_command(pkg_name,
verbose=10,
doctests=False,
python='python',
cd=False,
stdout=False,
exe=False,
use_agg=False):
""" Run tests from new directory """
pystr = ''
if cd:
pystr += "import os; os.chdir('..');"
if use_agg:
pystr += 'import os; open("matplotlibrc", "wt").write("backend : agg"); '
pystr += ("import sys; import %s; sys.exit(not %s.test(doctests=%s"
% (pkg_name, pkg_name, doctests))
if verbose != None:
pystr += ', verbose=%d' % verbose
if exe:
pystr += ', extra_argv=["--exe"]'
pystr += ").wasSuccessful())"
return [python, '-c', "%s" % pystr]
nibabel_bot = GithubBot('nipy', 'nibabel',
test_cmd = shlex.split('nosetests --verbosity=3 --exe --with-doctest nibabel nisext'),
doc_build_cmd = "cd doc && make html",
doc_pip_depends = ('sphinx', 'texext'),
built_doc_src = "build/html",
pip_depends = ('nose', 'mock')
)
nitime_bot = GithubBot('nipy', 'nitime',
test_cmd = nptest_command('nitime', verbose=None),
pip_depends = ('nose', 'matplotlib')
)
pyarbus_bot = GithubBot('ivanov', 'pyarbus',
test_cmd = nptest_command('pyarbus', verbose=None, use_agg=True),
pip_depends = ('nose','nitime')
)
nipy_bot = GithubBot('nipy', 'nipy',
test_cmd = nptest_command('nipy', doctests=True),
doc_build_cmd = "cd doc && make dist",
built_doc_src = "doc/dist",
pip_depends = ('nose', 'sympy', 'nibabel', 'numpy', 'scipy'),
build_timeout = 2400,
)
dipy_bot = GithubBot('nipy', 'dipy',
test_cmd = ['python', '-c',
'import nose; '
'from nose.plugins import doctests; '
'open("matplotlibrc", "wt").write("backend : agg"); '
'argv = ["", "dipy", "--with-doctest", "--verbosity=3", "--exe"]; '
'nose.core.TestProgram(argv=argv, addplugins=[doctests.Doctest()])'],
pip_depends = ('nose', 'numpy>=1.7.1', 'cython>=0.25.1', 'nibabel', 'scipy'),
build_timeout = 9600, # allow for longer registration builds
)
# dipy bot for linux machines with optional pip_depends that
# need an X window for testing
dipy_bot_nox = GithubBot('nipy', 'dipy',
test_env = dict(TEST_WITH_XVFB='skip'),
test_cmd = shlex.split('xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" nosetests --verbosity=3 --with-doctest dipy'),
pip_depends = ('nose', 'numpy>=1.7.1', 'cython>=0.18', 'nibabel',
'xvfbwrapper'),
build_timeout = 9600, # allow for longer registration builds
)
nipype_bot = GithubBot('nipy', 'nipype',
test_cmd = nptest_command('nipype', doctests=True),
pip_depends = ('Traits', 'nose', 'nibabel', 'networkx', 'python-dateutil')
)
regreg_bot = GithubBot('regreg', 'regreg',
test_cmd = shlex.split('nosetests --verbosity=3 --exe --with-doctest regreg'),
pip_depends = ('nose', 'cython'),
)
# pandas bot, primarily for sparc testing
pandas_bot = GithubBot('pydata', 'pandas',
test_cmd = shlex.split('xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" nosetests --verbosity=3 --exe -s pandas'),
doc_build_cmd = "make doc",
built_doc_src = "doc/build/html",
pip_depends = ('nose', 'apiclient',),
build_timeout = 7200, # allow for its longer builds/testing especially for sparcs
)
# statsmodels bot, primarily for sparc testing
statsmodels_bot = GithubBot('statsmodels', 'statsmodels',
test_cmd = shlex.split('xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" nosetests --verbosity=3 --exe -s statsmodels'),
doc_build_cmd = "make -C docs html",
built_doc_src = "docs/build",
pip_depends = ('nose', 'patsy>=0.1.0',),
)
# seaborn bot
seaborn_bot = GithubBot('mwaskom', 'seaborn',
test_cmd = shlex.split('xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" nosetests --verbosity=3 --exe -s seaborn'),
pip_depends = ('nose',),
)
# pymvpa bot, primarily for sparc testing
pymvpa_bot = GithubBot('PyMVPA', 'PyMVPA',
test_cmd = shlex.split('nosetests --verbosity=3 --exe -s mvpa2'),
test_env = dict(MVPA_TESTS_LABILE='no', MVPA_MATPLOTLIB_BACKEND='agg', MVPA_TESTS_WTF='yes'),
doc_build_cmd = "make htmldoc",
built_doc_src = "build/html",
pip_depends = ('nose', 'statsmodels'),
build_timeout = 3600, # allow for its longer testing especially for sparcs.
)
# sklearn bot, primarily for sparc testing
sklearn_bot = GithubBot('scikit-learn', 'scikit-learn',
test_cmd = shlex.split('nosetests --verbosity=3 --exe -s sklearn'),
doc_build_cmd = "make -C doc html",
built_doc_src = "doc/build",
pip_depends = ('nose',),
)
# Fail2Ban bots -- need separate ones for different branches because
# tests are invoked differently across them
fail2ban_bot = GithubBot('fail2ban', 'fail2ban',
test_cmd = {'master': shlex.split('bin/fail2ban-testcases'),
'0.8': shlex.split('./fail2ban-testcases')},
branches = ['master', '0.8'],
test_dir = './build/',
)
# PsychoPy
psychopy_bot = GithubBot('psychopy', 'psychopy',
test_cmd = shlex.split('xvfb-run -s "-screen 0 1024x768x24 -ac +extension GLX +render -noreset" python ../psychopy/tests/runPytest.py -v -s -m "not needs_sound"'),
test_env = dict(USER="nobody", TRAVIS="true"),
branches = ['master'],
)
# Sympy
sympy_bot = GithubBot('sympy', 'sympy',
test_cmd = ['python', '-c',
'import sys; '
'import sympy; '
'open("matplotlibrc", "wt").write("backend : agg"); '
'dt=sympy.doctest(); '
't=sympy.test(); '
'st=sympy.test(slow=True, verbose=True, timeout=2300); '
'sys.exit(not (dt and t and st))'],
doc_build_cmd = "make html-errors",
pip_depends = (
'gmpy==1.16',
('--no-deps', 'https://github.com/Theano/Theano/archive/master.zip')),
doc_pip_depends = ('sphinx==1.1.3',),
build_timeout = 2400, # allow for very slow sympy tests
)
# Numpy
numpy_bot = GithubBot('numpy', 'numpy',
test_cmd = nptest_command('numpy', verbose=None),
pip_depends = ('nose',),
)
####### CHANGESOURCES
# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.
#TODO: We should probably change the GitPoller to a PBChangeSource to react to
# commits http://buildbot.net/buildbot/docs/latest/manual/cfg-changesources.html#chsrc-PBChangeSource
c['change_source'] = [bot.poller() for bot in (nibabel_bot,
nitime_bot,
pyarbus_bot,
nipy_bot,
dipy_bot,
nipype_bot,
regreg_bot,
statsmodels_bot,
seaborn_bot,
pymvpa_bot,
sklearn_bot,
sympy_bot,
numpy_bot,
fail2ban_bot,
psychopy_bot,
)]
# pandas is too expensive to test and overwhelmes the sparc box, so
# let's pull it much less frequently until figuring out how to
# implement **correct** locking
c['change_source'] += [pandas_bot.poller(interval=18000)]
####### SCHEDULERS
# Configure the Schedulers, which decide how to react to incoming changes.
c['schedulers'] = sum([
nibabel_bot.schedulers(['nibabel-py2.6',
'nibabel-py2.7-win32',
'nibabel-py2.7-win7',
'nibabel-py2.6-squeeze-sparc',
'nibabel-py2.7-wheezy-sparc',
'nibabel-py2.x-sid-sparc',
'nibabel-py2.7-ppc',
'nibabel-py2.6-arm',
'nibabel-py2.7-fedora',
'nibabel-py2.7-osx-10.6',
'nibabel-py2.7-osx-10.7',
'nibabel-py2.7-osx-10.10',
'nibabel-py2.7-debian-ppc',
'nibabel-py3.4',
'nibabel-py3.3',
'nibabel-py2.7-pyd0.9.7',
'nibabel-py2.7-pyd0.9.8',
]),
nitime_bot.schedulers(['nitime-py2.6',
'nitime-py2.7-win32',
'nitime-py2.6-arm',
'nitime-py2.7-fedora',
'nitime-py2.7-osx-10.6',
'nitime-py2.7-osx-10.7',
'nitime-py2.7-osx-10.10',
'nitime-py3.4',
]),
pyarbus_bot.schedulers(['pyarbus-py2.6',
]),
nipy_bot.schedulers(['nipy-py2.6',
'nipy-py2.7-win32',
'nipy-py2.6-squeeze-sparc',
'nipy-py2.7-wheezy-sparc',
'nipy-py2.x-sid-sparc',
'nipy-py2.7-ppc',
'nipy-py2.6-arm',
'nipy-py2.7-fedora',
'nipy-py2.7-osx-10.6',
'nipy-py2.7-osx-10.7',
'nipy-py2.7-osx-10.10',
'nipy-py2.7-debian-ppc',
'nipy-py3.3',
'nipy-py3.4',
'nipy-py2.7-sym0.7.0-nib1.2.0',
]),
dipy_bot.schedulers(['dipy-py2.6',
'dipy-py2.7-win32',
'dipy-py2.6-squeeze-sparc',
'dipy-py2.7-wheezy-sparc',
'dipy-py2.x-sid-sparc',
'dipy-py2.7-fedora',
'dipy-py2.7-osx-10.6',
'dipy-py2.7-osx-10.7',
'dipy-py2.7-osx-10.10',
'dipy-py2.7-debian-ppc',
'dipy-py3.4',
'dipy-py3.3',
]),
nipype_bot.schedulers(['nipype-py2.6',
'nipype-py2.7-win32',
'nipype-py2.7-fedora',
'nipype-py2.7-osx-10.6',
'nipype-py2.7-osx-10.10',
'nipype-py2.7-debian-ppc',
]),
regreg_bot.schedulers(['regreg-py2.6',
'regreg-py2.7-win32',
'regreg-py2.7-fedora',
'regreg-py2.7-osx-10.6',
'regreg-py2.7-osx-10.7',
'regreg-py2.7-osx-10.10',
'regreg-py2.7-debian-ppc',
]),
pandas_bot.schedulers([
'pandas-py2.x-sid-sparc',
'pandas-py3.x-sid-sparc',
'pandas-py2.6-wheezy-sparc',
'pandas-py2.7-wheezy-sparc',
'pandas-py3.x-wheezy-sparc',
]),
statsmodels_bot.schedulers([
'statsmodels-py2.x-sid-sparc',
# not yet
#'statsmodels-py3.x-sid-sparc',
'statsmodels-py2.7-wheezy-sparc',
#'statsmodels-py3.x-wheezy-sparc',
]),
sklearn_bot.schedulers([
'sklearn-py2.x-sid-sparc',
# not yet
#'sklearn-py3.x-sid-sparc',
'sklearn-py2.6-wheezy-sparc',
#'sklearn-py3.x-wheezy-sparc',
]),
numpy_bot.schedulers([
'numpy-py2.7-osx-10.10',
'numpy-py3.3-osx-10.10',
'numpy-py3.4-osx-10.10',
'numpy-py2.7-debian-ppc',
'numpy-py2.x-sid-sparc',
'numpy-py3.x-sid-sparc',
]),], []) + \
[
# Doc builds
nibabel_bot.nightly_scheduler(['nibabel-doc-builder'], 'doc', 2, 20, True),
nipy_bot.nightly_scheduler(['nipy-doc-builder'], 'doc', 2, 01, True),
pandas_bot.nightly_scheduler(['pandas-doc-builder'], 'doc', 2, 20, True),
statsmodels_bot.nightly_scheduler(['statsmodels-doc-builder'], 'doc', 3, 20, True),
pymvpa_bot.nightly_scheduler(['pymvpa-doc-builder'], 'doc', 4, 20, True),
# Checks for pip build / install
# Windows 32 nightly builds
nipy_bot.nightly_scheduler(['nipy-bdist32-27'], 'win32-whl-27', 2, 10, True),
nipy_bot.nightly_scheduler(['nipy-bdist32-33'], 'win32-whl-33', 2, 20, True),
nipy_bot.nightly_scheduler(['nipy-bdist32-34'], 'win32-whl-34', 2, 30, True),
nipy_bot.nightly_scheduler(['nipy-bdist32-35'], 'win32-whl-35', 2, 30, True),
# OSX nightlies
nipy_bot.nightly_scheduler(['nipy-bdist-whl-2.7'], 'osx-whl-27', 2, 20, True),
nipy_bot.nightly_scheduler(['nipy-bdist-whl-3.3'], 'osx-whl-33', 2, 30, True),
nibabel_bot.nightly_scheduler(['nibabel-bdist32-27'],
'whl-27', 2, 40, True),
nibabel_bot.nightly_scheduler(['nibabel-bdist32-33'],
'whl-33', 2, 50, True),
nibabel_bot.nightly_scheduler(['nibabel-bdist32-34'],
'whl-34', 3, 00, True),
nibabel_bot.nightly_scheduler(['nibabel-bdist32-35'],
'whl-35', 3, 00, True),
# Windows 64 nightly builds
nibabel_bot.nightly_scheduler(['nibabel-bdist64-27'],
'whl64-27', 2, 00, True),
# Dipy
# Windows 32 nightly builds
dipy_bot.nightly_scheduler(['dipy-bdist32-27'], 'dipy-win32-whl-27', 3, 10, True),
dipy_bot.nightly_scheduler(['dipy-bdist32-33'], 'dipy-win32-whl-33', 3, 20, True),
dipy_bot.nightly_scheduler(['dipy-bdist32-34'], 'dipy-win32-whl-34', 3, 30, True),
dipy_bot.nightly_scheduler(['dipy-bdist32-35'], 'dipy-win32-whl-35', 3, 30, True),
# Windows 64 nightly
dipy_bot.nightly_scheduler(['dipy-bdist64-27'], 'dipy-win64-whl-27', 3, 10, True),
dipy_bot.nightly_scheduler(['dipy-bdist64-35'], 'dipy-win64-whl-35', 4, 10, True),
dipy_bot.nightly_scheduler(['dipy-bdist64-35-win10'], 'dipy-win64-whl-35-win10', 3, 10, True),
dipy_bot.nightly_scheduler(['dipy-bdist64-35-win2016'], 'dipy-win64-whl-35-win2016', 3, 10, True),
# OSX nightlies
dipy_bot.nightly_scheduler(['dipy-bdist-whl-2.7'], 'dipy-osx-whl-27', 3, 20, True),
dipy_bot.nightly_scheduler(['dipy-bdist-whl-3.3'], 'dipy-osx-whl-33', 3, 30, True),
# Sympy binary builders
sympy_bot.nightly_scheduler(['sympy-bdist32-27'],
'whl-27', 5, 30, True),
sympy_bot.nightly_scheduler(['sympy-bdist64-27'],
'whl64-27', 5, 30, True),
# Numpy binary builders
numpy_bot.nightly_scheduler(['numpy-bdist-whl-osx-2.7'], 'whl-27', 5, 30, True),
numpy_bot.nightly_scheduler(['numpy-bdist-whl-osx-3.5'], 'whl-35', 5, 30, True),
numpy_bot.nightly_scheduler(['numpy-bdist-whl-osx-3.6'], 'whl-36', 5, 30, True),
]
# Try scheduler defined after builders
# Some factories
def factory_buildout_nibabel(python='python2.6',numpy='1.6.1'):
f = BuildFactory()
# check out the source
# XXX: the mastersrc should make appropriate changes based on numpy version
f.addStep(Git(repourl='git://github.com/nipy/nibabel.git', mode='full'))
f.addStep(FileDownload(mastersrc="bootstrap.py",
slavedest="bootstrap.py"))
f.addStep(FileDownload(mastersrc="nibabel_buildout.cfg",
slavedest="buildout.cfg"))
f.addStep(ShellCommand(command=[python, "bootstrap.py"]))
f.addStep(ShellCommand(command=["bin/buildout"]))