Symfony2 を Jenkins でCI する準備

Symfony2 はphpunit でテストできます。今回は、Jenkins でphpunitの自動ビルドをするための設定をします。
symfony + jenkins でテストサイクルを回そう | ウェブインパクトエンジニアブログを参考にしつつ環境を作成する。

Git Plugin のインストール

プラグインマネージャーからGit Plugin をインストールします。
Git リポジトリの指定などは普通のプロジェクトを変わりません。

php,pear,phpunitのサーバへのインストール

さくらVPSを使ってます。

# yum install php
# yum install php-pear
# yum install php-dom
# pear channel-discover pear.phpunit.de
# pear channel-discover pear.symfony-project.com
# pear channel-discover components.ez.no
# pear install pear.symfony-project.com/YAML
# pear install components.ez.no/ConsoleTools
# pear install --alldeps phpunit/PHPUnit
# phpunit --version
PHPUnit 3.6.10 by Sebastian Bergmann.

シェルの登録

オプションとして、junitのログを出力するようにしておきます。

$ phpunit --log-junit log/phpunit-result.xml -c app src/Acme/DemoBundle/

さてジョブ実行。。

Acme\DemoBundle\Tests\Controller\DemoControllerTest::testIndex
Exception: DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead

焦りすぎました。php.ini に timezone の設定がありませんでした。

またジョブ実行。。

RuntimeException: You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.

ぐぬぬ。この道はいつか来た道。

php-sqlite は yum install だとないよ

# yum install php-sqlite3

でインストールします。ビルド成功!

本当は紆余曲折してました。

誰か同じ地雷を踏まないように作業履歴も上げておきます。

php-sqlite でインストールできなかったのでpecl でpdo_sqlite をインストールする。

# pecl install pdo_sqlite
〜中略〜
Starting to download PDO-1.0.3.tgz (52,613 bytes)
...done: 52,613 bytes
12 source files, building
running: phpize
sh: phpize: command not found
ERROR: `phpize' failed
111 source files, building
running: phpize
sh: phpize: command not found
ERROR: `phpize' failed

むむ。エラー。phpizeをインストールするため、php-devel をインストールします。

# yum -y install php-devel
# pecl install pdo_sqlite
libtool: compile:  cc -I/var/tmp/PDO_SQLITE/sqlite/src -DPDO_SQLITE_BUNDLED=1 -DSQLITE_OMIT_CURSOR -I/usr/include/php/ext -I. -I/var/tmp/PDO_SQLITE -DPHP_ATOM_INC -I/var/tmp/pear-build-rootcTyPKV/PDO_SQLITE-1.0.1/include -I/var/tmp/pear-build-rootcTyPKV/PDO_SQLITE-1.0.1/main -I/var/tmp/PDO_SQLITE -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /var/tmp/PDO_SQLITE/sqlite_driver.c  -fPIC -DPIC -o .libs/sqlite_driver.o
/var/tmp/PDO_SQLITE/sqlite_driver.c: In function 'do_callback':
/var/tmp/PDO_SQLITE/sqlite_driver.c:311: error: 'zend_fcall_info' has no member named 'object_pp'
/var/tmp/PDO_SQLITE/sqlite_driver.c: At top level:
/var/tmp/PDO_SQLITE/sqlite_driver.c:636: warning: initialization from incompatible pointer type
make: *** [sqlite_driver.lo] Error 1
ERROR: `make' failed

んーなんか無理じゃないのかね。ぐぐってもでないエラーだし。

参考パッケージで入れたPHP 5に最新版sqlite拡張を入れる - 肉とご飯と甘いもの @ sotarok
ということで先人の経験を下にソースからインストールする。

$ tar xzvf php-5.3.10.tar.gz
$ cd php-5.3.10/ext/sqlite
$ phpize
$ ./configure
# make install
# vi /etc/php.d/sqlite.ini

sqlite.ini の内容は、

extension=sqlite.so

ビルド実行だめじゃん!しかし、神は見放さなかった!以下のコマンドでpdo-sqliteがインストールできます。。
俺の2時間はいったい。。

# yum install php-sqlite3