Skip to content
This repository has been archived by the owner on Feb 17, 2018. It is now read-only.

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma committed Mar 22, 2012
1 parent 96db703 commit c6413b7
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 33 deletions.
1 change: 1 addition & 0 deletions emacs/changes.py
Expand Up @@ -12,6 +12,7 @@ def __init__(self, repo, branch, interval, project):
"%s-%s" % (project._project_name, branch))
spec = '+refs/heads/%s:refs/remotes/origin/%s' % (branch, branch)
GitPoller.__init__(self, repo,
category=project._project_name,
workdir=workdir,
fetch_refspec=spec,
branch=branch, pollinterval=interval)
9 changes: 9 additions & 0 deletions emacs/config.py
@@ -1,3 +1,5 @@
from buildbot.config import BuilderConfig

class EmacsBuildConfig(dict):

def __init__(self, projectName="Buildbot", projectURL="", slavePortnum=9901,
Expand All @@ -14,3 +16,10 @@ def __init__(self, projectName="Buildbot", projectURL="", slavePortnum=9901,
self['projectURL'] = projectURL
self['buildbotURL'] = buildbotURL
self['db_url'] = db_url

class EmacsBuilderConfig(BuilderConfig):

def __init__(self, name, branch, slavenames=None, factory=None, category=None):
BuilderConfig.__init__(self, name=name, slavenames=slavenames,
factory=factory, category=category)
self.branch = branch
78 changes: 75 additions & 3 deletions emacs/projects/_base.py
@@ -1,20 +1,31 @@
from itertools import product
from ..config import EmacsBuilderConfig

class EmacsProject(object):

_project_name = ""
_project_combinations = {}

def __init__(self, config, slaves):
self._config = config
self._slaves = slaves
self._builders = None
self._schedulers = None
self._pollers = None

def dispatch(self):
config = self._config

config['slaves'].extend(self._slaves)
config['builders'].extend(self.getBuilders())
config['schedulers'].extend(self.getSchedulers())

config['change_source'].extend(self.getPollers())
self._builders = self.getBuilders()
config['builders'].extend(self._builders)

self._schedulers = self.getSchedulers()
config['schedulers'].extend(self._schedulers)

self._pollers = self.getPollers()
config['change_source'].extend(self._pollers)

def getPollers(self):
return []
Expand All @@ -24,3 +35,64 @@ def getSchedulers(self):

def getBuilders(self):
return []

def getAssignments(self):
keys = self._project_combinations.keys()
values = self._project_combinations.values()

assignments = {}

for combo in product(*values):
combo_tag = ":".join(combo)
assignments[combo_tag] = []
for slave in self._slaves:
fits = True
for key, val in zip(keys, combo):
if not slave.properties.hasProperty(key):
fits = False
break
if slave.properties.getProperty(key) != val:
fits = False
break
if fits:
assignments[combo_tag].append(slave.slavename)

return assignments

class EmacsGitProject(EmacsProject):

_project_git_repo = ""
_project_git_branches = ""

def getPollers(self):
return [self.getBranchPoller(branch)
for branch in self._project_git_branches]

def getSchedulers(self):
schedulers = []

for branch in self._project_git_branches:
schedulers.extend(self.getBranchSchedulers(branch))

return schedulers

def getBuilders(self):
builders = []

assignments = self.getAssignments()

for branch in self._project_git_branches:
factory = self.getBranchFactory(branch)

for combo, slaves in assignments.items():
if not slaves or len(slaves) == 0:
continue
name = "%s:%s:%s" % (self._project_name,
branch, combo)
builders.append(EmacsBuilderConfig(name=name,
branch=branch,
slavenames=slaves,
factory=factory,
category=self._project_name))

return builders
60 changes: 32 additions & 28 deletions emacs/projects/magit.py
@@ -1,40 +1,44 @@
from ._base import EmacsProject
from ._base import EmacsGitProject
from ..changes import EmacsGitPoller

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

from buildbot.process.factory import BuildFactory
from buildbot.steps.source import Git
from ..steps import EmacsCompile
from buildbot.config import BuilderConfig

class MagitProject(EmacsProject):
class MagitProject(EmacsGitProject):

_project_name = 'magit'

MAGIT_GIT_REPO = 'git://github.com/magit/magit.git'
MAGIT_GIT_BRANCHES = ['master']

def getPollers(self):
return [EmacsGitPoller(self.MAGIT_GIT_REPO, branch, 300, self)
for branch in self.MAGIT_GIT_BRANCHES]

def getSchedulers(self):
return [SingleBranchScheduler(
name="master",
change_filter=filter.ChangeFilter(branch='master'),
treeStableTimer=10,
builderNames=["master:linux-oneiric"])]

def getBuilders(self):
build_master_factory = BuildFactory()
build_master_factory.addStep(
Git(repourl=self.MAGIT_GIT_REPO, mode='copy',
branch="master"))
build_master_factory.addStep(
_project_combinations = {'os': ['lx-oneiric', 'osx-lion'],
'arch': ['64']}

_project_git_repo = 'git://github.com/magit/magit.git'
_project_git_branches = ['maint', 'master', 'next']

def getBranchPoller(self, branch):
return EmacsGitPoller(self._project_git_repo, branch, 300, self)

def getBranchSchedulers(self, branch):
filt = filter.ChangeFilter(branch=branch)
builders = [b.name for b in self._builders
if b.branch==branch]
name = "%s:%s" % (self._project_name, branch)
return [SingleBranchScheduler(name=name,
change_filter=filt,
treeStableTimer=10,
builderNames=builders),
# ForceScheduler(name=name + "--force",
# builderNames=builders)
]

def getBranchFactory(self, branch):
factory = BuildFactory()
factory.addStep(
Git(repourl=self._project_git_repo, mode='copy',
branch=branch))
factory.addStep(
EmacsCompile(command=["make", "clean", "all"]))

return [BuilderConfig(name="master:linux-oneiric",
slavenames=["magit:master:linux-oneiric"],
factory=build_master_factory)]
return factory
8 changes: 6 additions & 2 deletions master.cfg
Expand Up @@ -15,7 +15,9 @@ from buildbot.buildslave import BuildSlave
c = BuildmasterConfig = EmacsBuildConfig(projectName="Emacs Buildbot",
projectURL="http://dev.hodique.info")

slaves = [BuildSlave("magit:master:linux-oneiric", "fej253#@%e07")]
slaves = [BuildSlave("lx-oneiric:64", "fej253#@%e07",
properties={'os': 'lx-oneiric',
'arch': '64'})]

from emacs.projects.magit import MagitProject

Expand All @@ -35,8 +37,10 @@ from buildbot.status.web import auth, authz
authz_cfg=authz.Authz(
# change any of these to True to enable; see the manual for more
# options
# auth=auth.BasicAuth([("pyflakes","pyflakes")]),
auth=None,
gracefulShutdown = False,
forceBuild = False, # use this to test your slave once it is set up
forceBuild = False,
forceAllBuilds = False,
pingBuilder = False,
stopBuild = False,
Expand Down

0 comments on commit c6413b7

Please sign in to comment.