From dee1b38ebcf4249a0204773c255e8ac8e348cb23 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 22 Jan 2013 19:54:48 +0100 Subject: [PATCH 1/5] [ticket/11337] Run functional tests on travis using nginx and php-fpm. PHPBB3-11337 --- .travis.yml | 1 + travis/phpunit-mysql-travis.xml | 1 + travis/phpunit-postgres-travis.xml | 1 + travis/setup-webserver.sh | 53 ++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100755 travis/setup-webserver.sh diff --git a/.travis.yml b/.travis.yml index ba8c1b4a91..09c5059749 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ before_script: - cd phpBB - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then php ../composer.phar install --dev; fi" - cd .. + - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then travis/setup-webserver.sh; fi" script: - phpunit --configuration travis/phpunit-$DB-travis.xml diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index 5366494c8b..df97f1c0f0 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -35,5 +35,6 @@ + diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 0383edd9d6..49c001b717 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -37,5 +37,6 @@ + diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh new file mode 100755 index 0000000000..c475f0f7ff --- /dev/null +++ b/travis/setup-webserver.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# @copyright (c) 2013 phpBB Group +# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +# + +sudo apt-get update -qq +sudo apt-get install -qq nginx realpath + +sudo service nginx stop + +DIR=$(dirname "$0") +PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB") + +NGINX_CONF="/etc/nginx/sites-enabled/default" + +PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm" +PHP_FPM_CONF="$DIR/php-fpm.conf" +PHP_FPM_SOCK=$(realpath "$DIR")/php-fpm.sock + +USER=$(whoami) + +# php-fpm configuration +echo " +[global] + +[travis] +user = $USER +group = $USER +listen = $PHP_FPM_SOCK +pm = static +pm.max_children = 2 + +php_admin_value[memory_limit] = 128M +" | sudo tee $PHP_FPM_CONF + +# nginx configuration +echo " +server { + listen 80; + root $PHPBB_ROOT_PATH/; + index index.php index.html; + + location ~ \.php$ { + fastcgi_pass unix:$PHP_FPM_SOCK; + include fastcgi_params; + } +} +" | sudo tee $NGINX_CONF + +# Start daemons +sudo $PHP_FPM_BIN --fpm-config "$DIR/php-fpm.conf" +sudo service nginx start From d2f09a9e65c71aaae6753e7f715333374a0bd455 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 22 Jan 2013 20:21:19 +0100 Subject: [PATCH 2/5] [ticket/11337] php-fpm.conf is no longer owned by root. PHPBB3-11337 --- travis/setup-webserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index c475f0f7ff..d2ee42f862 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -32,7 +32,7 @@ pm = static pm.max_children = 2 php_admin_value[memory_limit] = 128M -" | sudo tee $PHP_FPM_CONF +" > $PHP_FPM_CONF # nginx configuration echo " From ea1c8ee85a30d44ceb63a4c8210541bfb01edff2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 22 Jan 2013 20:21:41 +0100 Subject: [PATCH 3/5] [ticket/11337] Silence nginx config file writing. PHPBB3-11337 --- travis/setup-webserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index d2ee42f862..ad63508ca6 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -46,7 +46,7 @@ server { include fastcgi_params; } } -" | sudo tee $NGINX_CONF +" | sudo tee $NGINX_CONF > /dev/null # Start daemons sudo $PHP_FPM_BIN --fpm-config "$DIR/php-fpm.conf" From 9860cf6b165f71b58c69da0bfc42e27bea1c24c9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 23 Jan 2013 00:26:38 +0100 Subject: [PATCH 4/5] [ticket/11337] Only run functional tests on 5.3.19 or higher. No FPM otherwise. There is no php-fpm for PHP 5.3.3. Make sure PHP version is at least 5.3.19, which is what 5.3 is currently aliased to. PHPBB3-11337 --- .travis.yml | 2 +- travis/phpunit-mysql-travis.xml | 2 +- travis/phpunit-postgres-travis.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09c5059749..0bb6920412 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: - cd phpBB - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then php ../composer.phar install --dev; fi" - cd .. - - sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then travis/setup-webserver.sh; fi" + - sh -c "if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` = "1" ]; then travis/setup-webserver.sh; fi" script: - phpunit --configuration travis/phpunit-$DB-travis.xml diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index df97f1c0f0..179a2a358e 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -17,7 +17,7 @@ tests/functional - ../tests/functional + ../tests/functional diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 49c001b717..12e20547ba 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -17,7 +17,7 @@ tests/functional - ../tests/functional + ../tests/functional From 4b9c163969cfffc302780d48015453a3ce472dca Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 23 Jan 2013 00:55:11 +0100 Subject: [PATCH 5/5] [ticket/11337] Abort setup-webserver.sh script when an error occurs. PHPBB3-11337 --- travis/setup-webserver.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh index ad63508ca6..beb04b0fef 100755 --- a/travis/setup-webserver.sh +++ b/travis/setup-webserver.sh @@ -3,6 +3,7 @@ # @copyright (c) 2013 phpBB Group # @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 # +set -e sudo apt-get update -qq sudo apt-get install -qq nginx realpath