Download - 2013 09 drupalcamp leuven deployments en workflow

Transcript
Page 1: 2013 09 drupalcamp leuven deployments en workflow

Deployments & workflow

Frederik Wouters

Page 2: 2013 09 drupalcamp leuven deployments en workflow

Who am I

Page 3: 2013 09 drupalcamp leuven deployments en workflow

Frederik Wouters

• Drupal user profile since 2010• Create issues/patches on d.o. • Freelance Drupal 6/7• Working for Q-music at the moment

Page 4: 2013 09 drupalcamp leuven deployments en workflow

Agenda

- Working alone- Working in a small team- Working in a large team- Releases and Deployments- Workflow models

Page 5: 2013 09 drupalcamp leuven deployments en workflow

IF YOU ARE ALONEIt’s just you and the server

Page 6: 2013 09 drupalcamp leuven deployments en workflow

FTPSSH…

Page 7: 2013 09 drupalcamp leuven deployments en workflow

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?

Page 8: 2013 09 drupalcamp leuven deployments en workflow

Working in a small team?

Page 9: 2013 09 drupalcamp leuven deployments en workflow

Some teams

FTPSSH…

DEV

DEV

DEV

Page 10: 2013 09 drupalcamp leuven deployments en workflow

Client want changes

• Get code from ftp• Make changes• Upload

• It’s not complicated• No overhead• If feels good• Always up to date

Page 11: 2013 09 drupalcamp leuven deployments en workflow

CODE IS LOSTYou knew it was coming

Page 12: 2013 09 drupalcamp leuven deployments en workflow

HELLO VCS

FTP / SSH / …

DEV

DEV

LEAD

Page 13: 2013 09 drupalcamp leuven deployments en workflow

Client want changes

• Check out latest version• Make changes to master• Commit • Deployer deploys

Page 14: 2013 09 drupalcamp leuven deployments en workflow

MULTIPLE DEVELOPERSNo problem

Page 15: 2013 09 drupalcamp leuven deployments en workflow

TL;DR

Prepare for scaling, even if you’re aloneUse git

Page 16: 2013 09 drupalcamp leuven deployments en workflow

Working in a bigger team

Page 17: 2013 09 drupalcamp leuven deployments en workflow

Assume

• Production / Acceptance / Dev environment• Code is tested before Acceptance• Multiple people are working on several

features at the same time.

Page 18: 2013 09 drupalcamp leuven deployments en workflow

Concept: BRANCHES

Page 19: 2013 09 drupalcamp leuven deployments en workflow

Client want changes

Hotfix• Check out acc/prd• Make changes• Commit

• checkout dev/acc• Cherry pick• Commit

Feature• Check out dev• Make changes• Commit

Page 20: 2013 09 drupalcamp leuven deployments en workflow

HOW TO IMPROVE

• Deployment• Workflow

Page 21: 2013 09 drupalcamp leuven deployments en workflow

DEPLOYMENT

Page 22: 2013 09 drupalcamp leuven deployments en workflow

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

Page 23: 2013 09 drupalcamp leuven deployments en workflow

DEPLOYING TO PRODUCTIONI merged branches

Page 24: 2013 09 drupalcamp leuven deployments en workflow

Automate deployments

No matter what your workflow is, you will always profit from automatic deployments

Frederik Wouters

Page 25: 2013 09 drupalcamp leuven deployments en workflow

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

Page 26: 2013 09 drupalcamp leuven deployments en workflow
Page 27: 2013 09 drupalcamp leuven deployments en workflow
Page 28: 2013 09 drupalcamp leuven deployments en workflow
Page 29: 2013 09 drupalcamp leuven deployments en workflow

Commit based deployment

• Github• Bitbucket

Committing will trigger a build of a specific branch to a specific environment.

https://github.com/wieni/jenbucket

Page 30: 2013 09 drupalcamp leuven deployments en workflow

How to set it up?

Github/bitbucket hook:• Github:

Page 31: 2013 09 drupalcamp leuven deployments en workflow

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– ….

Page 32: 2013 09 drupalcamp leuven deployments en workflow

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…

Page 33: 2013 09 drupalcamp leuven deployments en workflow

Config + deploy demo

• LIVE DEMO

Page 35: 2013 09 drupalcamp leuven deployments en workflow

I COMMITTED MY CODEIt’s on dev, because it’s good

Page 36: 2013 09 drupalcamp leuven deployments en workflow

WORKFLOW

Page 37: 2013 09 drupalcamp leuven deployments en 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

Page 38: 2013 09 drupalcamp leuven deployments en workflow

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)

Page 39: 2013 09 drupalcamp leuven deployments en workflow

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

Page 40: 2013 09 drupalcamp leuven deployments en workflow

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

Page 41: 2013 09 drupalcamp leuven deployments en workflow

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

Page 42: 2013 09 drupalcamp leuven deployments en workflow
Page 43: 2013 09 drupalcamp leuven deployments en workflow

What worked for my bigger projects

• Using jenkins• scrum• Working in sprint branches• Client tests --a lot--

Page 44: 2013 09 drupalcamp leuven deployments en workflow

What works for you?

• Small team, small changes, commit often, release often

• Big Team, big Features… Consider a x days sprint and release branches.

• …

Page 45: 2013 09 drupalcamp leuven deployments en workflow

TL;DR

Deploy without user interactionFind a workflow that suits your project

Prepare for scaling

Page 46: 2013 09 drupalcamp leuven deployments en workflow

Graphicshttp://nvie.com/posts/a-successful-git-branching-model/

Chuck Norris and friends

Page 47: 2013 09 drupalcamp leuven deployments en workflow

Contact me

@drupal_sensei

[email protected]