SlideShare uma empresa Scribd logo
1 de 86
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Engineering Design Notes
Engineering Design NotesEngineering Design Notes
Engineering Design NotesSead Spuzic
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Auto cad introduction
Auto cad introductionAuto cad introduction
Auto cad introductionqarni888
 
Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...
Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...
Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...Radoslaw Smilgin
 
Design For Assembly- Machining COnsideration
Design For Assembly- Machining COnsiderationDesign For Assembly- Machining COnsideration
Design For Assembly- Machining COnsiderationaman1312
 
Designing of economical medical bed
Designing of economical medical bedDesigning of economical medical bed
Designing of economical medical bedGaurav Yadav
 
Тестування ПЗ
Тестування ПЗТестування ПЗ
Тестування ПЗKyrylo Bezpalyi
 
Effective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentEffective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentRaj Indugula
 
Solidworks training report
Solidworks training reportSolidworks training report
Solidworks training reportPawan Kumar
 
Auto cad ppt
Auto cad pptAuto cad ppt
Auto cad pptALOK RAJ
 
Unit Test Presentation
Unit Test PresentationUnit Test Presentation
Unit Test PresentationSayedur Rahman
 
Design for assembly methods
Design for assembly methodsDesign for assembly methods
Design for assembly methodsaman1312
 
Introduction to CAD CAM in industries
Introduction to CAD CAM in industriesIntroduction to CAD CAM in industries
Introduction to CAD CAM in industriesAshish Khudaiwala
 

Mais procurados (20)

Engineering Design Notes
Engineering Design NotesEngineering Design Notes
Engineering Design Notes
 
Kaizen çalışmaları
Kaizen çalışmaları Kaizen çalışmaları
Kaizen çalışmaları
 
Cross browser testing
Cross browser testingCross browser testing
Cross browser testing
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Auto cad introduction
Auto cad introductionAuto cad introduction
Auto cad introduction
 
Lean manufacturing
Lean manufacturingLean manufacturing
Lean manufacturing
 
Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...
Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...
Statement Testing and Statement Coverage. ISTQB whitebox techniques with Test...
 
Autocad presentation
Autocad presentationAutocad presentation
Autocad presentation
 
Design For Assembly- Machining COnsideration
Design For Assembly- Machining COnsiderationDesign For Assembly- Machining COnsideration
Design For Assembly- Machining COnsideration
 
Designing of economical medical bed
Designing of economical medical bedDesigning of economical medical bed
Designing of economical medical bed
 
Can Crusher
Can CrusherCan Crusher
Can Crusher
 
Тестування ПЗ
Тестування ПЗТестування ПЗ
Тестування ПЗ
 
Effective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile EnvironmentEffective Testing Practices in an Agile Environment
Effective Testing Practices in an Agile Environment
 
Solidworks training report
Solidworks training reportSolidworks training report
Solidworks training report
 
Auto cad ppt
Auto cad pptAuto cad ppt
Auto cad ppt
 
Unit Test Presentation
Unit Test PresentationUnit Test Presentation
Unit Test Presentation
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Design for assembly methods
Design for assembly methodsDesign for assembly methods
Design for assembly methods
 
Introduction to CAD CAM in industries
Introduction to CAD CAM in industriesIntroduction to CAD CAM in industries
Introduction to CAD CAM in industries
 

Semelhante a 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
Hudson8x8
 
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 VariaAmazon 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 CodeKris Buytaert
 
Software engineering
Software engineeringSoftware engineering
Software engineeringbartlowe
 
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 applicationsSunil Dalal
 
Continuous delivery in Qbon
Continuous delivery  in QbonContinuous delivery  in Qbon
Continuous delivery in QbonJaric 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 TalksAmazon 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 jenkinsTomohide Kakeya
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Controlelliando dias
 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdfMahmoudAlnmr1
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08Sebastian Kurfürst
 
Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and AutomationMahesh Salaria
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationBasma 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 ToolsAmazon Web Services
 

Semelhante a 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_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.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