Skip to content

Commit

Permalink
Add Phing build tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
dankempster committed Jan 31, 2015
1 parent bfcb6ec commit f3eaf7b
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -3,9 +3,13 @@ phpunit.xml
composer.lock

# Build Artifacts
phpunit.xml
phpunit.phing.xml
cache.properties
build/
!build/php*.xml
!build/resources/*.xslt

bin

.idea/workspace.xml
.idea/dataSources.xml
Expand Down
3 changes: 1 addition & 2 deletions .idea/axstrad-content.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/phing.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/webResources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions build.properties
@@ -0,0 +1,58 @@
version=0.0.0
commit="none"
name=${phing.project.name}
summary="Summary"
author.name="Dan Kempster"
author.email="dev@dankempster.co.uk"
author.username="dankempster"
description="Description last commit ${commit}"

global.vendor.bin=/Users/dan/.composer/vendor/bin
global.bin=/usr/bin

exec.php=${global.bin}/php
exec.phing=${global.vendor.bin}/phing
exec.phpdepend=${global.vendor.bin}/pdepend
exec.phpcs=${global.vendor.bin}/phpcs
exec.phpunit=${project.bin}/phpunit
exec.phpmd=${global.vendor.bin}/phpmd
exec.phpcpd=${global.vendor.bin}/phpcpd
exec.phpdoc=${global.vendor.bin}/phpdoc
exec.phpdox=${global.bin}/phpdox
exec.phploc=${global.vendor.bin}/phploc

project.src=${project.basedir}/src
project.tests=${project.basedir}/tests
project.vendor=${project.basedir}/src
project.bin=${project.basedir}/bin
project.docs=${project.basedir}/docs
project.docs.api=${project.docs}/api

build.root=${project.basedir}/build
build.cache=${build.root}/cache
build.tmp=${build.root}/tmp
build.log=${build.root}/log
build.html=${build.root}/html
build.config=${build.root}/config
build.resources=${build.root}/resources

phpdepend.xml.file=${build.log}/phpdepend.xml
phpdepend.html=${build.html}
phpdepend.ignore=.git,tests/,build/

phpcs.xml.file=${build.log}/phpcs.xml
phpcs.html=${build.html}/phpcs

phpunit.html=${build.html}/phpunit
phpunit.config=${project.basedir}/phpunit.xml.dist
phpunit.phing.config=${project.basedir}/phpunit.phing.xml

phpmd.config=${build.config}/phpmd.xml
phpmd.report.html=${build.html}/pmd.html
phpmd.report.text=${build.html}/pmd.txt
phpmd.report.xml=${build.log}/pmd.xml

phpcpd.log.file=${build.log}/phpcpd.xml
phpcpd.html=${build.html}/phpcpd

phploc.log.file=${build.log}/phploc.xml
156 changes: 156 additions & 0 deletions build.xml
@@ -0,0 +1,156 @@
<project name="Axstrad/Content" default="all" basedir=".">
<property file="./build.properties"/>

<target name="prepare" depends="clean">
<mkdir dir="${build.tmp}"/>
<mkdir dir="${build.log}"/>
<mkdir dir="${build.cache}"/> <!-- Should NOT be part of 'clean' target -->
<mkdir dir="${build.html}"/>
</target>

<target name="clean">
<delete dir="${build.tmp}"/>
<delete dir="${build.log}"/>
<delete dir="${build.html}"/>
</target>

<target name="phpdepend-human"
description="Calculate software metrics using PHP_Depend and log result in XML format."
>
<mkdir dir="${build.html}"/>
<exec
command="${exec.phpdepend} --jdepend-chart=${build.html}/pdepend.svg --ignore=${phpdepend.ignore} --overview-pyramid=${build.html}/pyramid.svg ${project.src}"
dir="${project.src}"
passthru="true"
/>
</target>

<target name="phpdepend-ci"
depends="phpdepend-human"
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment."
>
<exec
command="${exec.phpdepend} --jdepend-xml=${phpdepend.xml.file} --ignore=${phpdepend.ignore} ${project.src}"
dir="${project.src}"
passthru="true"
/>
</target>

<target name="phpcs">
<mkdir dir="${phpcs.html}"/>
<exec
command="${exec.phpcs} --report=checkstyle --report-file=${phpcs.xml.file} --standard=PEAR --extensions=php --ignore=.git/,doc/,resources/,build ${project.src}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpunit"
description="Runs the project's PHPUnit tests. Intended for use in a Continuous Integration environment."
>
<mkdir dir="${phpunit.html}"/>
<xslt
file="${phpunit.config}"
tofile="${phpunit.phing.config}"
style="${build.resources}/phpunit-phing.xslt"
/>
<exec
command="${exec.phpunit} -c ${phpunit.phing.config}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpmd"
description="Intended for use by the command line before committing."
>
<exec
command="${exec.phpmd} ${project.src} text ${phpmd.config}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpmd-report"
description="Runs PHPMD against the project and outputs HTML and XML reports. Intended for internal use."
depends="phpmd-html,phpmd-xml"
/>

<target name="phpmd-html"
>
<exec
command="${exec.phpmd} ${project.src} html ${phpmd.config} --reportfile ${phpmd.report.html} --suffixes=php"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpmd-xml"
description="Runs PHPMD against the project and outputs HTML and XML reports. Intended for by a Continuous Integration environment."
>
<exec
command="${exec.phpmd} ${project.src} xml ${phpmd.config} --reportfile ${phpmd.report.xml} --suffixes=php"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpcpd"
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing."
>
<exec
command="${exec.phpcpd} --verbose ${project.src}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpcpd-ci"
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment."
>
<exec
command="${exec.phpcpd} --log-pmd ${phpcpd.log.file} --verbose ${project.src}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phploc"
description="Measure project size using PHPLOC and print human readable output. Intended for usage from the command line before committing."
>
<exec
command="${exec.phploc} ${project.src} ${project.tests}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phploc-ci"
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment."
>
<exec
command="${exec.phploc} --count-tests --log-xml ${phploc.log.file} ${project.src} ${project.tests} > ${build.html}/phploc.txt"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="phpdox" depends="phpunit,phploc-ci,phpcs,phpmd-xml">
<exec
command="${exec.phpdox}"
dir="${project.basedir}"
passthru="true"
/>
</target>

<target name="all" depends="clean, build, report, ci-tasks"/>

<!-- Intedned for use by humans -->
<target name="build" depends="prepare, test"/>
<target name="test" depends="prepare, phpunit"/>
<target name="report" depends="build, phploc, phpdepend-human, phpcs, phpmd-html, phpcpd, phpdox"/>

<!-- Intended for use by Continuous Integration environments -->
<target name="ci" depends="clean, ci-tasks"/>
<target name="ci-tasks" depends="test, phploc-ci, phpdepend-ci, phpcs, phpmd-xml, phpcpd-ci, phpdox"/>
</project>
26 changes: 26 additions & 0 deletions build/resources/phpunit-phing.xslt
@@ -0,0 +1,26 @@
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="phpunit">
<phpunit>
<xsl:copy-of select="testsuites" />

<logging>
<!-- Apply other templates to the logging/log nodes (including the commented out ones) -->
<xsl:apply-templates select="logging/node()"/>
</logging>

<xsl:copy-of select="filter" />
</phpunit>
</xsl:template>

<!-- Matches the commented out <log type="coverage-xml"> line and outputs it -->
<xsl:template match="comment()[contains(., 'coverage-xml') or contains(., 'coverage-html')]">
<xsl:value-of select="." disable-output-escaping="yes"/> <!-- uncomments the log line -->
</xsl:template>

<!-- Matches all uncomments <log /> elements and outputs them -->
<!--<xsl:template match="log">
<xsl:copy-of select="." />
</xsl:template>-->
</xsl:transform>
4 changes: 4 additions & 0 deletions composer.json
Expand Up @@ -34,6 +34,10 @@

"minimum-stability": "dev",

"config": {
"bin-dir": "bin"
},

"extra": {
"branch-alias": {
"dev-develop": "0.4.x-dev"
Expand Down
40 changes: 40 additions & 0 deletions phpdox.xml
@@ -0,0 +1,40 @@
<phpdox xmlns="http://phpdox.net/config">
<project name="axstrad/content" source="src" workdir="build/cache/phpdox">
<collector publiconly="false">
<include mask="*.php" />

<inheritance resolve="true">

</inheritance>
</collector>

<generator output="build/html">
<build engine="html" enabled="true" output="api">
<file extension="html" />
</build>

<enrich base="build/log">
<source type="phploc">
<file name="phploc.xml"></file>
</source>

<source type="git">
<git binary="/usr/bin/git" />
<history enabled="true" limit="15" cache="${phpDox.project.workdir}/gitlog.xml" />
</source>

<source type="phpunit">
<coverage path="phpunit-coverage"/>
</source>

<source type="phpcs">
<file name="phpcs.xml" />
</source>

<source type="pmd">
<file name="pmd.xml" />
</source>
</enrich>
</generator>
</project>
</phpdox>
11 changes: 11 additions & 0 deletions phpmd.xml
@@ -0,0 +1,11 @@
<ruleset name="name-of-your-coding-standard"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Description of your coding standard</description>

<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
<!-- ... -->
</ruleset>
11 changes: 6 additions & 5 deletions phpunit.xml.dist
Expand Up @@ -18,17 +18,18 @@
</testsuites>

<logging>
<!-- <log type="coverage-html"
target="build/coverage/phpunit"
<!--<log type="coverage-html"
target="build/html/phpunit"
title="Axstrad/Content"
charset="UTF-8"
yui="true"
highlight="true"
lowUpperBound="35"
highLowerBound="70"
/> -->
<!-- <log type="coverage-clover" target="build/logs/clover.phpunit.xml"/> -->
<!-- <log type="junit" target="build/logs/junit.phpunit.xml" logIncompleteSkipped="false"/> -->
/>-->
<!--<log type="coverage-xml" target="build/log/phpunit-coverage"/>-->
<log type="coverage-clover" target="build/log/clover.xml"/>
<!--<log type="junit" target="build/log/junit.xml" logIncompleteSkipped="false"/>-->
</logging>

<filter>
Expand Down

0 comments on commit f3eaf7b

Please sign in to comment.