Post on 22-Oct-2014
description
Deployments & workflow
Frederik Wouters
Who am I
Frederik Wouters
• Drupal user profile since 2010• Create issues/patches on d.o. • Freelance Drupal 6/7• Working for Q-music at the moment
Agenda
- Working alone- Working in a small team- Working in a large team- Releases and Deployments- Workflow models
IF YOU ARE ALONEIt’s just you and the server
FTPSSH…
Client wants a change
• Look at code• Make change• Upload Code
• It’s not complicated• No overhead• If feels good• Always up to date
What can go wrong?
Working in a small team?
Some teams
FTPSSH…
DEV
DEV
DEV
Client want changes
• Get code from ftp• Make changes• Upload
• It’s not complicated• No overhead• If feels good• Always up to date
CODE IS LOSTYou knew it was coming
HELLO VCS
FTP / SSH / …
DEV
DEV
LEAD
Client want changes
• Check out latest version• Make changes to master• Commit • Deployer deploys
MULTIPLE DEVELOPERSNo problem
TL;DR
Prepare for scaling, even if you’re aloneUse git
Working in a bigger team
Assume
• Production / Acceptance / Dev environment• Code is tested before Acceptance• Multiple people are working on several
features at the same time.
Concept: BRANCHES
Client want changes
Hotfix• Check out acc/prd• Make changes• Commit
• checkout dev/acc• Cherry pick• Commit
Feature• Check out dev• Make changes• Commit
HOW TO IMPROVE
• Deployment• Workflow
DEPLOYMENT
How do the big fish deploy?
FacebookCode is compiled to one big executableThis blob is deployed with bittorrent
Twitter“Murder” (Capistrano + optimised
bittorrent)
GoogleYADT : yaml datacenter management
DEPLOYING TO PRODUCTIONI merged branches
Automate deployments
No matter what your workflow is, you will always profit from automatic deployments
Frederik Wouters
Automate deployments
• Jenkins – Open source (dev’s love it)– A lot of components
• Capistrano– Open source (Ruby devs love it)– Command line
• Bamboo– Integrated with Jira (PM’s love it)– Nice issue tracking and all
Commit based deployment
• Github• Bitbucket
Committing will trigger a build of a specific branch to a specific environment.
https://github.com/wieni/jenbucket
How to set it up?
Github/bitbucket hook:• Github:
How to set it up?• Apt-get install jenkins• Install some plugins
– ftp publisher– Ssh publisher– Ssh credentials– Git client– Google calendar– Html5 notifier– Jquery– Mailer– Subversion– Workspace cleanup– ….
How to set it up?
Job conf:• Enter your git repo• Add build config – Build a tarball from codebase– Ssh publish the code– Create DB dump before– Symlink of files directory between deployments– Save a copy of prev codebase (just in case)– Drush updb, cc , fra , dis devel etc…
Config + deploy demo
• LIVE DEMO
Commit based deployment
• What is my current version?• Bitbucket
Provide a page where you can put your jenkins url. Committing will then trigger a build of a specific Job.
https://drupal.org/sandbox/wouters_frederik/1979636
I COMMITTED MY CODEIt’s on dev, because it’s good
WORKFLOW
• Waterfall
– Conception– Initiation– Analysis– Design– Construction– Testing– Implementation– Maintenance
• Scrum – Agile
– Sprint Backlog– 30 days sprint– Test– Release– Repeat
• CI
– Build test self– Commit to base– Build fast– Build + Test
every commit
Overview
Advantages• Waterfall
– Deliverables for every Phase
– Complete 1 thing at a time
• Scrum – Agile
– Rapid delivery– Changes in
requirements are ok– 30 days of awesome
• CI
– Early warnings of broken code
– Immediate testing of all changes
– Write less complex code (frequent checkins)
Implementation• Waterfall
– Work on master branch for entire project.
• Scrum – Agile
– Production branch– Hotfixes – Dev branch per
Release of 30 days.
• CI
– Commit to master– Write code with
feature toggles– Each change must be
testeable / releasable
How do the big fish do it?Facebook
Moving fast and breaking thingsMajor deploy every TuesdayTwo minor deploys every dayConflicts are to be sold by Tuesday 12.00
TwitterEach feature/bugfix lives in its branch, branches are selected for deploy, tested and
merged. This gives more merge conflicts.
GoogleThe release goes out on time. If a feature isn't
ready, it just gets moved to the next release. Features that are not ready can be disabled (hidden)
Everyone works most of the time on one main branch
CI is hot
Be sure to• Automate the build• Make your build self testing• Commit to the main line every day• Every commit should build to dev• Keep the build fast• Test a clone of production
What worked for my bigger projects
• Using jenkins• scrum• Working in sprint branches• Client tests --a lot--
What works for you?
• Small team, small changes, commit often, release often
• Big Team, big Features… Consider a x days sprint and release branches.
• …
TL;DR
Deploy without user interactionFind a workflow that suits your project
Prepare for scaling
Graphicshttp://nvie.com/posts/a-successful-git-branching-model/
Chuck Norris and friends