CI
-
Upload
patrick-mizer -
Category
Documents
-
view
65 -
download
0
Transcript of CI
Who am I?Patrick MizerChief Architect at SpareFootZCE: PHP4, PHP5, and ZF
[email protected]/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.
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
Continuous something...
Version Control
Deploy to Staging
AutomatedTests
AUTO AUTO
ContinuousIntegration
ContinuousDelivery
ContinuousDeployment
Continuous something...
Version Control
Deploy to Staging
AutomatedTests
Acceptance Tests
Deploy to Production
AUTO AUTO AUTO MANUAL
Version Control
Deploy to Staging
AutomatedTests
AUTO AUTO
ContinuousIntegration
ContinuousDelivery
ContinuousDeployment
Continuous something...
Version Control
Deploy to Staging
AutomatedTests
Acceptance Tests
Deploy to Production
AUTO AUTO AUTO AUTO
Version Control
Deploy to Staging
AutomatedTests
Acceptance Tests
Deploy to Production
AUTO AUTO AUTO MANUAL
Version Control
Deploy to Staging
AutomatedTests
AUTO AUTO
ContinuousIntegration
ContinuousDelivery
ContinuousDeployment
Continuous something...
Version Control
Deploy to Staging
AutomatedTests
Acceptance Tests
Deploy to Production
AUTO AUTO AUTO AUTO
Version Control
Deploy to Staging
AutomatedTests
Acceptance Tests
Deploy to Production
AUTO AUTO AUTO MANUAL
Version Control
Deploy to Staging
AutomatedTests
AUTO AUTO
ContinuousIntegration
ContinuousDelivery
ContinuousDeployment
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.
Finding bugs late is costly
Local
Development
Staging
Production
Developers
QA & Stakeholders
Your Customers
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!”
Poor Quality Codebase
“Who the #$@# is using tabs instead of spaces!?”
“We have 2 classes doing the exact same thing”
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
❏ 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
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.orgJenkins 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
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>
The Integration Machine❏ A reasonable facsimile of production❏ Every commit is built here❏ By yourself? Use Vagrant
Performance - BonusPhantomjs 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 - Bonusphantomjs yslow.js -i grade -threshold "A" -f junit http://staging.sparefoot.com > results.xml
Lessons LearnedBuilding 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.
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