Skip to content

Commit

Permalink
Issue LionsAd#38: Restructured drupal_ti_ensure_drupal and sub functi…
Browse files Browse the repository at this point in the history
…ons for backward compatibility.
  • Loading branch information
yanniboi committed Jan 23, 2017
1 parent cfe551b commit ea1f601
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 31 deletions.
5 changes: 0 additions & 5 deletions environments/drupal-7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ function drupal_ti_download_drupal() {
}

function drupal_ti_install_drupal() {
if [ ! -f install.php ]
then
return -1
fi

php -d sendmail_path=$(which true) ~/.composer/vendor/bin/drush.php --yes site-install "$DRUPAL_TI_INSTALL_PROFILE" --db-url="$DRUPAL_TI_DB_URL"
drush use $(pwd)#default
}
Expand Down
4 changes: 0 additions & 4 deletions environments/drupal-8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ function drupal_ti_download_drupal() {
}

function drupal_ti_install_drupal() {
if [ ! -f install.php ]
then
return -1
fi
php -d sendmail_path=$(which true) ~/.composer/vendor/bin/drush.php --yes -v site-install "$DRUPAL_TI_INSTALL_PROFILE" --db-url="$DRUPAL_TI_DB_URL"
drush use $(pwd)#default
}
Expand Down
35 changes: 19 additions & 16 deletions functions/drupal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Common functionality for common tasks.

#
# Ensures that the right Drupal version exists.
# Ensures that the right Drupal version is downloaded.
#
function drupal_ti_ensure_drupal() {
function drupal_ti_ensure_drupal_download() {
# This function is re-entrant.
if [ -d "$DRUPAL_TI_DRUPAL_DIR" ]
then
Expand All @@ -30,16 +30,24 @@ function drupal_ti_ensure_drupal() {
}

#
# Ensures that Drupal is installed.
# Ensures that the right Drupal version is installed.
#
function drupal_ti_ensure_drupal_installed() {
drupal_ti_ensure_drupal
function drupal_ti_ensure_drupal() {
# This function is re-entrant.
drupal_ti_ensure_drupal_download

# @todo Maybe use a different check for Drupal installed.
if [ -r "$TRAVIS_BUILD_DIR/../drupal_ti-drupal-installed" ]
then
return
fi

# Create database and install Drupal.
mysql -e "create database $DRUPAL_TI_DB"

cd drupal
cd "$DRUPAL_TI_DRUPAL_DIR"
drupal_ti_install_drupal
touch "$TRAVIS_BUILD_DIR/../drupal_ti-drupal-installed"
}

#
Expand Down Expand Up @@ -91,15 +99,9 @@ function drupal_ti_run_server() {

# Use hhvm_serve for PHP 5.3 fcgi and hhvm fcgi
PHP_VERSION=$(phpenv version-name)
if [ "$PHP_VERSION" = "5.3" -o "$PHP_VERSION" = "hhvm" ]
then
export GOPATH="$DRUPAL_TI_DIST_DIR/go"
export DRUPAL_TI_WEBSERVER_HOST=$(echo "$DRUPAL_TI_WEBSERVER_URL" | sed 's,http://,,')
{ "$GOPATH/bin/hhvm-serve" -listen="$DRUPAL_TI_WEBSERVER_HOST:$DRUPAL_TI_WEBSERVER_PORT" 2>&1 | drupal_ti_log_output "webserver" ; } &
else
# start a web server on port 8080, run in the background; wait for initialization
{ drush runserver "$DRUPAL_TI_WEBSERVER_URL:$DRUPAL_TI_WEBSERVER_PORT" 2>&1 | drupal_ti_log_output "webserver" ; } &
fi
export DRUPAL_TI_WEBSERVER_HOST=$(echo "$DRUPAL_TI_WEBSERVER_URL" | sed 's,http://,,')
export GOPATH="$DRUPAL_TI_DIST_DIR/go"
{ "$GOPATH/bin/hhvm-serve" -listen="$DRUPAL_TI_WEBSERVER_HOST:$DRUPAL_TI_WEBSERVER_PORT" 2>&1 | drupal_ti_log_output "webserver" ; } &

# Wait until drush server has been started.
drupal_ti_wait_for_service_port "$DRUPAL_TI_WEBSERVER_PORT"
Expand Down Expand Up @@ -188,6 +190,8 @@ function drupal_ti_ensure_php_for_drush_webserver() {
return
fi

drupal_ti_ensure_hhvm_serve

# install php packages required for running a web server from drush on php 5.3
PHP_VERSION=$(phpenv version-name)
if [ "$PHP_VERSION" != "5.3" -a "$PHP_VERSION" != "hhvm" ]
Expand All @@ -201,7 +205,6 @@ function drupal_ti_ensure_php_for_drush_webserver() {
drupal_ti_ensure_php_fpm
fi

drupal_ti_ensure_hhvm_serve
touch "$TRAVIS_BUILD_DIR/../drupal_ti-php-for-webserver-installed"
}

Expand Down
2 changes: 1 addition & 1 deletion runners/behat/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -e $DRUPAL_TI_DEBUG

# Ensure the right Drupal version is installed.
drupal_ti_ensure_drupal_installed
drupal_ti_ensure_drupal

# Ensure the module is linked into the code base and enabled.
drupal_ti_ensure_module
Expand Down
5 changes: 1 addition & 4 deletions runners/phpunit-core/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
set -e $DRUPAL_TI_DEBUG

# Ensure the right Drupal version is downloaded.
drupal_ti_ensure_drupal

# Change directory to Drupal core directory.
cd drupal
drupal_ti_ensure_drupal_download

# Ensure the module is linked into the code base.
drupal_ti_ensure_module_linked
Expand Down
2 changes: 1 addition & 1 deletion runners/simpletest/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -e $DRUPAL_TI_DEBUG

# Ensure the right Drupal version is installed.
drupal_ti_ensure_drupal_installed
drupal_ti_ensure_drupal

# Enable simpletest module.
cd "$DRUPAL_TI_DRUPAL_DIR"
Expand Down

0 comments on commit ea1f601

Please sign in to comment.