Hatena::Groupcatalyst

dann@catalyst このページをアンテナに追加 RSSフィード

2008-03-08

CatalystアプリをbuildbotでContinuous Integration

| 20:29 |  CatalystアプリをbuildbotでContinuous Integration - dann@catalyst を含むブックマーク はてなブックマーク -  CatalystアプリをbuildbotでContinuous Integration - dann@catalyst  CatalystアプリをbuildbotでContinuous Integration - dann@catalyst のブックマークコメント

buildbotはPythonで記述されたCIツールで、割と多くのプロジェクトで使われているようです。

http://buildbot.sourceforge.net/manual-0.7.5.html

どのような形で結果が見えるのかは、djangoのページなどを参照するのがわかりやすいです。

http://buildbot.djangoproject.com/

buildbotでは、スケジュールに応じてビルド・テストなどを行い、ビルド・テストの結果をメールやIRCなどで通知させることができます。CIツールはテスト数が多くなってきたときに活躍します。日に数回、全体の単体テスト・機能テストを全て実行するようにしておくと、プロダクトのデグレードは減ります。

前置きはおいといて、実際にbuildbotの設定方法を見ていきましょう。

インストール

sudo aptitude install buildbot

マスターの作成

% buildbot create-master ~/Buildbot/master/MyApp

マスターの設定

% vim ~/Buildbot/master/MyApp/master.cfg

master.cfgには、大きく分けて、大体以下の4つの設定をします

  • sourcesに、何をチェック対象にするかを記述
  • scheduleに、どのようなタイミングでsourceをチェックするかを設定
  • buildersに、ビルドやテストのステップを記述
  • statusに、ビルド結果の通知方法を記述

master.cfgは、以下のような感じに書きます。

# -*- python -*-
# ex: set syntax=python:

# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory (although the filename
# can be changed with the --basedir option to 'mktap buildbot master').

# It has one job: define a dictionary named BuildmasterConfig. This
# dictionary has a variety of keys to control different aspects of the
# buildmaster. They are documented in docs/config.xhtml .


# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}

####### BUILDSLAVES

# the 'bots' list defines the set of allowable buildslaves. Each element is a
# tuple of bot-name and bot-password. These correspond to values given to the
# buildslave's mktap invocation.
c['bots'] = [("MyApp-bot","buildbot")]


# 'slavePortnum' defines the TCP port to listen on. This must match the value
# configured into the buildslaves (with their --master option)

c['slavePortnum'] = 9989

####### CHANGESOURCES
# the 'sources' list tells the buildmaster how it should find out about
# source code changes. Any class which implements IChangeSource can be added
# to this list: there are several in buildbot/changes/*.py to choose from.

from buildbot.changes.svnpoller import SVNPoller
source_code_svn_url='http://192.168.0.30/svn/MyApp/trunk'
svn_user='buildbot'
svn_password='password'

svn_poller = SVNPoller(
    svnurl=source_code_svn_url,
    svnuser=svn_user,
    svnpasswd=svn_password,
    pollinterval=60*1, #seconds
    histmax=10,
    svnbin='/usr/bin/svn',)

c['sources'] = [ svn_poller ]

####### SCHEDULERS

## configure the Schedulers
# When to run builds
from buildbot import scheduler
daily = scheduler.Periodic("daily", ["MyApp-Builder"], 24*60*60)
code_changed = scheduler.Scheduler(name="code_changed",
    branch=None,
    treeStableTimer=10*60,
    builderNames=["MyApp-Builder"])
c['schedulers'] = [ daily,code_changed ]

####### BUILDERS
# How to build the software
builders = []

from buildbot.process import factory
from buildbot.steps import source,shell
f1 = factory.BuildFactory()
f1.addStep(source.SVN,
    svnurl=source_code_svn_url,
    mode="clobber")
f1.addStep(shell.ShellCommand, command=['perl', 'Makefile.PL'])
f1.addStep(shell.ShellCommand, command=['make'])
f1.addStep(shell.ShellCommand, command=['make', 'test'])

b1 = {'name': 'MyApp-Builder',
    'slavename': 'MyApp-bot',
    'builddir': 'myapp_build_dir',
    'factory': f1,}
