Skip to content

Commit

Permalink
Upgrade Phing to version 3.0 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
sturkel89 authored Jul 9, 2024
1 parent 6a8283c commit ca10274
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
59 changes: 44 additions & 15 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="vufind-marc" 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="skip_phpdoc" value="false" />
<property name="phpdoc_version" value="3.3.1" />
<property name="phpunit_command" value="${srcdir}/vendor/bin/phpunit" /><!-- if you have issues with segfaults during code coverage generation, try adding -dzend.enable_gc=0 to this (but this fix was probably only needed in PHP 5) -->
<property name="phpunit_command" value="${srcdir}/vendor/bin/phpunit" />

<!-- Main Target -->
<target name="main" description="main target">
Expand Down Expand Up @@ -41,39 +42,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">
<arg line="--standard=${srcdir}/tests/phpcs.xml --report=checkstyle &gt; ${builddir}/reports/checkstyle.xml" escape="false" />
</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 All @@ -97,30 +116,40 @@
<then>
<mkdir dir="${builddir}/apidocs" />
<mkdir dir="${builddir}/docs_cache" />
<exec command="php ${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar --cache-folder=${builddir}/docs_cache --title=&quot;VuFind-Marc API Documentation&quot; -t ${builddir}/apidocs -d ${srcdir}/src" passthru="true" />
<exec executable="php ${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar" passthru="true">
<arg line="--cache-folder=${builddir}/docs_cache --title=&quot;VuFind-Marc 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} --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} --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}" passthru="true" checkreturn="true" />
<exec dir="${srcdir}/tests" executable="${sh}" passthru="true" checkreturn="true">
<arg line="-c &apos;${phpunit_command} &apos;" />
</exec>
</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 @@ -34,11 +34,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 ca10274

Please sign in to comment.