Continuous Integration and PHP

download Continuous Integration and PHP

If you can't read please download the document

Transcript of Continuous Integration and PHP

improve your development processContinuous Integration and PHP

Arno SchneiderSystem ArchitectProject Lead of Xinc

Buenas!Como vosotros puedeis ver, yo no soy nativo espaol ni catala ;)

Por eso creo que es mejor para todos que hago la presentacion en ingles ;)

Por que es una pena, tengo unas copias de la presentacion en castellano, si quieres pregunta por una copia

Y ahora en ingles, si disculpeis.

The presentation I am going to give is about the process of Continuous Integration in General and especially in the PHP world and how you can use it to deliver better quality products

Continuous Integration and PHP

Introduction

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Hello,

My name is Arno schneider,I am currently working as System Architet at Local BillingIn my freetime I am the lead developer of Xinc, which is a continuous integration server we will speak about later.In my professional life I am used to working with Continuous Integration tools like CruiseControl and Xinc

Continuous Integration and PHP

Topics of this Presentation

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

We will talk about

- What continuous Integration is in general- And how you can use it in your development process to improve quality and satisfaction for all participants- We will look at two special Servers which can be used for Continuous Integration with PHP - One of them which is CruiseControl and the phpUnderControl extension - And the other is Xinc a PHP based solution where I am involved in the development- To wrap it up I will give you a short introduction in how Continuous Integration works with Xinc

Continuous Integration and PHP

What is Continuous Integration?
What is Integration?

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

The name Continuous Integration consists of two parts.Continuous which means frequent, ongoingand Integration.

What does the term Integration mean here in this context?- We are going to speak about Integration as integrating a change, modifying, adding a piece of your software system into your source code repository without breaking the project and its functionality. For example modifying the database schema would be a change you need to integrate.

When is Integration becoming really important?- Any change you do that has an impact on the functionality- The more developers and/or components you have, the more dependencies you have and the complexity of changes and their effect is raising

Continuous Integration and PHP

What is Continuous Integration?
Short Summary

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

So to summarize as short as possible what Continuous Integration can be seen as.

It is a Software engineering practice,describing how to integrate all changes to your project very frequently an assuring a stable product by generating self testing code, covered by unit tests.

It uses the rapid feedback mechanism to inform involved developers of an integration problem, so it can be solved fast and before it gets more complex. We call that Putting the pain up front.

Goal of this practice is to generate as many working builds as possible.Now what do we mean here, when talking of a build?

Continuous Integration and PHP

What is Continuous Integration?
A common process without Continuous Integration

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Number of Bugs

undetected bugs

Project Timeline

Development Phase

Testing PhaseIntegration Phase

Lets have a look at a very common way of developing software in a team.

- We have Developer A and Developer B- Developer B is waiting for Developer A to define some interfaces, classes, methods so he can work with them- Once defined, Developer B starts developing using these methods and functions, so that it works on this local machine- Developer A of course is working as well to improve the functionality and changes interface declarations, function and method declarations as well.- Since it does not work that well yet, they keep on working on there local computers- Slowly de-stabilizing the code base without knowing it- Not realizing the problems until committing and testing- Once committed, neither the Code of Developer A nor the Code of Developer B work anymore.- The worst thing is, they DO NOT find out until testing manually, since there are no Unit Tests in place.- A full week of work seems to be for the trash

Continuous Integration and PHP

What is Continuous Integration?
Workflow for Developers first step towards CI

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Checkout / Update

Develop

Local testing

Update WC

Resolve / Testing

Commit

ReceiveBuild Result

!

Lets review the Developer Workflow which is absolutely mandatory for the CI process to work properly.

A developers work starts with checking out the sources from the repository or with updating his working copy.

He works on a feature / a function. Tests his development locally until its ready to integrate it into the repository.

To make sure he developed against the latest sources, he fetches the latest update from the repository.

He merges changes and resolve conflicts and tests local to assure a working commit.He commits to the repository.Now his work is not done, he needs to wait for the build result.if the build was successful, he can go on and start the workflow from the beginning.

Continuous Integration and PHP

What is Continuous Integration?
Development process with Continuous Integration

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Number of Bugs

Project Timeline

Development

Testing / Integration

Undetected Bugs

Lets have a look at a very common way of developing software in a team.

- We have Developer A and Developer B- Developer B is waiting for Developer A to define some interfaces, classes, methods so he can work with them- Once defined, Developer B starts developing using these methods and functions, so that it works on this local machine- Developer A of course is working as well to improve the functionality and changes interface declarations, function and method declarations as well.- Since it does not work that well yet, they keep on working on there local computers- Slowly de-stabilizing the code base without knowing it- Not realizing the problems until committing and testing- Once committed, neither the Code of Developer A nor the Code of Developer B work anymore.- The worst thing is, they DO NOT find out until testing manually, since there are no Unit Tests in place.- A full week of work seems to be for the trash

Continuous Integration and PHP

Using CI to improve your development
How to get started

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

How do we get from the current situation ...feeling the pain late and suffering more

.. to a CI controlledworkflow?suffering the pain earlierand have a better product

If you want to implement a Continuous Integration Process, how do you get from your current situation

- Where you have hardly any unit tests- No real build automation- Where you will always feel the pain of integration very late