c['builders'] = [b1]

####### STATUS TARGETS
# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# including web pages, email senders, and IRC bots.


from buildbot.status import html
from buildbot.status import words
htmlStatus = html.Waterfall(http_port=8010)
ircStatus = words.IRC(host="irc.example.net", nick="buildbot",
                              channels=["#myapp-test"])
c['status'] = [htmlStatus,ircStatus]

c['status'] = [htmlStatus,ircStatus]

# from buildbot.status import mail
# c['status'].append(mail.MailNotifier(fromaddr="buildbot@localhost",
#                                      extraRecipients=["builds@example.com"],
#                                      sendToInterestedUsers=False))
#
# from buildbot.status import words
# c['status'].append(words.IRC(host="irc.example.com", nick="bb",
#                              channels=["#example"]))
#
# from buildbot.status import client
# c['status'].append(client.PBListener(9988))


####### DEBUGGING OPTIONS

# if you set 'debugPassword', then you can connect to the buildmaster with
# the diagnostic tool in contrib/debugclient.py . From this tool, you can
# manually force builds and inject changes, which may be useful for testing
# your buildmaster without actually commiting changes to your repository (or
# before you have a functioning 'sources' set up). The debug tool uses the
# same port number as the slaves do: 'slavePortnum'.

#c['debugPassword'] = "debugpassword"

# if you set 'manhole', you can ssh into the buildmaster and get an
# interactive python shell, which may be useful for debugging buildbot
# internals. It is probably only useful for buildbot developers. You can also
# use an authorized_keys file, or plain telnet.
#from buildbot import manhole
#c['manhole'] = manhole.PasswordManhole("tcp:9999:interface=127.0.0.1",
#                                       "admin", "password")


####### PROJECT IDENTITY

# the 'projectName' string will be used to describe the project that this
# buildbot is working on. For example, it is used as the title of the
# waterfall HTML page. The 'projectURL' string will be used to provide a link
# from buildbot HTML pages to your project's home page.

c['projectName'] = "MyApp"
c['projectURL'] = "http://192.168.0.30/"

# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.Waterfall page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry, but
# with an externally-visible host name which the buildbot cannot figure out
# without some help.

c['buildbotURL'] = "http://192.168.0.30:8010/"

スレーブ用のアカウント作成

アカウント名はbuildbotで。

スレーブの作成

スレーブのアカウントで、スレーブ作成

buildbot create-slave /home/buildbot/Buildbot/slave/MyApp 192.168.0.30:9989 MyApp-bot buildbot

スレーブの設定ファイルは、buildbot.tacに記述されている。

マスターとスレーブの起動

master% buildbot start /home/buildbot/Buildbot/slave/MyApp
buildbot % buildbot start /home/buildbot/Buildbot/master/MyApp

これで、上記のmaster.cfgの設定では、Subversionにチェックインされたコードがあればビルドされます。また、Dailyでビルドされます。結果は、http://192.168.0.30:8010/で見ることができます。

テストが失敗していれば、その部分が「赤く」表示されます。

Catalystアプリのテストと書いていますが、make testしているだけなので、他のものでもテストできます。

設定・実行の際の注意点

  • 記述が間違っている場合のエラーメッセージが貧弱なので、エラーがでたらStackTraceを見て、どこが間違っているかを探す。
  • twistd.* は消してから、buildbot start を実行しないとダメ

idudeiyacouidudeiyacou2019/07/05 16:08http://mewkid.net/buy-amoxicillin/ - Amoxicillin Online <a href="http://mewkid.net/buy-amoxicillin/">Buy Amoxicillin</a> dyd.ifmc.catalyst.g.hatena.ne.jp.yuq.xs http://mewkid.net/buy-amoxicillin/

iridubabeeiridubabee2019/07/05 16:28http://mewkid.net/buy-amoxicillin/ - Amoxicillin 500mg Capsules <a href="http://mewkid.net/buy-amoxicillin/">Amoxicillin Online</a> yxl.nwgj.catalyst.g.hatena.ne.jp.sak.lj http://mewkid.net/buy-amoxicillin/

トラックバック - http://catalyst.g.hatena.ne.jp/dann/20080308