Intégration Continue Avec Jenkins Eric Hogue
Qu'est ce que l'intégration Continue?
Installer ant et Jenkins sudo apt-get install default-jdk ant Suivre les instructions sur le site de jenkins Installer les plugins Git Plugin Github Plugin Green Balls
 
Les outils
PHPUnit
Installation sudo apt-get install php5-xdebug php-pear sudo pear upgrade pear sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony-project.com sudo pear install phpunit/PHPUnit
phpunit.xml <phpunit bootstrap=&quot;Tests/bootstrap.php&quot;>      <testsuites>          <testsuite name=&quot;Demo&quot;>              <directory>.</directory> </testsuite>      </testsuites>      <logging>          <log type=&quot;coverage-html&quot;               target=&quot;build/phpunit/html&quot; title=&quot;CIDemo&quot;              charset=&quot;UTF-8&quot; yui=&quot;true&quot; highlight=&quot;true&quot;              lowUpperBound=&quot;35&quot; highLowerBound=&quot;70&quot; />          <log type=&quot;coverage-clover&quot; target=&quot;build/phpunit/clover.xml&quot;/>          <log type=&quot;junit&quot; target=&quot;build/phpunit/junit.xml&quot;               logIncompleteSkipped=&quot;false&quot; />      </logging> </phpunit>
build.xml <project name=&quot;CIDemo&quot; default=&quot;build&quot; basedir=&quot;.&quot;>      <property name=&quot;output&quot; location=&quot;${basedir}/build/&quot; />      <target name=&quot;build&quot; depends=&quot;prepare,phpunit&quot;>      </target>      <target name=&quot;prepare&quot; depends=&quot;clean&quot;>          <mkdir dir=&quot;${output}&quot; />      </target>      <target name=&quot;clean&quot;>          <delete dir=&quot;${output}&quot; />      </target>      <target name=&quot;phpunit&quot;>          <exec executable=&quot;phpunit&quot; failonerror=&quot;true&quot; />      </target> </project>
Plugin xUnit Résultats des tests unitaires
Plugin Clover PHP Rapports sur la couverture des tests
Plugin Clover PHP
PHP Code Sniffer
sudo pear install PHP_CodeSniffer Installation:  build.xml <target name=&quot;phpcs&quot;> <exec executable=&quot;phpcs&quot;> <arg line=&quot;--report=checkstyle --report-file=${output}/phpcs/checkstyle.xml --standard=Zend ${basedir}&quot; /> </exec> </target>
Plugin Checkstyle
 
PHP Depend
sudo pear channel-discover pear.pdepend.org sudo pear install pdepend/PHP_Depend-beta Installation:  build.xml      <target name=&quot;pdepend&quot;>          <exec executable=&quot;pdepend&quot;>              <arg line=&quot;                  --jdepend-xml=${output}/pdepend/jdepend.xml --jdepend-chart=${output}/pdepend/dependencies.svg                  --overview-pyramid=${output}/pdepend/overview-pyramid.svg --ignore=Tests/ .      &quot; />          </exec>      </target>
Plugin JDepend
 
PHP Mess Detector
sudo pear channel-discover pear.phpmd.org sudo pear channel-discover pear.pdepend.org sudo pear install --alldeps phpmd/PHP_PMD Installation:  build.xml <target name=&quot;phpmd&quot;>      <exec executable=&quot;phpmd&quot;> <arg line=&quot;. xml               codesize,unusedcode,naming,design               --reportfile ${output}/phpmd/messdetector.xml               --exclude Tests/&quot;           />      </exec> </target>
Plugin PMD
PHP Copy/Paste Detector
sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear install phpunit/phpcpd Installation:  build.xml <target name=&quot;phpcpd&quot; depends=&quot;prepare&quot;>      <exec executable=&quot;phpcpd&quot;>          <arg line=&quot; --log-pmd ${output}/phpcpd/phpcpd.xml               --min-tokens 30 .&quot; />      </exec> </target>
Plugin DRY
Template for Jenkins Jobs for PHP Projects By Sebastian Bergmann
http://jenkins-php.org/ Tout ce qu'il faut pour un projet PHP   Les plugins nécessaires   Un fichier build.xml   Un template pour Jenkins   PHP Project Wizard (PPW)
Autres possibilités Phing/Rake Autres tests (Selenium, Behat) Déployement  automatique/continue   ...
Questions? GitHub: https://github.com/EricHogue/ SlideShare: http://www.slideshare.net/EricHogue Blog: http://erichogue.ca/ Twitter: @ehogue Email: phpquebec@erichogue.ca LinkedIn http://ca.linkedin.com/in/ehogue Contact:

