LionsAd / drupal_ti

Drupal - Travis Integration
82 stars 37 forks source link

path to drush.php is hardcoded, so drupal_ti doesn't respect COMPOSER_BIN_DIR #66

Open kenorb opened 8 years ago

kenorb commented 8 years ago

In drupal-7.sh and drupal-8.sh there is a command which run drush in the following way:

~/.composer/vendor/bin/drush.php

so I've the following error:

php -d sendmail_path=/bin/true /home/travis/.composer/vendor/bin/drush.php --yes site-install testing --db-url=mysql://root:@127.0.0.1/drupal Could not open input file: /home/travis/.composer/vendor/bin/drush.php

Since I'd like to have my drush available globally as I'm using drupal_ti on top of my other CI tests, I've specified the following environment variable: COMPOSER_BIN_DIR=~/bin which automatically link drush binary into ~/bin which is available by default in Travis CI by just running drush (so I don't need to modify my PATH). This way is also described in drush docs.

So I wondering if there is a better way of running drush. It seems this syntax is only used in order to handle mails (php -d sendmail_path=$(which true)).

In my .travis.yml, my approach is a bit different (by installing mailcatcher, so there can be some tests related to received e-mails):

 - gem install mailcatcher && mailcatcher -v
 - echo 'sendmail_path="/usr/bin/env catchmail"' | tee -a "$(php --ini | grep "Loaded Configuration" | awk '{print $4}')"

In this case, we can install site in normal way, which is: drush --yes site-install, so we're not depending on any hardcoded paths and mails are handled by catchmail.

LionsAd commented 8 years ago

I think I could just check for COMPOSER_BIN_DIR instead?

Then it would continue to work. This is mainly for the installation, so not affecting other parts.

kenorb commented 8 years ago

I think so, in case when COMPOSER_BIN_DIR is defined, running without sudo ~/bin value could be more preferred, with sudo, the /usr/local/bin work better in this case, so it's better to have some more flexible way of finding drush.

Or the same way as drush finding its php file:

SCRIPT_PATH="`dirname "$SELF_PATH"`/drush.php"

in drush (see: vim $(which drush)).

So it can be:

php -d sendmail_path=/bin/true "$(dirname "$(which drush)")"/drush.php ...
LionsAd commented 8 years ago

As drupal_ti takes care of installing drush and there is no harm in doing so, I think checking COMPOSER_BIN_DIR is enough. It is an edge-case anyway - as hhvm has trouble with the php.ini.

LionsAd commented 8 years ago

The problem with using:

which drush and dirname is that it can be a symlink and then the logic starts to get complicated.