| 1 | #!/usr/bin/python |
|---|
| 2 | # -*- coding: UTF-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2007 Tarek Ziadé |
|---|
| 5 | # |
|---|
| 6 | # Authors: |
|---|
| 7 | # Tarek Ziadé <tarek@ziade.org> |
|---|
| 8 | # |
|---|
| 9 | # This program is free software; you can redistribute it and/or |
|---|
| 10 | # modify it under the terms of the GNU General Public License |
|---|
| 11 | # as published by the Free Software Foundation; either version 2 |
|---|
| 12 | # of the License, or (at your option) any later version. |
|---|
| 13 | # |
|---|
| 14 | # This program is distributed in the hope that it will be useful, |
|---|
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | # GNU General Public License for more details. |
|---|
| 18 | # |
|---|
| 19 | # You should have received a copy of the GNU General Public License |
|---|
| 20 | # along with this program; if not, write to the Free Software |
|---|
| 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | import datetime, time, os.path |
|---|
| 23 | from buildbot.scheduler import Scheduler, Nightly |
|---|
| 24 | from buildbot.process import step, factory |
|---|
| 25 | from buildbot.status import html |
|---|
| 26 | from buildbot.status import mail |
|---|
| 27 | from buildbot.changes.pb import PBChangeSource |
|---|
| 28 | from twisted.python import log |
|---|
| 29 | |
|---|
| 30 | # configuration |
|---|
| 31 | SVN_USER = 'buildbot' |
|---|
| 32 | SVN_PASSWORD = 'bb426hy544' |
|---|
| 33 | SVN_SERVER = 'localhost/repo' |
|---|
| 34 | TEST_BUNDLE = '/private/ecs/bundles/emencia' |
|---|
| 35 | PATH_BUNDLE = '/private/ecs/build/ecs' |
|---|
| 36 | TARGET_MAIL = 'checkins@lists.emencia.net' |
|---|
| 37 | SOURCE_MAIL = 'buildbot@lists.emencia.net' |
|---|
| 38 | SVN_FRONT_NAME = 'svn.emencia.net' |
|---|
| 39 | |
|---|
| 40 | svnserver = 'http://%s:%s@/%s' % (SVN_USER, SVN_PASSWORD, SVN_SERVER) |
|---|
| 41 | port = 9989 |
|---|
| 42 | wport = 8010 |
|---|
| 43 | |
|---|
| 44 | class RepositoryScheduler(Scheduler): |
|---|
| 45 | def __init__(self, name, branch, treeStableTimer, builderNames, |
|---|
| 46 | repository, fileIsImportant=None): |
|---|
| 47 | Scheduler.__init__(self, name, branch, treeStableTimer, |
|---|
| 48 | builderNames, fileIsImportant) |
|---|
| 49 | self.repository = repository |
|---|
| 50 | |
|---|
| 51 | def addChange(self, change): |
|---|
| 52 | # check to make sure the repository matches! |
|---|
| 53 | cs = change.comments.split(' ') |
|---|
| 54 | if len(cs) > 0: |
|---|
| 55 | repo = cs[0] |
|---|
| 56 | log.msg('checking %s vs %s' % |
|---|
| 57 | (repo, self.repository)) |
|---|
| 58 | if repo != self.repository: |
|---|
| 59 | log.msg("%s ignoring repository %s" % |
|---|
| 60 | (self, repo)) |
|---|
| 61 | return |
|---|
| 62 | # call our parent since this on the correct repository |
|---|
| 63 | Scheduler.addChange(self, change) |
|---|
| 64 | |
|---|
| 65 | s = factory.s |
|---|
| 66 | c = BuildmasterConfig = {} |
|---|
| 67 | c['bots'] = [("bot", SVN_PASSWORD)] |
|---|
| 68 | c['sources'] = [PBChangeSource()] |
|---|
| 69 | c['schedulers'] = [] |
|---|
| 70 | c['builders'] = [] |
|---|
| 71 | c['status'] = [] |
|---|
| 72 | |
|---|
| 73 | repos = (('ecs', TEST_BUNDLE |
|---|
| 74 | 'http://%s:%s@%s/%s' % (SVN_USER, SVN_PASSWORD, SVN_SERVER, |
|---|
| 75 | TEST_PATH),) |
|---|
| 76 | |
|---|
| 77 | for name, path, svnurl in repos: |
|---|
| 78 | quick = Scheduler(name, None, 60, [name]) |
|---|
| 79 | c['schedulers'].append(quick) |
|---|
| 80 | test_steps = [s(step.SVN, mode="update", baseURL= svnserver + path, |
|---|
| 81 | svnurl=svnurl), |
|---|
| 82 | s(step.Test, command=["make", "test"])] |
|---|
| 83 | test_f = factory.BuildFactory(test_steps) |
|---|
| 84 | pauline = {'name': name, 'slavename': 'bot', |
|---|
| 85 | 'builddir': name, 'factory': test_f} |
|---|
| 86 | c['builders'].append(pauline) |
|---|
| 87 | |
|---|
| 88 | names = [name for name, path, svnurl in repos] |
|---|
| 89 | |
|---|
| 90 | c['status'].append(mail.MailNotifier(builders=names, |
|---|
| 91 | fromaddr=SOURCE_MAIL, |
|---|
| 92 | extraRecipients=[TARGET_MAIL], |
|---|
| 93 | mode='failing', |
|---|
| 94 | sendToInterestedUsers=True)) |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | c['status'].append(html.Waterfall(http_port=wport)) |
|---|
| 98 | c['slavePortnum'] = port |
|---|
| 99 | c['projectName'] = "ecs" |
|---|
| 100 | c['projectURL'] = "" |
|---|
| 101 | c['buildbotURL'] = "http://%s:%d/" % (SVN_FRONT_NAME, wport) |
|---|