Skip to content

Instantly share code, notes, and snippets.

@rob-murray
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob-murray/9503484 to your computer and use it in GitHub Desktop.
Save rob-murray/9503484 to your computer and use it in GitHub Desktop.
PHP CI.md
### Continuous Integration; PHP
> RM 12.3.14
### What this is about
* Here is what I have done with CI for a PHP project.
* Key aim is knowledge sharing and if sessions like this are value.
I am not saying that this is correct or should be or even can be applied to all projects but this has worked for me.
I will go through some of the tools used, some of the steps in the integration process - I am open to suggestions or discussions on different ways to do things.
### What is CI?
A process of integrating code in a software development project and validating the cohesion ?
Not a tool, maybe not a process but more a behaviour.
### How do we validate the project cohesion?
This could be a manual process; maybe employ a team of people to do it, or...
Because we automated EVERYTHING, this should be an automated process and because we don't want to reinvent the wheel we use a tool to do this; enter Jenkins.
But we need some way to validate the changes so we have some kind of tests.
This test could be just that the project compiles, or you could actually verify the functionality so we have suites of tests.
All this is so that...
* find problems due to changes quickly with feedback
* constant availability of a product that is shippable
* frequent checkins
But you probably need some kind of tests.
### What is Jenkins
A generic tool to centralise integrating and building projects of various technologies. We can tell it to look for changes in source code repo and then do something, then do something else, then finally do something else.
Loads of technologies, loads of plugins.
### What is the project
A trying to be RESTful API for OS MapFinder clients; we use http verbs, codes and stateless
Make a request and get either http code or http 200 and json back. Easy.
Runs on MS Azure with IIS :(
How I came to take it on...
### Tools used
#### PHP Project
It's using `Silex` for routing, request, response abstraction + MS Azure SDK + the rest is custom code.
#### Dependancy management
Composer - I have had problems with some packages but obvious value with this.
Why dependancy management?
#### Build
Ant - Everyone knows how it works
This will build the project artifact; the thing that is deployable.
But also as a wrapper around every other tool so that 1) convenience 2) Jenkins knows how to run things
#### Testing
PHPUnit
Types of test;
Unit
Integration(ish)
Functional
Various Phpunit configs for CI.
Failing tests will break the build - Not deployable.
#### Quality
PHPMD - Static analysis;
Not using any kind of CheckStyle yet - to be discussed.
Code quality will NOT break the build.
### How they fit with Jenkins
Look at the Jenkins job.
### Workflow
* Devs add tests and code.
* Devs commit.
* Jenkins runs tests...
* If all pass then builds the artifact - this is deployable >> we can release this with confidence.
#### Sonar
Look at Sonar and how this can be used.
### Summary
* Not set process but a series of blocks to build from
* Doesnt have to be big bang; implement in stages
Useful?

Continuous Integration; PHP

What this is about

  • Here is what I have done with CI for a PHP project.
  • Key aim is knowledge sharing and if sessions like this are value.

I am not saying that this is correct or should be or even can be applied to all projects but this has worked for me.

I will go through some of the tools used, some of the steps in the integration process - I am open to suggestions or discussions on different ways to do things.

What is CI?

A process of integrating code in a software development project and validating the cohesion ?

How do we validate the project cohesion?

This could be a manual process; maybe employ a team of people to do it, or...

Because we automated EVERYTHING, this should be an automated process and because we don't want to reinvent the wheel we use a tool to do this; enter Jenkins.

But we need some way to validate the changes so we have some kind of tests.

This test could be just that the project compiles, or you could actually verify the functionality so we have suites of tests.

All this is so that...

  • find problems due to changes quickly with feedback
  • constant availability of a product that is shippable
  • frequent checkins

But you probably need some kind of tests.

What is Jenkins

A generic tool to centralise integrating and building projects of various technologies. We can tell it to look for changes in source code repo and then do something, then do something else, then finally do something else.

Loads of technologies, loads of plugins.

What is the project

A trying to be RESTful API for OS MapFinder clients; we use http verbs, codes and stateless

Make a request and get either http code or http 200 and json back. Easy.

Runs on MS Azure with IIS :(

How I came to take it on...

Tools used

PHP Project

It's using Silex for routing, request, response abstraction + MS Azure SDK + the rest is custom code.

Dependancy management

Composer - I have had problems with some packages but obvious value with this. Why?

Code

Build

Ant - Everyone knows how it works

This will build the project artifact; the thing that is deployable.

But also as a wrapper around every other tool so that 1) convenience 2) Jenkins knows how to run things

Testing

PHPUnit

Types of test;

Unit Integration(ish) Functional

Various Phpunit configs for CI.

Quality

PHPMD - Static analysis;

Not using any kind of CheckStyle yet - to be discussed.

How they fit with Jenkins

Look at the Jenkins job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment