Package buildbot :: Package process :: Module factory
[frames] | no frames]

Source Code for Module buildbot.process.factory

  1  # This file is part of Buildbot.  Buildbot is free software: you can 
  2  # redistribute it and/or modify it under the terms of the GNU General Public 
  3  # License as published by the Free Software Foundation, version 2. 
  4  # 
  5  # This program is distributed in the hope that it will be useful, but WITHOUT 
  6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  8  # details. 
  9  # 
 10  # You should have received a copy of the GNU General Public License along with 
 11  # this program; if not, write to the Free Software Foundation, Inc., 51 
 12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 13  # 
 14  # Copyright Buildbot Team Members 
 15   
 16  from buildbot import interfaces, util 
 17  from buildbot.process.build import Build 
 18  from buildbot.steps.source import CVS, SVN 
 19  from buildbot.steps.shell import Configure, Compile, Test, PerlModuleTest 
 20   
21 -class ArgumentsInTheWrongPlace(Exception):
22 """When calling BuildFactory.addStep(stepinstance), addStep() only takes 23 one argument. You passed extra arguments to addStep(), which you probably 24 intended to pass to your BuildStep constructor instead. For example, you 25 should do:: 26 27 f.addStep(ShellCommand(command=['echo','stuff'], haltOnFailure=True)) 28 29 instead of:: 30 31 f.addStep(ShellCommand(command=['echo','stuff']), haltOnFailure=True) 32 """
33
34 -class BuildFactory(util.ComparableMixin):
35 """ 36 @cvar buildClass: class to use when creating builds 37 @type buildClass: L{buildbot.process.build.Build} 38 """ 39 buildClass = Build 40 useProgress = 1 41 workdir = "build" 42 compare_attrs = ['buildClass', 'steps', 'useProgress', 'workdir'] 43
44 - def __init__(self, steps=None):
45 self.steps = [] 46 if steps: 47 self.addSteps(steps)
48
49 - def newBuild(self, requests):
50 """Create a new Build instance. 51 52 @param requests: a list of buildrequest dictionaries describing what is 53 to be built 54 """ 55 b = self.buildClass(requests) 56 b.useProgress = self.useProgress 57 b.workdir = self.workdir 58 b.setStepFactories(self.steps) 59 return b
60
61 - def addStep(self, step):
63
64 - def addSteps(self, steps):
65 for s in steps: 66 self.addStep(s)
67 68 # BuildFactory subclasses for common build tools 69
70 -class GNUAutoconf(BuildFactory):
71 - def __init__(self, source, configure="./configure", 72 configureEnv={}, 73 configureFlags=[], 74 compile=["make", "all"], 75 test=["make", "check"]):
76 BuildFactory.__init__(self, [source]) 77 if configure is not None: 78 # we either need to wind up with a string (which will be 79 # space-split), or with a list of strings (which will not). The 80 # list of strings is the preferred form. 81 if type(configure) is str: 82 if configureFlags: 83 assert not " " in configure # please use list instead 84 command = [configure] + configureFlags 85 else: 86 command = configure 87 else: 88 assert isinstance(configure, (list, tuple)) 89 command = configure + configureFlags 90 self.addStep(Configure, command=command, env=configureEnv) 91 if compile is not None: 92 self.addStep(Compile, command=compile) 93 if test is not None: 94 self.addStep(Test, command=test)
95
96 -class CPAN(BuildFactory):
97 - def __init__(self, source, perl="perl"):
98 BuildFactory.__init__(self, [source]) 99 self.addStep(Configure, command=[perl, "Makefile.PL"]) 100 self.addStep(Compile, command=["make"]) 101 self.addStep(PerlModuleTest, command=["make", "test"])
102
103 -class Distutils(BuildFactory):
104 - def __init__(self, source, python="python", test=None):
105 BuildFactory.__init__(self, [source]) 106 self.addStep(Compile, command=[python, "./setup.py", "build"]) 107 if test is not None: 108 self.addStep(Test, command=test)
109
110 -class Trial(BuildFactory):
111 """Build a python module that uses distutils and trial. Set 'tests' to 112 the module in which the tests can be found, or set useTestCaseNames=True 113 to always have trial figure out which tests to run (based upon which 114 files have been changed). 115 116 See docs/factories.xhtml for usage samples. Not all of the Trial 117 BuildStep options are available here, only the most commonly used ones. 118 To get complete access, you will need to create a custom 119 BuildFactory.""" 120 121 trial = "trial" 122 randomly = False 123 recurse = False 124
125 - def __init__(self, source, 126 buildpython=["python"], trialpython=[], trial=None, 127 testpath=".", randomly=None, recurse=None, 128 tests=None, useTestCaseNames=False, env=None):
129 BuildFactory.__init__(self, [source]) 130 assert tests or useTestCaseNames, "must use one or the other" 131 if trial is not None: 132 self.trial = trial 133 if randomly is not None: 134 self.randomly = randomly 135 if recurse is not None: 136 self.recurse = recurse 137 138 from buildbot.steps.python_twisted import Trial 139 buildcommand = buildpython + ["./setup.py", "build"] 140 self.addStep(Compile, command=buildcommand, env=env) 141 self.addStep(Trial, 142 python=trialpython, trial=self.trial, 143 testpath=testpath, 144 tests=tests, testChanges=useTestCaseNames, 145 randomly=self.randomly, 146 recurse=self.recurse, 147 env=env, 148 )
149 150 151 # compatibility classes, will go away. Note that these only offer 152 # compatibility at the constructor level: if you have subclassed these 153 # factories, your subclasses are unlikely to still work correctly. 154 155 ConfigurableBuildFactory = BuildFactory 156
157 -class BasicBuildFactory(GNUAutoconf):
158 # really a "GNU Autoconf-created tarball -in-CVS tree" builder 159
160 - def __init__(self, cvsroot, cvsmodule, 161 configure=None, configureEnv={}, 162 compile="make all", 163 test="make check", cvsCopy=False):
164 mode = "clobber" 165 if cvsCopy: 166 mode = "copy" 167 source = CVS(cvsroot=cvsroot, cvsmodule=cvsmodule, mode=mode) 168 GNUAutoconf.__init__(self, source, 169 configure=configure, configureEnv=configureEnv, 170 compile=compile, 171 test=test)
172
173 -class QuickBuildFactory(BasicBuildFactory):
174 useProgress = False 175
176 - def __init__(self, cvsroot, cvsmodule, 177 configure=None, configureEnv={}, 178 compile="make all", 179 test="make check", cvsCopy=False):
180 mode = "update" 181 source = CVS(cvsroot=cvsroot, cvsmodule=cvsmodule, mode=mode) 182 GNUAutoconf.__init__(self, source, 183 configure=configure, configureEnv=configureEnv, 184 compile=compile, 185 test=test)
186
187 -class BasicSVN(GNUAutoconf):
188
189 - def __init__(self, svnurl, 190 configure=None, configureEnv={}, 191 compile="make all", 192 test="make check"):
193 source = SVN(svnurl=svnurl, mode="update") 194 GNUAutoconf.__init__(self, source, 195 configure=configure, configureEnv=configureEnv, 196 compile=compile, 197 test=test)
198