# HG changeset patch # User Jeff Hammel # Date 1296666688 28800 # Node ID cb9ad0b041401dca9bf77a4bc4ad573769027108 # Parent e15ccc0e1463bf12063af01cb527586ba79212b4 preliminary passing of platform information from slaves; not yet tested diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/config.py --- a/autobot/config.py Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/config.py Wed Feb 02 09:11:28 2011 -0800 @@ -36,15 +36,28 @@ name = section.split('slave:', 1)[-1] slave_dict = self.master.copy() slave_dict.update(self.section_dict(section)) - assert 'password' in slave_dict, 'Slave %s: must provide a password' + assert 'password' in slave_dict, 'Slave %s: must provide a password' % name + + # get factories _factories = slave_dict.get('factories', '') _factories = _factories.split() if _factories == ['']: _factories = [] if _factories == ['*']: _factories = factories.keys() + + # get platform information + platform = {} + for key in 'os': + if key in slave_dict: + platform[key] = slave_dict.pop(key) + else: + platform[key] = None + + # put it together coherently self.slaves[name] = {'password': slave_dict['password'], - 'factories': _factories } + 'factories': _factories, + 'platform': platform } continue # get factories diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/process/factory.py --- a/autobot/process/factory.py Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/process/factory.py Wed Feb 02 09:11:28 2011 -0800 @@ -24,9 +24,10 @@ sources = {'git': [], 'hg': []} default_branches = {'git': 'master', 'hg': 'default'} - def __init__(self, git=None, hg=None): + def __init__(self, platform=None, git=None, hg=None): BuildFactory.__init__(self) + self.platform = platform # override class-level defaults if git is not None: @@ -72,15 +73,15 @@ create a virtualenv and install some python packages in it """ - def __init__(self, name='env', hg=None, git=None, checkout=True): + def __init__(self, platform=None, name='env', hg=None, git=None, checkout=True): """ - name : of the virtualenv - hg: sources of python packages with setuptools setup.pys - git: git sources of python package """ - SourceFactory.__init__(self, hg=hg, git=git) + SourceFactory.__init__(self, platform=platform, hg=hg, git=git) - # wipe any vesitages + # wipe any vestiges self.addStep(ShellCommand(command=['rm', '-rf', name])) # create a virtualenv @@ -124,10 +125,10 @@ setup several python packages """ - def __init__(self, name='env', hg=None, git=None): + def __init__(self, platform=None, name='env', hg=None, git=None): # setup the environment - VirtualenvFactory.__init__(self, name=name, hg=hg, git=git) + VirtualenvFactory.__init__(self, platform=platform, name=name, hg=hg, git=git) # install the packages sources = [] diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/projects/__init__.py --- a/autobot/projects/__init__.py Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/projects/__init__.py Wed Feb 02 09:11:28 2011 -0800 @@ -11,22 +11,30 @@ """ import imp +import inspect import os import sys from buildbot.process.factory import BuildFactory from logparser import TestLogParserFactory from mozmill import TestMozmillFactory +__all__ = ['factories', 'descriptions', 'here', 'args'] + # available factories:: # import these automagically; requires non-zipped eggs -factories = {} -descriptions = {} +factories = {} # factory classes +descriptions = {} # their descriptions +args = {} # their arguments here = os.path.dirname(os.path.abspath(__file__)) packages = [os.path.join(here, path) for path in os.listdir(here) if os.path.isdir(os.path.join(here, path))] packages = [os.path.basename(package) for package in packages if os.path.exists(os.path.join(package, '__init__.py'))] +modules = [os.path.splitext(module)[0] + for module in os.listdir(here) + if module.endswith('.py') and not module.startswith('_')] +packages.extend(modules) for package in packages: try: module = imp.load_package('autobot.projects.'+package, imp.find_module(package, [here])[1]) @@ -39,6 +47,7 @@ if issubclass(_obj, BuildFactory) and _obj.__module__.startswith('autobot.projects.'): factories[package] = _obj descriptions[package] = (getattr(_obj, '__doc__', attr) or attr).strip() + args[package] = inspect.getargspec(_obj.__init__).args[1:] # not self except TypeError: continue diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/projects/autobot/__init__.py --- a/autobot/projects/autobot/__init__.py Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/projects/autobot/__init__.py Wed Feb 02 09:11:28 2011 -0800 @@ -9,10 +9,10 @@ sources = {'hg': ['http://k0s.org/mozilla/hg/autobot']} - def __init__(self, slaveport=7357, htmlport=7358): + def __init__(self, platform=None, slaveport=7357, htmlport=7358): # setup the environment - PythonSourceFactory.__init__(self, name='autobot') + PythonSourceFactory.__init__(self, platform=platform, name='autobot') # find the necessary scripts self.findScript('create-autobot') @@ -35,7 +35,6 @@ haltOnFailure=True)) - # make sure they start self.addStep(ShellCommand(command=[WithProperties('%(buildbot)s'), 'start', 'master'], diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/projects/mozmill/__init__.py --- a/autobot/projects/mozmill/__init__.py Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/projects/mozmill/__init__.py Wed Feb 02 09:11:28 2011 -0800 @@ -11,11 +11,11 @@ # VCS sources = {'git': ['http://github.com/mozautomation/mozmill.git']} - def __init__(self, firefox_url=None, git=None, + def __init__(self, platform=None, git=None, tests='http://hg.mozilla.org/qa/mozmill-tests'): # setup the environment - VirtualenvFactory.__init__(self, name='mozmill', git=git) + VirtualenvFactory.__init__(self, name='mozmill', platform=platform, git=git) # currently, mozmill-tests are dealt with separately here # this is to avoid having mozmill depend on them or their changes diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/projects/project.template --- a/autobot/projects/project.template Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/projects/project.template Wed Feb 02 09:11:28 2011 -0800 @@ -11,9 +11,10 @@ sources = {'hg': ['{{repo}}'], 'git': []} - def __init__(self): - SourceFactory.__init__(self) + def __init__(self, platform=None): + SourceFactory.__init__(self, platform=platform) + # checkout the repositories self.checkout() # run the tests [TODO] diff -r e15ccc0e1463 -r cb9ad0b04140 autobot/template/master/master.cfg --- a/autobot/template/master/master.cfg Tue Feb 01 21:34:30 2011 -0800 +++ b/autobot/template/master/master.cfg Wed Feb 02 09:11:28 2011 -0800 @@ -23,11 +23,20 @@ # define builder factories from autobot.projects import factories as factory_dict +from autobot.projects import args builders = [] for slave in config.slaves: for factory in config.slaves[slave]['factories']: - f = factory_dict[factory](**config.args.get(factory, {})) + + # get the factory constructor arguments + factory_args = config.args.get(factory, {}).copy() + if 'platform' in args[factory]: + # slave platform information + factory_args['platform'] = config.slaves[slave]['platform'] + + # make a factory + f = factory_dict[factory](**factory_args) # define builder buildername = '%s - %s' % (factory, slave)