Skip to content

Commit

Permalink
Cleaned up before_script.sh so that it was possible to reuse it for V…
Browse files Browse the repository at this point in the history
…agrant
  • Loading branch information
zerkms committed Jun 21, 2014
1 parent 1a80bec commit 5b4cfef
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 54 deletions.
File renamed without changes.
8 changes: 8 additions & 0 deletions .ci/before_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BEFORE_SCRIPT_DIR=$(dirname $0)

source $BEFORE_SCRIPT_DIR/common_env.sh
source $BEFORE_SCRIPT_DIR/travis_env.sh

source $BEFORE_SCRIPT_DIR/setup.sh

source $BEFORE_SCRIPT_DIR/start.sh
6 changes: 6 additions & 0 deletions .ci/common_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

SELENIUM_HUB_URL='http://127.0.0.1:4444'
SELENIUM_JAR=/usr/share/selenium/selenium-server-standalone.jar
SELENIUM_DOWNLOAD_URL=http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.1.jar
PHP_VERSION=$(php -v)
13 changes: 13 additions & 0 deletions .ci/phpunit-environment.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[program:selenium]
command=xvfb-run java -Dwebdriver.firefox.bin=/usr/bin/firefox -jar /usr/share/selenium/selenium-server-standalone.jar
autostart=false ; selenium

[program:python-webserver]
command=python -m SimpleHTTPServer 8080
directory=. ; python-webserver
autostart=false ; python-webserver

[program:php-webserver]
command=php -S localhost:8080
directory=. ; php-webserver
autostart=false ; php-webserver
35 changes: 35 additions & 0 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [ ! -f "/usr/local/bin/composer" ]; then
echo "Installing Composer"
php -r "readfile('https://getcomposer.org/installer');" | sudo php -d apc.enable_cli=0 -- --install-dir=/usr/local/bin --filename=composer
else
echo "Updating Composer"
sudo /usr/local/bin/composer self-update
fi

if [ ! -d vendor ] || [ ! -f vendor/autoload.php ]; then
echo "Installing dependencies"
composer install --dev
fi

echo "Installing supervisord"
sudo apt-get install supervisor -y --no-install-recommends
sudo cp ./.ci/phpunit-environment.conf /etc/supervisor/conf.d/
sudo sed -i "s/^directory=.*webserver$/directory=${ESCAPED_BUILD_DIR}\\/selenium-1-tests/" /etc/supervisor/conf.d/phpunit-environment.conf
sudo sed -i "s/^autostart=.*selenium$/autostart=true/" /etc/supervisor/conf.d/phpunit-environment.conf

if $(echo "$PHP_VERSION" | grep --quiet 'PHP 5.4'); then
sudo sed -i "s/^autostart=.*php-webserver$/autostart=true/" /etc/supervisor/conf.d/phpunit-environment.conf
else
sudo sed -i "s/^autostart=.*python-webserver$/autostart=true/" /etc/supervisor/conf.d/phpunit-environment.conf
fi

echo "Installing Firefox"
sudo apt-get install firefox -y --no-install-recommends

if [ ! -f "$SELENIUM_JAR" ]; then
echo "Downloading Selenium"
sudo mkdir -p $(dirname "$SELENIUM_JAR")
sudo wget -nv -O "$SELENIUM_JAR" "$SELENIUM_DOWNLOAD_URL"
fi
10 changes: 10 additions & 0 deletions .ci/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

sudo supervisorctl reload

wget --retry-connrefused --tries=60 --waitretry=1 --output-file=/dev/null "$SELENIUM_HUB_URL/wd/hub/status" -O /dev/null
if [ ! $? -eq 0 ]; then
echo "Selenium Server not started"
else
echo "Finished setup"
fi
3 changes: 3 additions & 0 deletions .ci/travis_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

ESCAPED_BUILD_DIR=$(echo "$TRAVIS_BUILD_DIR" | sed 's/\//\\\//g')
3 changes: 3 additions & 0 deletions .ci/vagrant_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

ESCAPED_BUILD_DIR="\/vagrant"
12 changes: 12 additions & 0 deletions .ci/vagrant_pre_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

sed -i "/mirror:\\/\\//d" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse" /etc/apt/sources.list

apt-get update

# installing xvfb, java and php
apt-get install xvfb openjdk-7-jre-headless php5-cli php5-curl php5-xdebug -y --no-install-recommends
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ firefox/
/.project
/.buildpath
/.settings
/.vagrant/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ language: php
php:
- 5.3
- 5.4
before_script: ./before_script.sh
before_script: ./.ci/before_script.sh
script: "vendor/bin/phpunit --verbose --debug Tests"
22 changes: 22 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
VAGRANTFILE_API_VERSION = "2"

$setupEnvironment = <<-SCRIPT
cd /vagrant
source ./.ci/vagrant_pre_setup.sh
source ./.ci/common_env.sh
source ./.ci/vagrant_env.sh
source ./.ci/setup.sh
source ./.ci/start.sh
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise32"

config.vm.provision "shell", inline: $setupEnvironment
end
53 changes: 0 additions & 53 deletions before_script.sh

This file was deleted.

0 comments on commit 5b4cfef

Please sign in to comment.