Integration continue

  • 1.
    Intégration Continue AvecJenkins Eric Hogue
  • 2.
    Qu'est ce quel'intégration Continue?
  • 3.
    Installer ant etJenkins sudo apt-get install default-jdk ant Suivre les instructions sur le site de jenkins Installer les plugins Git Plugin Github Plugin Green Balls
  • 4.
  • 5.
  • 6.
  • 7.
    Installation sudo apt-getinstall php5-xdebug php-pear sudo pear upgrade pear sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony-project.com sudo pear install phpunit/PHPUnit
  • 8.
    phpunit.xml <phpunit bootstrap=&quot;Tests/bootstrap.php&quot;>     <testsuites>          <testsuite name=&quot;Demo&quot;>              <directory>.</directory> </testsuite>      </testsuites>      <logging>          <log type=&quot;coverage-html&quot;               target=&quot;build/phpunit/html&quot; title=&quot;CIDemo&quot;              charset=&quot;UTF-8&quot; yui=&quot;true&quot; highlight=&quot;true&quot;              lowUpperBound=&quot;35&quot; highLowerBound=&quot;70&quot; />          <log type=&quot;coverage-clover&quot; target=&quot;build/phpunit/clover.xml&quot;/>          <log type=&quot;junit&quot; target=&quot;build/phpunit/junit.xml&quot;               logIncompleteSkipped=&quot;false&quot; />      </logging> </phpunit>
  • 9.
    build.xml <project name=&quot;CIDemo&quot;default=&quot;build&quot; basedir=&quot;.&quot;>      <property name=&quot;output&quot; location=&quot;${basedir}/build/&quot; />      <target name=&quot;build&quot; depends=&quot;prepare,phpunit&quot;>      </target>      <target name=&quot;prepare&quot; depends=&quot;clean&quot;>          <mkdir dir=&quot;${output}&quot; />      </target>      <target name=&quot;clean&quot;>          <delete dir=&quot;${output}&quot; />      </target>      <target name=&quot;phpunit&quot;>          <exec executable=&quot;phpunit&quot; failonerror=&quot;true&quot; />      </target> </project>
  • 10.
    Plugin xUnit Résultatsdes tests unitaires
  • 11.
    Plugin Clover PHP Rapportssur la couverture des tests
  • 12.
  • 13.
  • 14.
    sudo pear installPHP_CodeSniffer Installation:  build.xml <target name=&quot;phpcs&quot;> <exec executable=&quot;phpcs&quot;> <arg line=&quot;--report=checkstyle --report-file=${output}/phpcs/checkstyle.xml --standard=Zend ${basedir}&quot; /> </exec> </target>
  • 15.
  • 16.
  • 17.
  • 18.
    sudo pear channel-discoverpear.pdepend.org sudo pear install pdepend/PHP_Depend-beta Installation:  build.xml      <target name=&quot;pdepend&quot;>          <exec executable=&quot;pdepend&quot;>              <arg line=&quot;                  --jdepend-xml=${output}/pdepend/jdepend.xml --jdepend-chart=${output}/pdepend/dependencies.svg                  --overview-pyramid=${output}/pdepend/overview-pyramid.svg --ignore=Tests/ .      &quot; />          </exec>      </target>
  • 19.
  • 20.
  • 21.
  • 22.
    sudo pear channel-discoverpear.phpmd.org sudo pear channel-discover pear.pdepend.org sudo pear install --alldeps phpmd/PHP_PMD Installation:  build.xml <target name=&quot;phpmd&quot;>      <exec executable=&quot;phpmd&quot;> <arg line=&quot;. xml               codesize,unusedcode,naming,design               --reportfile ${output}/phpmd/messdetector.xml               --exclude Tests/&quot;           />      </exec> </target>
  • 23.
  • 24.
  • 25.
    sudo pear channel-discoverpear.phpunit.de sudo pear channel-discover components.ez.no sudo pear install phpunit/phpcpd Installation:  build.xml <target name=&quot;phpcpd&quot; depends=&quot;prepare&quot;>      <exec executable=&quot;phpcpd&quot;>          <arg line=&quot; --log-pmd ${output}/phpcpd/phpcpd.xml               --min-tokens 30 .&quot; />      </exec> </target>
  • 26.
  • 27.
    Template for JenkinsJobs for PHP Projects By Sebastian Bergmann
  • 28.
    http://jenkins-php.org/ Tout cequ'il faut pour un projet PHP   Les plugins nécessaires   Un fichier build.xml   Un template pour Jenkins   PHP Project Wizard (PPW)
  • 29.
    Autres possibilités Phing/RakeAutres tests (Selenium, Behat) Déployement  automatique/continue   ...
  • 30.
    Questions? GitHub: https://github.com/EricHogue/ SlideShare: http://www.slideshare.net/EricHogueBlog: http://erichogue.ca/ Twitter: @ehogue Email: phpquebec@erichogue.ca LinkedIn http://ca.linkedin.com/in/ehogue Contact:

