Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apache Ant build.xml file for PHPUnit+Jenkins+Ant+Symfony2
<?xml version="1.0" encoding="UTF-8"?>
<!-- Set some basic project information and targets -->
<project name="My Symfony2 Project" default="build">
<target name="build"
depends="prepare, vendors, dbupdate, fixtures, lint, phploc, phpmd, phpcpd, phpcs, phpunit"/>
<target name="build-parallel"
depends="prepare, vendors, dbupdate, fixtures, lint, tools-parallel, phpcpd, phpunit"/>
<property environment="env"/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="phpmd"/>
</sequential>
<antcall target="phpcpd"/>
<antcall target="phpcs"/>
<antcall target="phploc"/>
<antcall target="phpdox"/>
</parallel>
</target>
<!-- Clean up from previous builds -->
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/api"/>
</target>
<!-- Prepare for the new build -->
<target name="prepare" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/api"/>
</target>
<!-- Add vendors or code will fail -->
<target name="vendors" depends="clean" description="Add Vendors">
<exec executable="php" failonerror="true">
<arg value='/usr/local/bin/composer/composer.phar' />
<arg value='install' />
</exec>
</target>
<!-- Run any DB schema updates -->
<target name="dbupdate" depends="clean" description="Update Schema">
<exec executable="php" failonerror="true">
<arg value='app/console' />
<arg value="doctrine:schema:update" />
<arg value='-n' />
</exec>
</target>
<!-- Update fixtures-->
<target name="fixtures" depends="clean" description="Update fixtures">
<exec executable="php" failonerror="true">
<arg value='app/console' />
<arg value="doctrine:fixtures:load" />
<arg value='-n' />
</exec>
</target>
<!-- Lint the PHP files in app dir. Linting the whole framework library takes forever -->
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/app">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<!-- PHPLoc (Lines Of Code) report -->
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${basedir}/app" />
</exec>
</target>
<!-- PHP Mess Detector -->
<target name="phpmd" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${basedir}/app" />
<arg value="xml" />
<arg value="codesize,unusedcode,naming" />
<arg value="--reportfile" />
<arg value="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<!-- PHP Copy Paste Detector -->
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/app" />
</exec>
</target>
<!-- PHP Code Sniffer - tokenises PHP, JS and CSS files and detects violations of defined coding standards -->
<target name="phpcs" description="Check code with PHP Code Sniffer">
<exec executable="phpcs">
<arg value="-n" />
<arg value="--extensions=php" />
<arg value="--error-severity=1" />
<arg path="${basedir}/app" />
</exec>
</target>
<!-- Kick off phpunit -->
<target name="phpunit">
<exec dir="${basedir}/app" executable="/usr/bin/phpunit364" failonerror="true" description="Run unit app with PHPUnit 3.6.4">
<arg line="--verbose" />
</exec>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.