testing: Move vendor installation to script

And all downloaded data to `vendor/`
This commit is contained in:
Markus Frosch 2017-08-30 09:35:47 +02:00 committed by Thomas Gelf
parent 727cc22bc4
commit bd5f9d7dea
4 changed files with 74 additions and 11 deletions

3
.gitignore vendored
View File

@ -2,6 +2,5 @@
/.idea/
.*.sw[op]
## PHP / composer
## PHP vendor artifacts
/vendor/
composer.lock

View File

@ -26,15 +26,9 @@ env:
DIRECTOR_TESTDB_USER="director_test"
before_script:
# TODO: Re-enable after dropping 5.3 support:
# - curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
- curl -OL https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.9.1/phpcs.phar
- wget https://github.com/Icinga/icingaweb2/archive/v2.4.0.tar.gz
- tar xfz v2.4.0.tar.gz
- ln -s icingaweb2-2.4.0/library/Icinga
- ln -s icingaweb2-2.4.0/library/vendor/Zend
- ./test/setup_vendor.sh
- ./test/travis-prepare.sh
script:
- php phpcs.phar --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Director/ library/vendor/ipl/ application/ *.php test
- phpunit --testdox || phpunit --verbose
- php vendor/phpcs.phar --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Director/ library/vendor/ipl/ application/ *.php test
- php vendor/phpunit.phar --testdox || phpunit --verbose

View File

@ -7,6 +7,10 @@ call_user_func(function () {
if (! class_exists('PHPUnit_Framework_TestCase')) {
require_once __DIR__ . '/phpunit-compat.php';
}
$include_path = $basedir . '/vendor' . PATH_SEPARATOR . ini_get('include_path');
ini_set('include_path', $include_path);
require_once $basedir . '/library/Director/Test/Bootstrap.php';
Bootstrap::cli($basedir);
});

66
test/setup_vendor.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash
set -ex
MODULE_HOME=${MODULE_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"}
PHP_VERSION="$(php -r 'echo phpversion();')"
ICINGAWEB_VERSION=${ICINGAWEB_VERSION:=2.4.1}
ICINGAWEB_GITREF=${ICINGAWEB_GITREF:=}
PHPCS_VERSION=${PHPCS_VERSION:=2.9.1}
if [ "$PHP_VERSION" '<' 5.6.0 ]; then
PHPUNIT_VERSION=${PHPUNIT_VERSION:=4.8}
else
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}
fi
cd ${MODULE_HOME}
test -d vendor || mkdir vendor
cd vendor/
# icingaweb2
if [ -n "$ICINGAWEB_GITREF" ]; then
icingaweb_path="icingaweb2"
test ! -L "$icingaweb_path" || rm "$icingaweb_path"
if [ ! -d "$icingaweb_path" ]; then
git clone https://github.com/Icinga/icingaweb2.git "$icingaweb_path"
fi
(
set -e
cd "$icingaweb_path"
git fetch -p
git checkout -f "$ICINGAWEB_GITREF"
)
else
icingaweb_path="icingaweb2-${ICINGAWEB_VERSION}"
if [ ! -e "${icingaweb_path}".tar.gz ]; then
wget -O "${icingaweb_path}".tar.gz https://github.com/Icinga/icingaweb2/archive/v"${ICINGAWEB_VERSION}".tar.gz
fi
if [ ! -d "${icingaweb_path}" ]; then
tar xf "${icingaweb_path}".tar.gz
fi
ln -svf "${icingaweb_path}" icingaweb2
fi
ln -svf "${icingaweb_path}"/library/Icinga
ln -svf "${icingaweb_path}"/library/vendor/Zend
# phpunit
phpunit_path="phpunit-${PHPUNIT_VERSION}"
if [ ! -e "${phpunit_path}".phar ]; then
wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
fi
ln -svf "${phpunit_path}".phar phpunit.phar
# phpcs
phpcs_path="phpcs-${PHPCS_VERSION}"
if [ ! -e "${phpcs_path}".phar ]; then
wget -O "${phpcs_path}".phar \
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar
fi
ln -svf "${phpcs_path}".phar phpcs.phar