Continuous Integration (CI) is a software development practice where developers regularly merge their work into a central repository. This allows for automated builds and tests which catch errors early. CI helps reduce integration problems, improves code quality, and allows for more frequent deployments. The document discusses implementing CI with tools like Jenkins, build scripts, unit testing, code analysis, and notifications to improve the development process.
2. Who am I?
Patrick Mizer
Chief Architect at SpareFoot
ZCE: PHP4, PHP5, and ZF
patrick@sparefoot.com
github.com/maximizer
3. We help consumers search,
compare, and book self
storage online.
I’m not supposed to say this but…
Think Hotels.com, but for self storage.
4. We have been using a
Continuous Integration
workflow since 2009
5. SpareFoot in 2009
❏ 20 Visits per day
❏ 1 RackSpace cloud instance
❏ 2 Developers
❏ 1 Application
❏ 5-10 builds per day
❏ Deployed whenever -> % svn up
6. SpareFoot Today
❏ 2 million visitors per month
❏ > 50 AWS EC2 instances
❏ 35 developers
❏ 7 product teams.
❏ 100-200 builds per day
❏ Continuous Delivery
7. What I will cover...
❏ What is CI?
❏ Why do it?
❏ The Jenkins CI Server
❏ What does a CI workflow look like?
❏ Build Tools
❏ Testing and Analysis
❏ Notification
❏ Lessons Learned
15. What is Continuous Integration?
CI is a software development process in which
developers integrate their work frequently.
Each integration is built and verified by
automated tests so that errors and
inconsistencies are detected and fixed as
quickly as possible.
16. What is Continuous Integration?
CI originated with Extreme Programming
CI is a process. It dictates no specific tooling.
21. Integration Hell
“Your changes to the booking service are
incompatible with mine. How do we merge
now?”
“When did we start using Guzzle 2.0? The
SDK requires 3.0 and composer won’t let us
use both!”
30. No Deployable Code
“It works on my machine!”
“I don’t know why it’s not working on staging,
sounds like an ops problem.”
“We need to push a fix for this immediately.”
31. CI attempts to mitigate these
❏ Finding bugs late is costly
❏ Integration hell
❏ Poor quality code base
❏ Poor project visibility
❏ No deployable code
32. Better code, faster development
Better code
❏ Code is tested early and often
❏ Standards enforced on every commit
33. Better code, faster development
Better code
❏ Code is tested early and often
❏ Standards enforced on every commit
Faster development
❏ Integration issues are found earlier
❏ Testing becomes part of everyone’s process
❏ Building is a non-event
37. Continuous Integration
❏ Maintain an SCM code repository
❏ Create and automate the build
❏ Everyone commits to mainline (at least daily)
38. Continuous Integration
❏ Maintain an SCM code repository
❏ Create and automate the build
❏ Everyone commits to mainline (at least daily)
❏ Every commit to mainline is built
39. Continuous Integration
❏ Maintain an SCM code repository
❏ Create and automate the build
❏ Everyone commits to mainline (at least daily)
❏ Every commit to mainline is built
❏ Tests verified on a prod-like environment
40. Continuous Integration
❏ Maintain an SCM code repository
❏ Create and automate the build
❏ Everyone commits to mainline (at least daily)
❏ Every commit to mainline is built
❏ Tests verified on a prod-like environment
❏ Notify everyone of the results
41. Excuses
“We're not big enough”
“Too much work”
“We don't have devops”
“We don't have tests”
42. The CI Server
❏ Polls for changes
❏ Manages and monitors builds
❏ Notifies team of results
43. Jenkins
❏ Free Open Source (MIT License)
❏ Built on Java
❏ Fork of Hudson
❏ Plugins for everything
❏ Lots of resources
Easy to get going:
% sudo apt-get install jenkins
% sudo apt-get install jenkins-cli
44. Jenkins-php.org
Jenkins template for PHP projects put together
by Sebastian (yes, that Sebastian) Bergmann
Step-by-step Instructions:
❏ Template w/ plugins
❏ Build file
❏ Log formats
❏ Jenkins config
45. The CI workflow
❏ Developer commits code
❏ CI Server polls SCM for changes
❏ CI Server integrates and builds code
to the Integration Environment
❏ CI notifies team of result
72. Performance - Bonus
Phantomjs is a headless browser
based on Webkit with JS API
YSlow is a tool that analyzes web
pages and why they’re slow based on
Yahoo’s rules.
Phantomjs + YSlow = Awesomeness
81. Lessons Learned
Building the DB
❏ Put your schema changes under version
control.
❏ Incorporate them into the build
❏ Fail when there’s a problem. Make this the
only way to get schema changes to
production.
84. Our Git Workflow
commit commit PUSH
Branch
Merge
Pull
request
commit
PUSHcommit commit commit
Merge
Pull
request
MASTER
BRANCH B
BRANCH A
Branch + master
built to dev
environment and
tested.
Branch + master
built to dev
environment and
tested.
Master built to
staging
environment and
tested.
85. Play with Jenkins today!
github.com/
maximizer/vagrant-ci
% git clone github.com/maximizer/vagrant-ci.git
% vagrant up
http://localhost:8282
http://jenkins-php.org