Skip to content

Commit

Permalink
Updated composer.json and build.xml to phing3 standards
Browse files Browse the repository at this point in the history
  • Loading branch information
sturkel89 committed Jul 10, 2024
1 parent e500207 commit 6379b6f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
57 changes: 43 additions & 14 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="vufindcode" basedir="." default="main">
<property name="sh" value="/bin/sh" />
<property name="tmp" value="/tmp" />
<property name="package" value="${phing.project.name}" override="true" />
<property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" />
<property name="srcdir" value="${project.basedir}" override="true" />
<property name="downloadsdir" value="${srcdir}/downloads" override="true" />
<property name="skip_phpdoc" value="false" />
<property name="phpdoc_version" value="3.3.1" />
<property name="phpunit_command" value="${srcdir}/vendor/bin/phpunit" />
Expand Down Expand Up @@ -41,39 +43,57 @@

<!-- Report rule violations with PHPMD (mess detector) -->
<target name="phpmd">
<exec command="${srcdir}/vendor/bin/phpmd ${srcdir}/src xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/tests --reportfile ${builddir}/reports/phpmd.xml" />
<exec executable="${srcdir}/vendor/bin/phpmd">
<arg line="${srcdir}/src xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/tests --reportfile ${builddir}/reports/phpmd.xml" />
</exec>
</target>

<!-- PHP_Depend code analysis -->
<target name="pdepend">
<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}/src" />
<exec executable="${srcdir}/vendor/bin/pdepend">
<arg line="--jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/src" />
</exec>
</target>

<!-- PHP CodeSniffer -->
<target name="phpcbf">
<exec command="${srcdir}/vendor/bin/phpcbf --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
<exec executable="${srcdir}/vendor/bin/phpcbf" escape="false" passthru="true" checkreturn="true">
<arg line="--standard=${srcdir}/tests/phpcs.xml" />
</exec>
</target>
<target name="phpcs">
<exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml --report=checkstyle &gt; ${builddir}/reports/checkstyle.xml" escape="false" />
<exec executable="${srcdir}/vendor/bin/phpcs" escape="false">
<arg line="--standard=${srcdir}/tests/phpcs.xml --report=checkstyle &gt; ${builddir}/reports/checkstyle.xml" />
</exec>
</target>
<target name="phpcs-console">
<exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
<exec executable="${srcdir}/vendor/bin/phpcs" escape="false" passthru="true" checkreturn="true">
<arg line="--standard=${srcdir}/tests/phpcs.xml" />
</exec>
</target>

<!-- Phpstan -->
<target name="phpstan-checkstyle">
<exec command="${srcdir}/vendor/bin/phpstan --configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G --error-format=checkstyle analyse &gt; ${builddir}/reports/phpstan-checkstyle.xml" escape="false" passthru="true" checkreturn="true" />
<exec executable="${srcdir}/vendor/bin/phpstan" escape="false" passthru="true" checkreturn="true">
<arg line="--configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G --error-format=checkstyle analyse &gt; ${builddir}/reports/phpstan-checkstyle.xml" />
</exec>
</target>
<target name="phpstan-console">
<exec command="${srcdir}/vendor/bin/phpstan --configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G analyse" escape="false" passthru="true" checkreturn="true" />
<exec executable="${srcdir}/vendor/bin/phpstan" escape="false" passthru="true" checkreturn="true">
<arg line="--configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G analyse" />
</exec>
</target>

<!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
<target name="php-cs-fixer">
<exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --verbose" passthru="true" escape="false" />
<exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false">
<arg line="fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --verbose" />
</exec>
</target>
<target name="php-cs-fixer-dryrun">
<exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --dry-run --verbose --diff" passthru="true" escape="false" checkreturn="true" />
<exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false" checkreturn="true">
<arg line="fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --dry-run --verbose --diff" />
</exec>
</target>

<!-- PHP API Documentation -->
Expand Down Expand Up @@ -106,30 +126,39 @@
</fileset>
</phpdoc2>
-->
<exec command="php ${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar --cache-folder=${builddir}/docs_cache --title=&quot;VuFindCode API Documentation&quot; -t ${builddir}/apidocs -d ${srcdir}/src" passthru="true" />
<exec executable="php" passthru="true">
<arg line="${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar --cache-folder=${builddir}/docs_cache --title=&quot;VuFindCode API Documentation&quot; -t ${builddir}/apidocs -d ${srcdir}/src" />
</exec>
</then>
</if>
</target>

<!-- PHPUnit -->
<target name="phpunit" description="Run tests">
<exec dir="${srcdir}/tests" command="${phpunit_command} -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/" passthru="true" checkreturn="true" />
<exec dir="${srcdir}/tests" executable="${sh}" passthru="true" checkreturn="true">
<arg line="-c &apos;${phpunit_command} -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/&apos;" />
</exec>
</target>

<!-- PHPUnit without logging output -->
<target name="phpunitfast" description="Run tests">
<exec dir="${srcdir}/tests" command="${phpunit_command} -dzend.enable_gc=0" passthru="true" checkreturn="true" />
<exec dir="${srcdir}/tests" executable="${sh}" passthru="true" checkreturn="true">
<arg line="-c &apos;${phpunit_command} -dzend.enable_gc=0&apos;" />
</target>

<!-- Set up dependencies -->
<target name="startup" description="set up dependencies">
<exec command="composer install" />
<exec executable="composer">
<arg line="install" />
</exec>
</target>

<!-- Clean up -->
<target name="shutdown" description="clean up file system">
<delete dir="${srcdir}/vendor" includeemptydirs="true" failonerror="true" />
<delete file="${srcdir}/composer.lock" failonerror="true" />
<exec command="git reset --hard" />
<exec executable="git">
<arg line="reset --hard" />
</exec>
</target>
</project>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.51.0",
"guzzlehttp/guzzle": "^7.8.1",
"pear/http_request2": "2.6.0",
"phpmd/phpmd": "2.15.0",
"phpstan/phpstan": "1.10.59",
"phpunit/phpunit": "10.5.11",
"phing/phing": "2.17.4",
"phing/phing": "3.0",
"squizlabs/php_codesniffer": "3.9.0"
}
}

0 comments on commit 6379b6f

Please sign in to comment.