eZ Community » Blogs » Thiago Campos Viana » PHP Continuous Integration: A first...

By

PHP Continuous Integration: A first attempt

Monday 22 November 2010 1:11:39 pm

  • Currently 3 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

In this post I will create a walkthrough on how to set up an php continuous enviroment on Windows. This is not a complete post, I will need your help to make it perfect.

 Download XAMMP Lite
 
 http://www.apachefriends.org/en/xampp-windows.html
 
 Install it in C:\
 
 \apache\conf\httpd.conf
 
 Uncoment #LoadModule rewrite_module modules/mod_rewrite.so 
 Change the settings in the file: C:\xampplite\php\php.ini
 

max_execution_time 180
max_input_time 180
memory_limit 128

 
 
 
 
 ########################
 
 Control Panel->System->Advanced->Environment Variables->User Variables for XXXX
 Add or change the PATH variable with the value: C:\xampplite\php
 
 ########################
 Download XDebug
 
 http://xdebug.org/download.php
 
Rename the dll file to XDebug to php_xdebug.dll
 
Move it to C:\xampplite\php\ext
 
 
Open the file C:\xampplite\php\php.ini:
 

# At the XDebug block add: zend_extension = "XAMPP_HOME\php\ext\php_xdebug.dll".
 # Find and uncomment the line: xdebug.remote_host=localhost. Change the value of the setting from localhost to 127.0.0.1.
 # Find and uncomment the line: xdebug.remote_enable = 0. Change 0 to 1.
 # Find and uncomment the line: xdebug.remote_handler = "dbgp".
 # Find and uncomment the line: xdebug.remote_port = 9000.
 # Save the php.ini file.

 
 
 
 ########################
 
 Install pear extensions
 
 Start->Run->Type "cmd"
 
 

cd C:\xampplite\php
 
pear channel-update pear.php.net
 
pear channel-discover pear.symfony-project.com
pear install symfony/YAML
#pear upgrade symfony/YAML
 
pear channel-discover components.ez.no
pear install -a ezc/eZComponents
#pear upgrade ezc/eZComponents
 
 
 
pear channel-discover pear.phpunit.de
pear remote-list -c phpunit
pear install --alldeps phpunit/PHPUnit
#pear upgrade phpunit/PHPUnit
 
pear install PhpDocumentor
 
pear install Testing_Selenium-beta
 
pear install PHP_CodeSniffer
 
pear channel-discover pear.xplib.de
 
pear install xplib/PHP_CodeSniffer_Standards_EZC-beta
 
pear install phpunit/PHP_CodeBrowser
 
 
 
 
pear channel-discover pear.pdepend.org
 
 
pear install pdepend/PHP_Depend-beta
 
 
pear channel-discover pear.phpmd.org
 
pear install phpmd/PHP_PMD-alpha
 
pear install --alldeps phpunit/phpUnderControl

 http://sourceforge.net/projects/cruisecontrol/files/
 
 Install java jdk
 change the JAVA_HOME variable to C:\Program Files\Java\jdk1.6.0_17
 

Maybe it could be needed to copy jdk_home/lib/tools.jar to jre6_home/lib/ext
 
 
 Run using the Start menu the file cruisecontrol.bat
 
 phpuc install "C:\Program Files\CruiseControl"
 
 
 Close the cruisecontrol prompt and go to the Start menu and open it again.
 
 
 ########################
 Download Netbeans (PHP or Full)
 http://netbeans.org/downloads/index.html
 
 Change Netbeans language:
 
 Netbeans_Folder\etc
 
 Open "netbeans.conf", find the default options line:
 
 netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"
 