Editor's Notes

  • #2 Qui suis-je?  - Développe depuis 2001 - Delphi, C++, C#, perl, PHP Mon histoire: - 8 ans dans la même cie - Code vieux de 6 ans - Changements ont des effets imprévisibles - Se croise les doigts avants de déployer - autre cie, code sniffer, mais jamais exécuté
  • #3 Définition: - Intégration fréquente     - Plus facile - Vérification automatique - Détecte les problèmes rapidement - Transparence
  • #4 Sun jdk? Ubuntu/Debian -&gt; apt-get RedHat/Fedora -&gt; yum Windows -&gt; setup.exe Mac -&gt; .pkg
  • #5 - Configurer Git (svn, mercurial...) - Branche -&gt; blank pour toutes - Poll SCM Every Minute - Configurer ant (maven, shell script, windows batch) - Notification, toujours au lead, plus celui qui brise le build
  • #6 Analyse dynamique Analyse Statique
  • #7 Analysise Dynamique Le plus important Tests unitaires Couverture de code avec Xdebug
  • #8 pear config-set auto_discover 1
  • #10 default basedir output build -&gt; depends  Ajouter tous les outils ici prepare/clean
  • #12 Couverture par ligne
  • #13 Nombre = tests qui couvre ligne
  • #14 Standarts Document que persone ne lit
  • #15 Fichier xml avec un standard
  • #16 Projet existant -&gt; Check only new errors Click sur un fichier ammene a l&apos;erreur
  • #18 Outil d&apos;analyse statique Permet de détecter des problemes potentiels Complexité Noms Longueur
  • #21 Ca - Afferent Couplings: The number of other packages that depend on this Ce - Efferent Couplings: The number of other packages that classes from this package depend upon Instability: Ratio of coupling (Ce / (Ce + Ca)) Abstraction: Ratio of abstract and concrete classes   (ac / (ac + cc)) D =&gt; Distance V=&gt; Volatility Héritage ANDC -&gt; The  Average Number of Derived Classes AHH -&gt; Average Hierarchy Height   Taille et complexité Cyclomatic Complexity Coupling Fanout -&gt; types référencé Calls -&gt; method calls Abstraction Instability Chart Abstract -&gt; many depends on it -&gt; keep stable Concrete -&gt; many dependencies -&gt; unstable
  • #23 Types:  Code Size - Cyclomatic complexity - Méthode/classe trop longue - Trop de parametres Design - exit - eval - goto - coupling Naming - Nom variable/méthode court/long - Constructor name has class &lt;&gt; __construct Unsused code
  • #26 Changer  --min-tokens     def: 70 --min-lines         def: 5
  • #27 Don&apos;t Repeat Yourself
  • #28 Montrer Jenkins
  • #29 Plugins installer command line
  • #31 Avec CI on peut maintenant avoir confiance en nos changements