From efa73fa82a759d66b5af989d66cfbf8fd31003e5 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 25 May 2016 09:24:39 -0400 Subject: [PATCH] Use Composer to load utilities; use Phing for more Travis tasks. (#704) --- .travis.yml | 8 +------- build.xml | 28 +++++++++++++++++----------- composer.json | 8 +++++++- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae9feffa935..5d8289ce74a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,17 +10,11 @@ env: - VUFIND_HOME=$PWD VUFIND_LOCAL_DIR=$PWD/local before_script: - - pear install pear/PHP_CodeSniffer - pear install pear/Http_Request2 - pear channel-discover pear.phing.info - pear install phing/phing - - composer global require fabpot/php-cs-fixer - - export PATH="$HOME/.composer/vendor/bin:$PATH" - phpenv config-rm xdebug.ini - phpenv rehash script: - - phing composer - - phpunit --stderr --configuration module/VuFind/tests/phpunit.xml - - phpcs --standard=PEAR --ignore=*/config/*,*/tests/* --extensions=php $PWD/module - - phing php-cs-fixer-dryrun + - phing composer phpunitfast phpcs-console php-cs-fixer-dryrun diff --git a/build.xml b/build.xml index 95842ffa374..54a0195ae72 100644 --- a/build.xml +++ b/build.xml @@ -21,6 +21,7 @@ <property name="pgsqlhost" value="localhost" /> <property name="pgsqlrootuser" value="postgres" /> <property name="phpunit_extra_params" value="" /> + <property name="composer_extra_params" value="" /> <property name="mink_driver" value="zombiejs" /><!-- may also be set to selenium --> <property name="snooze_multiplier" value="1" /><!-- can be used to slow down tests (selenium only) --> <property name="php-cs-fixers" value="no_blank_lines_before_namespaces,function_call_space,trailing_spaces,unused_use,lowercase_keywords,encoding,parenthesis,php_closing_tag,visibility,duplicate_semicolon,extra_empty_lines,no_blank_lines_after_class_opening,no_empty_lines_after_phpdocs,operators_spaces,spaces_before_semicolon,ternary_spaces,concat_with_spaces,short_array_syntax,phpdoc_no_access,remove_leading_slash_use,eof_ending" /> @@ -68,35 +69,38 @@ <!-- Report rule violations with PHPMD (mess detector) --> <target name="phpmd"> - <exec command="phpmd ${srcdir}/module xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/module/VuFind/tests,${srcdir}/module/VuDL/tests,${srcdir}/module/VuFindSearch/tests --reportfile ${builddir}/reports/phpmd.xml" /> + <exec command="${srcdir}/vendor/bin/phpmd ${srcdir}/module xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/module/VuFind/tests,${srcdir}/module/VuDL/tests,${srcdir}/module/VuFindSearch/tests --reportfile ${builddir}/reports/phpmd.xml" /> </target> <!-- Measure project with phploc --> <target name="phploc"> - <exec command="phploc --log-csv ${builddir}/reports/phploc.csv ${srcdir}/module" /> + <exec command="${srcdir}/vendor/bin/phploc --log-csv ${builddir}/reports/phploc.csv ${srcdir}/module" /> </target> <!-- PHP_Depend code analysis --> <target name="pdepend"> - <exec command="pdepend --jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/module" /> + <exec command="${srcdir}/vendor/bin/pdepend --jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/module" /> </target> <!-- PHP copy-and-paste detection --> <target name="phpcpd"> - <exec command="phpcpd --log-pmd ${builddir}/reports/pmd-cpd.xml --exclude tests ${srcdir}/module" /> + <exec command="${srcdir}/vendor/bin/phpcpd --log-pmd ${builddir}/reports/pmd-cpd.xml --exclude tests ${srcdir}/module" /> </target> <!-- PHP CodeSniffer --> <target name="phpcs"> - <exec command="phpcs --standard=PEAR --ignore=*/config/*,*/tests/* --extensions=php --report=checkstyle ${srcdir}/module > ${builddir}/reports/checkstyle.xml" escape="false" /> + <exec command="${srcdir}/vendor/bin/phpcs --standard=PEAR --ignore=*/config/*,*/tests/* --extensions=php --report=checkstyle ${srcdir}/module > ${builddir}/reports/checkstyle.xml" escape="false" /> + </target> + <target name="phpcs-console"> + <exec command="${srcdir}/vendor/bin/phpcs --standard=PEAR --ignore=*/config/*,*/tests/* --extensions=php ${srcdir}/module" escape="false" passthru="true" checkreturn="true" /> </target> <!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) --> <target name="php-cs-fixer"> - <exec command="php-cs-fixer fix ${srcdir}/module --fixers=${php-cs-fixers} --verbose" passthru="true" escape="false" /> + <exec command="${srcdir}/vendor/bin/php-cs-fixer fix ${srcdir}/module --fixers=${php-cs-fixers} --verbose" passthru="true" escape="false" /> </target> <target name="php-cs-fixer-dryrun"> - <exec command="php-cs-fixer fix ${srcdir}/module --fixers=${php-cs-fixers} --dry-run --verbose --diff" passthru="true" escape="false" checkreturn="true" /> + <exec command="${srcdir}/vendor/bin/php-cs-fixer fix ${srcdir}/module --fixers=${php-cs-fixers} --dry-run --verbose --diff" passthru="true" escape="false" checkreturn="true" /> </target> <!-- PHP API Documentation --> @@ -112,18 +116,18 @@ <!-- PHPUnit --> <target name="phpunit" description="Run tests"> - <exec dir="${srcdir}/module/VuFind/tests" command="NODE_PATH=${nodepath} VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${phpunit_extra_params}" passthru="true" checkreturn="true" /> + <exec dir="${srcdir}/module/VuFind/tests" command="NODE_PATH=${nodepath} VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${phpunit_extra_params}" passthru="true" checkreturn="true" /> </target> <!-- PHPUnit without logging output --> <target name="phpunitfast" description="Run tests"> - <exec dir="${srcdir}/module/VuFind/tests" command="NODE_PATH=${nodepath} VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} phpunit -dzend.enable_gc=0 ${phpunit_extra_params}" passthru="true" checkreturn="true" /> + <exec dir="${srcdir}/module/VuFind/tests" command="NODE_PATH=${nodepath} VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 ${phpunit_extra_params}" passthru="true" checkreturn="true" /> </target> <target name="composer" description="Install dependencies with Composer"> <httpget url="https://getcomposer.org/composer.phar" sslVerifyPeer="false" dir="${srcdir}" /> <echo message="Installing dependencies..." /> - <exec command="php ${srcdir}/composer.phar install" passthru="true" checkreturn="true" /> + <exec command="php ${srcdir}/composer.phar install ${composer_extra_params}" passthru="true" checkreturn="true" /> </target> <!-- Install and Activate VuFind --> @@ -272,7 +276,9 @@ <mkdir dir="${builddir}/export/vufind/usr/local/vufind" /> <!-- load the relevant files into the work area --> - <phingcall target="composer" /> + <phingcall target="composer"> + <property name="composer_extra_params" value="--no-dev" /> + </phingcall> <exec command="git archive HEAD --format=tar | tar -x -C ${builddir}/export/vufind/usr/local/vufind" /> <copy todir = "${builddir}/export/vufind/usr/local/vufind/vendor"> <fileset dir="${srcdir}/vendor" defaultexcludes="false" /> diff --git a/composer.json b/composer.json index 2ea9a8c8325..24187076880 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,12 @@ "require-dev": { "behat/mink": "1.7.0", "behat/mink-selenium2-driver": "1.3.0", - "behat/mink-zombie-driver": "1.3.0" + "behat/mink-zombie-driver": "1.3.0", + "fabpot/php-cs-fixer": "1.11.2", + "phploc/phploc": "2.0.6", + "phpmd/phpmd": "1.5.0", + "phpunit/phpunit": "4.8.4", + "sebastian/phpcpd": "1.4.3", + "squizlabs/php_codesniffer": "2.6.0" } } -- GitLab