Add "-J-Duser.language=en -J-Duser.region=US" to the end of line:
 

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m 
-J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none 
-J-Dapple.laf.useScreenMenuBar=true -J-Duser.language=en 
-J-Duser.region=US"

 
Open the Netbeans

 Tools->Options->PHP
 
 General
 PHP 5 Interpreter=C:\xampplite\php\php.exe
 UnitTesting
 PHPUnit Script: C:\xampplite\php\phpunit.bat
 
 
 ########################
 Download NBGit
 
 http://code.google.com/p/nbgit/
 
 Netbeans->Tools->Plugins->Download->Add Plugin
 
 Team->Git->Clone other
 
 http://github.com/ezsystems/ezpublish.git ( Only the benchmark and tests folder are important now )
 
 ###########################
 download netbeans php codesniffer
 
 http://github.com/beberlei/netbeans-php-enhancements/downloads/
 
 
 
 Tools->options->php->code sniffer->pear
 
 #################################
 
 available plugins
 
 selenium module for php
 
 #################################
 
 php md for netbeans ( I'm not sure if it is woking )
 
 
 http://sourceforge.net/projects/phpmdnb/
 
 Tool->options->misc->phpmd
 
 Using phpmd:

phpmd C:\xampplite\htdocs\ez\kernel\classes\ezaudit.php xml codesize,design,unusedcode,naming --reportfile C:\teste.xml

 
 ############################
 
 Using pdepend:

pdepend --summary-xml=/tmp/summary.xml \ 
 --jdepend-chart=/tmp/jdepend.svg \ --overview-pyramid=/tmp/pyramid.svg \
 /usr/local/share/pear/PHP/Depend

 
 
 ############################
 Download ez publish
 
 http://share.ez.no/download-develop
 
 C:\xampplite\htdocs
 
 extract ezpublishcommunity-4.4.0-with_ezc-gpl.tar.gz
 rename the folder ezpublish-4.4.0-with_ezc-gpl to ez
 

 Install it.

 
 
 #########
 
Running tests:

php bin/php/ezpgenerateautoloads.php -e
php tests/runtests.php extension/extfolder

BD testing

php tests/runtests.php -D mysql://root@localhost/ezpublish extension/extfolder

#########

Now you need to set up cruisecontrol to work with your project.

Edited, quick notes:

 

 

mkdir /usr/local/jenkins
cd /usr/local/jenkins/
wget <a href="http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war">http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war</a>
export JENKINS_HOME=/usr/local/jenkins
 java -jar jenkins.war

pear config-set auto_discover 1
pear install pear.phpqatools.org/phpqatools PHPDocumentor

pear channel-discover pear.netpirates.net
 pear channel-discover components.ez.no
pear install theseer/Autoload
pear install pear.netpirates.net/phpDox

sudo pear config-set auto_discover 1
 sudo pear install pear.netpirates.net/phpDox

pear -d preferred_state=beta install phpunit/DbUnit

-
gedit /etc/php5/conf.d/xdebug.ini
zend_extension="/usr/lib/php5/20090626/xdebug.so"

-

wget <a href="http://localhost:8080/jnlpJars/jenkins-cli.jar">http://localhost:8080/jnlpJars/jenkins-cli.jar</a>

java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin checkstyle
 java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin cloverphp
java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin dry
 java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin htmlpublisher
java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin jdepend
 java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin plot
java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin pmd
java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin violations
 java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin xunit

java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin git
 java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> install-plugin greenballs


java -jar jenkins-cli.jar -s <a href="http://localhost:8080">http://localhost:8080</a> safe-restart


sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
git clone <a href="http://github.com/isaacs/npm.git">http://github.com/isaacs/npm.git</a>
 cd npm
sudo make install
sudo npm install -g csslint


If you are using the Template mentioned above go to  <parallelTasks ..> element and add:
1
    
<antcall target="csslint"/>
 
----

<target name="csslint" description="Run the CSSLint tool on CSS files">
    <fileset dir="." id="cssfiles.raw">
      <include name="**/*.css" />
     </fileset>
    <pathconvert pathsep=" " property="cssfiles.clean" refid="cssfiles.raw"/>
    <exec executable="csslint" output="${basedir}/build/logs/csslint.xml">
       <arg line="--rules=errors --format=lint-xml ${cssfiles.clean}" />
    </exec>
</target>


+++++++++++++++

<a href="http://code.google.com/p/jslint4java/downloads/list">http://code.google.com/p/jslint4java/downloads/list</a>    ---dist
 
mkdir /usr/local/jslint
export JSLINT_HOME=/usr/local/jslint/

<target name="jslint" description="Run the JSLint tool on JS files">
  <fileset dir="public/scripts" id="jsfiles.raw">
     <include name="**/*.js" />
    <exclude name="**/*.min.js" />
  </fileset>
  <pathconvert pathsep=" " property="jsfiles.clean" refid="jsfiles.raw" />
   <exec executable="java" output="build/logs/jslint.xml">
    <arg line="-jar $JSLINT_HOME/jslint4java.jar --report xml ${jsfiles.clean}" />
  </exec>
</target>

<taskdef name="jslint" classname="com.googlecode.jslint4java.ant.JSLintTask"/>
<target name="jslint">
<jslint haltOnFailure="false" options="undef" jslint="${jslint.js.file}">
 <predef>tw,ps,log,TWDate,Packages,java,assertEquals,assertNotEquals,assertTrue,assertFalse,assertExists,newSQLStatement,newSQLParameter,addSQLParameter,assertNotExists,assertGreater,constructHeading,constructCheckbox,constructRadio,buildInfoPopupDiv</predef>
 <formatter type="xml" destfile="jslint_results.xml"/>
<fileset dir="${js.root}" includes="**/*.js" />
</jslint>
</target>

#########

Proudly Developed with from