Skip to content

Instantly share code, notes, and snippets.

@mikedfunk
Created March 23, 2016 19:37
Show Gist options
  • Save mikedfunk/41a15f862560f785813d to your computer and use it in GitHub Desktop.
Save mikedfunk/41a15f862560f785813d to your computer and use it in GitHub Desktop.
<project name="saatchiart" default="check" basedir=".">
<target name="clean" description="Clean up and create artifact directories">
<delete dir="${project.basedir}/build"/>
<mkdir dir="${project.basedir}/build/coverage"/>
<mkdir dir="${project.basedir}/build/logs"/>
<mkdir dir="${project.basedir}/build/code-browser"/>
<mkdir dir="${project.basedir}/build/pdepend"/>
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
<!-- <exec logoutput="true" command="find -L src -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l | grep '^.+(?!no syntax errors).+'" /> -->
<exec logoutput="true" command="find . -type f -name '*.php' ! -path './vendor/*' ! -path './tests/*' -print0 | xargs -0 -n 1 -P 4 php -l | grep '^.+(?!no syntax errors).+'" />
</target>
<target name="fix">
<exec logoutput="true" command="php-cs-fixer fix src --level=psr2 --fixers=-phpdoc_params,-psr0,-single_blank_line_before_namespace,-phpdoc_short_description,-concat_without_spaces,concat_with_spaces,-no_blank_lines_after_class_opening,-spaces_cast --verbose" />
<!-- <exec logoutput="true" command="phpcbf ${packages}" /> -->
</target>
<target name="fixdryrun" description="php-cs-fixer fix dry run">
<!-- disable the config-file=.php_cs for now, I can't get it to ignore files or blacklist rules. -->
<exec logoutput="true"
command="php-cs-fixer fix src --level=psr2 --fixers=-phpdoc_params,-psr0,-single_blank_line_before_namespace,-phpdoc_short_description,-concat_without_spaces,concat_with_spaces,-no_blank_lines_after_class_opening,-spaces_cast,-parenthesis --dry-run --verbose" />
</target>
<target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend">
<exec logoutput="true"
command="pdepend --jdepend-xml=${project.basedir}/build/logs/jdepend.xml --jdepend-chart=${project.basedir}/build/pdepend/dependencies.svg --overview-pyramid=${project.basedir}/build/pdepend/overview-pyramid.svg src" />
</target>
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD">
<exec logoutput="true"
command="phpcpd src" />
</target>
<target name="phpdoc">
<exec logoutput="true" command="phpdoc -d src -t build/phpdoc --template=clean --force" />
</target>
<target name="phpdoccheckstyle">
<exec logoutput="true" command="phpdoc -d src -t ${project.basedir}/build/phpdoc --template=checkstyle --force | grep -B 1 '^\ '" />
</target>
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer">
<exec logoutput="true"
command="phpcs -v --report=checkstyle --report-file=${project.basedir}/build/logs/checkstyle.xml --standard=PSR2 src" />
</target>
<target name="phpcscheck" description="view phpcs errors">
<exec logoutput="true"
command="phpcs src" />
</target>
<target name="phploc" description="Generate phploc.csv">
<exec logoutput="true"
command="phploc --count-tests --log-csv ${project.basedir}/build/logs/phploc.csv src" />
</target>
<target name="phpmd" description="Generate pmd.xml using PHPMD">
<exec logoutput="true" spawn="true"
command="phpmd src xml phpmd.xml --reportfile ${project.basedir}/build/logs/pmd.xml" />
</target>
<target name="phpunit" description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">
<exec logoutput="true" checkreturn="true" command="php -d memory_limit=1024M vendor/bin/phpunit --configuration=phpunit.xml --log-junit=build/logs/junit.xml --coverage-clover=build/logs/clover.xml" />
</target>
<target name="check" depends="phpcpd,phpcscheck,phpdoccheckstyle,fixdryrun,lint" description="check phpcs standards and phpdoc errors, show the output" />
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment