SlideShare a Scribd company logo
Continuous Integration
Stop procrastinating and build often!
Who am I?
Patrick Mizer
Chief Architect at SpareFoot
ZCE: PHP4, PHP5, and ZF
patrick@sparefoot.com
github.com/maximizer
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.
We have been using a
Continuous Integration
workflow since 2009
SpareFoot in 2009
❏ 20 Visits per day
❏ 1 RackSpace cloud instance
❏ 2 Developers
❏ 1 Application
❏ 5-10 builds per day
❏ Deployed whenever -> % svn up
SpareFoot Today
❏ 2 million visitors per month
❏ > 50 AWS EC2 instances
❏ 35 developers
❏ 7 product teams.
❏ 100-200 builds per day
❏ Continuous Delivery
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
I want to clarify something..
Continuous something...
Continuous Integration
Continuous Delivery
Continuous Deployment
Continuous something...
Continuous
Integration
Continuous
Delivery
Continuous
Deployment
Continuous something...
Version
Control
Deploy to
Staging
Automated
Tests
AUTO AUTO
Continuous
Integration
Continuous
Delivery
Continuous
Deployment
Continuous something...
Version
Control
Deploy to
Staging
Automated
Tests
Acceptance
Tests
Deploy to
Production
AUTO AUTO AUTO MANUAL
Version
Control
Deploy to
Staging
Automated
Tests
AUTO AUTO
Continuous
Integration
Continuous
Delivery
Continuous
Deployment
Continuous something...
Version
Control
Deploy to
Staging
Automated
Tests
Acceptance
Tests
Deploy to
Production
AUTO AUTO AUTO AUTO
Version
Control
Deploy to
Staging
Automated
Tests
Acceptance
Tests
Deploy to
Production
AUTO AUTO AUTO MANUAL
Version
Control
Deploy to
Staging
Automated
Tests
AUTO AUTO
Continuous
Integration
Continuous
Delivery
Continuous
Deployment
Continuous something...
Version
Control
Deploy to
Staging
Automated
Tests
Acceptance
Tests
Deploy to
Production
AUTO AUTO AUTO AUTO
Version
Control
Deploy to
Staging
Automated
Tests
Acceptance
Tests
Deploy to
Production
AUTO AUTO AUTO MANUAL
Version
Control
Deploy to
Staging
Automated
Tests
AUTO AUTO
Continuous
Integration
Continuous
Delivery
Continuous
Deployment
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.
What is Continuous Integration?
CI originated with Extreme Programming
CI is a process. It dictates no specific tooling.
So, why do it?
So, why do it?
Finding bugs late is costly
Local
Development
Staging
Production
Developers
QA &
Stakeholders
Your
Customers
Finding bugs late is costly
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!”
Integration Hell
Mainline
Developer C
Developer A
Developer B
Integration Hell
Mainline
Developer C
Developer A
Developer B
Integration Hell
Mainline
Developer C
Developer A
Developer B
Integration Hell
Mainline
Developer C
Developer A
Developer B
Integration Hell
Mainline
Developer C
Developer A
Developer B
Integration Hell
Mainline
Developer C
Developer A
Developer B
Poor Quality Codebase
“Who the #$@# is using tabs instead of
spaces!?”
“We have 2 classes doing the exact same
thing”
Poor Project Visibility
“What is our test coverage?”
“How is our app performing?”
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.”
CI attempts to mitigate these
❏ Finding bugs late is costly
❏ Integration hell
❏ Poor quality code base
❏ Poor project visibility
❏ No deployable code
Better code, faster development
Better code
❏ Code is tested early and often
❏ Standards enforced on every commit
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
Continuous Integration
Implementing a CI solution is pretty
straightforward.
Continuous Integration
❏ Maintain an SCM code repository
Continuous Integration
❏ Maintain an SCM code repository
❏ Create and automate the build
Continuous Integration
❏ Maintain an SCM code repository
❏ Create and automate the build
❏ Everyone commits to mainline (at least daily)
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
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
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
Excuses
“We're not big enough”
“Too much work”
“We don't have devops”
“We don't have tests”
The CI Server
❏ Polls for changes
❏ Manages and monitors builds
❏ Notifies team of results
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
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
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
The CI workflow
Push
The CI workflow
Poll
Push
The CI workflow
Poll
Build
Push
The CI workflow
Poll
Build
Test/Analyze
Push
The CI workflow
Poll
Build
Test/Analyze
Notify
Push
The Build
❏ Build dependencies
❏ Tests
❏ Static analysis
❏ Artifacts (docs, phar, etc)
❏ ...
Build tools...
Build tools...
“But build files are only for
compiling.”
Build tools...
Use a proper built tool
❏ Apache Ant (Java)
❏ Phing (PHP)
Apache Ant
❏ build.xml
❏ Targets and depends
❏ Java = threads ++
Anatomy of build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="some-php-project" default="build">
<target name="build" depends="phpunit"/>
<target name="phpunit" description="Run unit tests">
<exec executable="phpunit" failonerror="true"/>
</target>
</project>
SCM polling and build
The Integration Machine
❏ A reasonable facsimile of production
❏ Every commit is built here
❏ By yourself? Use Vagrant
Verifying the Build
Unit Tests Functional Tests
Selenium
“But setting up selenium is
hard...”
SauceLabs
SauceLabs
Testing is just the beginning
Static Analysis
Analysis of software without
actually executing the code.
Check your PHP syntax
PHP Lint
php -l foo.php
find . -name “*.php” -exec
php -l {};
PHP Lint
Coding Standards
PHP Code Sniffer
phpcs --standard=pear foo.php
PHP Code Sniffer
DRY
Copy page detector
phpcpd -min-lines=5 /src/service/*
Copy Paste Detector
Performance
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
Performance - Bonus
phantomjs yslow.js
-i grade -threshold "A"
-f junit
http://staging.sparefoot.com >
results.xml
Notification
Notification
Notification
Notification
Lessons Learned
Lessons Learned
Lessons Learned
Version all of you CI Config.
We didn’t and now we’re
going back and rewriting it.
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.
Git feature branching
Git feature branching solves
a separate problem.
Git feature branching
Master
Branch C
Branch A
Branch B
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.
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
Thank You!
Questions?
https://joind.in/13077
patrick@sparefoot.com
github.com/maximizer/vagrant-ci

More Related Content

What's hot

Full session asp net mvc vs aspnet core
Full session asp net mvc vs aspnet coreFull session asp net mvc vs aspnet core
Full session asp net mvc vs aspnet core
fizmhd
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
Florian Fesseler
 
Introduction to Progressive Web Apps (PWA)
Introduction to Progressive Web Apps (PWA)Introduction to Progressive Web Apps (PWA)
Introduction to Progressive Web Apps (PWA)
Sandip Nirmal
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jest
pksjce
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
NexThoughts Technologies
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
Doeun KOCH
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
Marian Wamsiedel
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
Shakil Ahmed
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
Smile Gupta
 
Aprendendo Angular com a CLI
Aprendendo Angular com a CLIAprendendo Angular com a CLI
Aprendendo Angular com a CLI
Vanessa Me Tonini
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
Ahmed rebai
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
Thomas Hunter II
 
Introducing OpenAPI Version 3.1
Introducing OpenAPI Version 3.1Introducing OpenAPI Version 3.1
Introducing OpenAPI Version 3.1
SmartBear
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | Edureka
Edureka!
 
Top java script frameworks ppt
Top java script frameworks pptTop java script frameworks ppt
Top java script frameworks ppt
Omkarsoft Bangalore
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
Knoldus Inc.
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Dinesh U
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot Framework
Pekka Klärck
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!
Chris Richardson
 

What's hot (20)

Full session asp net mvc vs aspnet core
Full session asp net mvc vs aspnet coreFull session asp net mvc vs aspnet core
Full session asp net mvc vs aspnet core
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
Introduction to Progressive Web Apps (PWA)
Introduction to Progressive Web Apps (PWA)Introduction to Progressive Web Apps (PWA)
Introduction to Progressive Web Apps (PWA)
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jest
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
Design functional solutions in Java, a practical example
Design functional solutions in Java, a practical exampleDesign functional solutions in Java, a practical example
Design functional solutions in Java, a practical example
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
 
Aprendendo Angular com a CLI
Aprendendo Angular com a CLIAprendendo Angular com a CLI
Aprendendo Angular com a CLI
 
Reactjs workshop
Reactjs workshop Reactjs workshop
Reactjs workshop
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Introducing OpenAPI Version 3.1
Introducing OpenAPI Version 3.1Introducing OpenAPI Version 3.1
Introducing OpenAPI Version 3.1
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | Edureka
 
Top java script frameworks ppt
Top java script frameworks pptTop java script frameworks ppt
Top java script frameworks ppt
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot Framework
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!Dark Energy, Dark Matter and the Microservices Patterns?!
Dark Energy, Dark Matter and the Microservices Patterns?!
 

Similar to CI

Continuous Integration - What even is it?
Continuous Integration - What even is it?Continuous Integration - What even is it?
Continuous Integration - What even is it?
Rob Jacoby
 
Hudson
HudsonHudson
Hudson
8x8
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Amazon Web Services
 
Continuous Delivery in Practice (extended)
Continuous Delivery in Practice (extended)Continuous Delivery in Practice (extended)
Continuous Delivery in Practice (extended)
Tzach Zohar
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
D
 
Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)
Anton Babenko
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
Kris Buytaert
 
Software engineering
Software engineeringSoftware engineering
Software engineering
bartlowe
 
What is dev ops?
What is dev ops?What is dev ops?
What is dev ops?
Mukta Aphale
 
Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applications
Sunil Dalal
 
Continuous delivery in Qbon
Continuous delivery  in QbonContinuous delivery  in Qbon
Continuous delivery in Qbon
Jaric Kuo
 
Announcing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck TalksAnnouncing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck Talks
Amazon Web Services
 
Let’s start Continuous Integration with jenkins
Let’s start Continuous Integration with jenkinsLet’s start Continuous Integration with jenkins
Let’s start Continuous Integration with jenkins
Tomohide Kakeya
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Control
elliando dias
 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
shahidafrith
 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
MahmoudAlnmr1
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08
Sebastian Kurfürst
 
Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
Mahesh Salaria
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
Basma Alkerm
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
Amazon Web Services
 

Similar to CI (20)

Continuous Integration - What even is it?
Continuous Integration - What even is it?Continuous Integration - What even is it?
Continuous Integration - What even is it?
 
Hudson
HudsonHudson
Hudson
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
Continuous Delivery in Practice (extended)
Continuous Delivery in Practice (extended)Continuous Delivery in Practice (extended)
Continuous Delivery in Practice (extended)
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
 
Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
What is dev ops?
What is dev ops?What is dev ops?
What is dev ops?
 
Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applications
 
Continuous delivery in Qbon
Continuous delivery  in QbonContinuous delivery  in Qbon
Continuous delivery in Qbon
 
Announcing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck TalksAnnouncing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck Talks
 
Let’s start Continuous Integration with jenkins
Let’s start Continuous Integration with jenkinsLet’s start Continuous Integration with jenkins
Let’s start Continuous Integration with jenkins
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Control
 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08
 
Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 

CI