to the desired situation

- A CI controlled development process with automated builds, running your unit-tests to assure stability and to inform your of broken builds

Continuous Integration and PHP

Using CI to improve your development
How to get started self testing code

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

First thing you have to do to get started is to work on your unit-tests.

How much of your code is covered by unit tests? Probably not a whole lot.Without unit tests, CI does not make a lot of sense

Start using PHPUnit or if you already did so, extend your test suite- When you discover new bugs, develop a unit test with the fix of the bug- Also develop unit tests for each new feature- You dont need full code coverage, you have to find your level.

Next step is to automate your build- All the unit tests are not worth anything if you dont let them validate your code change with every integration, every commit into the repository.- Look into preferrably Phing or Ant to create build scripts for automation

Continuous Integration and PHP

Using CI to improve your development
How to get started team development behavior

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

One of the most important things to get Continuous Integration working is to change the behaviour of your team.Developers need to test locally first. They also need to change their attitude towards testing. Instead of just saying My code works they have to proove that it works ... with unit tests.You have to encourage all developers, your team members to use the CI workflow. Learning to commit on a functional level is very important. Commits are a good thing, the more commits we do, the more integrations and the earlier we detect bugs.Smaller commits, less changed files also allow for diff-debugging. You can just compare the current broken source code with the last working one.The most important part of the CI workflow is to understand that a commit is not finished until you received feedback for it. If it failed its your responsibility to fix the build.

Continuous Integration and PHP

Using CI to improve your development
How to get started configuration control / automated deployment

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Besides working on testing more and changing the way you work, CI requires you do improve on your configuration management.For build automation it is very important that you put everything, really everything under version control and into a single soure code repository. This is a difficult task.That includes external components, database schema, data, configuration files and much more.Going from there you have to create a deliverable for each product you are working on, that can be easily installed and is fairly easy accessible for all team members.To do End-to-End testing of your product, you have to clone your production environment. Very difficult, especially if you have expensive production systems. The minimum would be to clone the version numbers of the main components. Automating deployment into this cloned environment and running tests there, gives you another feedback channel and more confidence that your builds are stable and working.

Continuous Integration and PHP

Using CI to improve your development
How to get started - Summary

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

To summarize and wrap up our understanding of Continuous Integration.As you have seen, Continuous Integration is more than setting up a CI ServerYou really have to live it, every day your are working.Any tool, that can ease the pain, make CI more comfortable for you and show the positive results, is welcome.

Keep in mind, that Continuous Integration is a customized process, tailored to meet your needs. It does not have to be the same in every company.

Continuous Integration and PHP

Continuous Integration Servers
Workflow with CI Server

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Continuous Integration Servers
Benefits

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Continuous Integration Servers
CruiseControl + phpUnderControl

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Continuous Integration Servers
CruiseControl + phpUnderControl

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Continuous Integration Servers
Xinc Is Not CruiseControl

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Continuous Integration Servers
Xinc Is Not CruiseControl

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Continuous Integration Servers
Basic Comparison CC vs. Xinc for CI in PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc CI Server for PHP

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc Project Config - /etc/xinc/conf.d/xinc.xml

defining the change lookup interval:checking every 5 minuteschecking modifications on svn:update the WC if change detectedset of builders to be run:a project can have several buildersset of publisher to be run:general, onfailure, onsuccess, onrecoveryXinc CI Server for PHP

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc Project Config - /etc/xinc/conf.d/xinc.xml

phingbuilder:calling a phing build scriptXinc CI Server for PHP

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc Project Config - /etc/xinc/conf.d/xinc.xml

on failure publisher:sending out an email for the failed buildXinc CI Server for PHP

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc Project Config - /etc/xinc/conf.d/xinc.xml

on success publisher:make the pear package available for downloadXinc CI Server for PHP

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc CI Server for PHP

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Xinc CI Server for PHP
Checking the build results on the web interface

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

build status summary:status, build time, build labelcomplete build history:access historical buildsbuild log message:displaying info about build stepsXinc CI Server for PHP
Checking the build results on the web interface

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

project access:overview of projectsmodification summary:showing the number of modified filescommit logs:showing the last comments for the changeregistered artifacts:downloads, reports, documentationXinc CI Server for PHP
Checking the build results on the web interface

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

PHPUnit test results:registered as an artifactXinc CI Server for PHP
Checking the build results on the web interface

Continuous Integration and PHP

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Code Coverage Results:registered as an artifactXinc CI Server for PHP
Checking the build results on the web interface

Continuous Integration and PHP

Xinc CI Server for PHP
Future of Xinc Where is it heading to?

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Continuous Integration and PHP

Links
Where can I find more information?

improve your development processArno Schneider @Barcelona PHP Conference, Feb. 23rd 2008

Thank you for your attentionMuchas gracias por su atencin!

CruiseControlXincExecution PlatformJVMPHPInstallerWindows Installer / Zip FilePEARPreferred Build Toolsant, mavenphingOther Supported Build Toolsphing (unstable integration) ...SCM supportcvs, svn, perforce ...svnSupported Project Languagesanything that ant can buildPHPWeb FrontendJettyApache (preferred)Extendible throughXSL, JSP, JavaXinc Plugins (PHP)

???Page ??? (???)02/22/2008, 22:17:21Page /