Top Topic ?

PHP CodeBrowser and Hudson integration

Posted in qa by Ladislav Prskavec on December 10, 2009

I read about PHP_CodeBrowser and their html reports are nice.

How can add this reports to Hudson ?

Use HTML Publisher Plugin!

It’s easy, add to your build script new target phpcb in this style:

<target name="phpcb">
<exec executable="phpcb" dir="${basedir}/source">
<arg line="--log reports/logs/
--source source/
--output reports/phpcb/" />
</exec>
</target>

Don’t forget install HTML Publisher Plugin and make in job settings to directory with reports:

Reports are done:

Advertisements
Tagged with: , , ,

PHP and Hudson

Posted in php by Ladislav Prskavec on February 26, 2009

Hudson is extensible continuous integration engine used for Java projects. It’s architecture can be used for others languages as PHP too.

Install

  1. download war file
  2. run direct in console java -jar hudson.war (free port 8080 andJDK 1.5+)
  3. or make install to servlet server (Tomcat, Jetty, JBoss, …)
  4. after that go http://localhost:8080
  5. plugins recommended for php

Build

For build can use phing (example) or ant.

<?xml version="1.0" encoding="UTF-8"?>
<project name="start_page" basedir="." default="main">
<!-- $Id: build.xml 102 2009-02-26 14:39:10Z abtris $ -->
<property name="tmp" value="/tmp" />
<property name="wsname" value="source" />
<property name="package"  value="${phing.project.name}" override="true" />
<property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" />
<property name="srcdir"   value="./src/" override="true" />

<!-- Main Target -->
<target name="main" description="main target">

<!-- Create dirs -->
<mkdir dir="${builddir}/reports"/>
<mkdir dir="${builddir}/reports/coverage"/>

<!-- PHP API Documentation -->
<phpdoc title="API Documentation"
destdir="${builddir}/apidocs"
sourcecode="yes"
defaultpackagename="StartPage"
output="HTML:Smarty:PHP">
<fileset dir=".">
<include name="*/*.php" />
</fileset>
</phpdoc>

<!-- PHP CodeSniffer -->
<exec command="phpcs --standard=ZEND --report=checkstyle ${ws}/${wsname}/src/ > ${builddir}/reports/checkstyle.xml" escape="false" />

<!-- PHPUnit -->
<exec command="phpunit --log-xml ${builddir}/reports/phpunit.xml --log-pmd ${builddir}/reports/phpunit.pmd.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ tests/AllTests.php"/>

</target>
</project>

Example configuration

Project name: StartPage
Source Code Management: Subversion
Repository URL: https://localhost/svn/start_page/trunk
Local module directory (optional): source
Use update: true

Build

Execute shell: phing -f $WORKSPACE/source/build.xml -Dws=$WORKSPACE -Dtmp=$WORKSPACE

Post-build action

Publish Javadoc
Javadoc directory = build/start_page/apidocs/
Retain javadoc for each successful build = false
Publish JUnit test result report
Test report XMLs = build/start_page/reports/phpunit.xml
Publish Checkstyle analysis results
Checkstyle results = build/start_page/reports/checkstyle.xml
Publish PMD analysis results
PMD results = build/start_page/reports/phpunit.pmd.xml
Publish Clover Coverage Report
Clover report directory = build/start_page/reports/coverage/