From bd5f9d7deaf48bf83c96f819cba4af0d3911e2c0 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Wed, 30 Aug 2017 09:35:47 +0200 Subject: [PATCH] testing: Move vendor installation to script And all downloaded data to `vendor/` --- .gitignore | 3 +- .travis.yml | 12 ++------ test/bootstrap.php | 4 +++ test/setup_vendor.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 11 deletions(-) create mode 100755 test/setup_vendor.sh diff --git a/.gitignore b/.gitignore index 99b4353c..35110729 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,5 @@ /.idea/ .*.sw[op] -## PHP / composer +## PHP vendor artifacts /vendor/ -composer.lock diff --git a/.travis.yml b/.travis.yml index fe609e25..f12836fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/test/bootstrap.php b/test/bootstrap.php index fa27e2e3..87ed8690 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -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); }); diff --git a/test/setup_vendor.sh b/test/setup_vendor.sh new file mode 100755 index 00000000..f2be6027 --- /dev/null +++ b/test/setup_vendor.sh @@ -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