74
LIGHTNING BRANCHES HOW WE SUPERCHARGE DELIVERY OF FEATURES AT REDMART

Lightning branches at RedMart (Js conf Asia 2014 Talk)

Embed Size (px)

Citation preview

Page 1: Lightning branches at RedMart (Js conf Asia 2014  Talk)

LIGHTNINGBRANCHESHOW WE SUPERCHARGE DELIVERY OF FEATURES AT

REDMART

Page 2: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Hi I’m @ringular work at @Redmartcom#frontend #devops

Page 3: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Getting Code to

Production Fast

Page 4: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Not this talk :(

“No talk all action”

Page 5: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Lesser Meetings

More Productivity

Page 6: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Real World Development

Workflow of a Scaling

Startup

Page 7: Lightning branches at RedMart (Js conf Asia 2014  Talk)

LIGHTNINGBRANCHESHOW WE SUPERCHARGE DELIVERY OF FEATURES AT

REDMART

Page 8: Lightning branches at RedMart (Js conf Asia 2014  Talk)
Page 9: Lightning branches at RedMart (Js conf Asia 2014  Talk)
Page 10: Lightning branches at RedMart (Js conf Asia 2014  Talk)
Page 11: Lightning branches at RedMart (Js conf Asia 2014  Talk)

We just deployed a feature in production in a

matter of minutes

What just happened?

Page 12: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Yes. It was staged..

Page 13: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Yes. It wasn’t really a

feature..

Page 14: Lightning branches at RedMart (Js conf Asia 2014  Talk)

but I’d say..

Page 15: Lightning branches at RedMart (Js conf Asia 2014  Talk)
Page 16: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Specifically Cool for

RedMart

Page 17: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Product Market Fit

Page 18: Lightning branches at RedMart (Js conf Asia 2014  Talk)

BEAR WITH ME

Page 19: Lightning branches at RedMart (Js conf Asia 2014  Talk)

COMPANIES SCALE BRO

Page 20: Lightning branches at RedMart (Js conf Asia 2014  Talk)

COMPANIES SCALE BRO

Page 21: Lightning branches at RedMart (Js conf Asia 2014  Talk)

COMPANIES SCALE BRO

Page 22: Lightning branches at RedMart (Js conf Asia 2014  Talk)

COMPANIES SCALE BRO

Page 23: Lightning branches at RedMart (Js conf Asia 2014  Talk)

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

Page 24: Lightning branches at RedMart (Js conf Asia 2014  Talk)

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

Page 25: Lightning branches at RedMart (Js conf Asia 2014  Talk)

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

Page 26: Lightning branches at RedMart (Js conf Asia 2014  Talk)

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

Page 27: Lightning branches at RedMart (Js conf Asia 2014  Talk)

More Stakeholders

Page 28: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Huddling behind

developers doesn’t scale

Page 29: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Bring your laptop over

every time? Nah

Page 30: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Less Code :(

More Meetings

Page 31: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Einstein’s Mass Energy Equation

E = MC²

Page 32: Lightning branches at RedMart (Js conf Asia 2014  Talk)

E = Environment that developers love

C = Code they write per day

M = Meetings they attend per day

E = C²/M

Page 33: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Recap

Companies Scale

Empower multiple features ( ↑ E )

More Code ( ↑ C )

Communicate in a Snap ( ↓ M )

Page 34: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git flow

Empower multiple

features development

Page 35: Lightning branches at RedMart (Js conf Asia 2014  Talk)

BEAR WITH ME

Page 36: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git Flow - Quick Recap

Master - Official Release History

Release - Combined features

Develop - Integration Branch

Branching Model

Hotfix/ - Bugfixes, based off master branch

Page 37: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git Flow - Quick Recap

Master - Official Release History

Release - Combined features

Develop - Integration Branch

feature/* - Development of Features based off

develop branch

Hotfix/ - Bugfixes, based off master branch

Page 38: Lightning branches at RedMart (Js conf Asia 2014  Talk)

> git flow feature start jsconf

eg. feature/jsconf

Page 39: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git Flow - Quick Recap

Master - Official Release History

Release - Combined features

develop - Integration Branch

feature/* - Development of Features based off

develop branch

Hotfix/ - Bugfixes, based off master branch

Page 40: Lightning branches at RedMart (Js conf Asia 2014  Talk)

> git flow feature finish jsconf

feature/jsconf -> develop

Page 41: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git Flow - Quick Recap

Master - Official Release History

release - Combined features

develop - Integration Branch

feature/* - Development of Features based off

develop branch

Hotfix/ - Bugfixes, based off master branch

Page 42: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git Flow - Quick Recap

master - Official Release History

release - Combined features

develop - Integration Branch

feature/* - Development of Features based off

develop branch

Hotfix/ - Bugfixes, based off master branch

Page 43: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Git Flow - Quick Recap

master - Official Release History

release - Combined features

develop - Integration Branch

feature/* - Development of Features based off

develop branch

Hotfix/ - Bugfixes, based off master branch

Page 44: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Code review

Pull requests

- feature -> develop

- develop -> release

- develop or release -> master

Page 45: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Oath - Thou shalt

Only commit in feature branch

Commit & push often

Merge develop into feature branch everyday

Only merge feature into develop, never master

Only merge pull requests into master

Page 46: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Multiple features ☑

Page 47: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Just having branches

obviously not enough.

Page 48: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Environments

Page 49: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Local

Page 50: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Local

Staging develop or release

Page 51: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Local

Staging develop or release

Production master

Page 52: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Local

Staging develop or release

Production master

Development develop or feature/*

Page 53: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Development *.alpha.redmart.com

develop to

alpha.redmart.com

feature/jsconf to

jsconf.alpha.redmart.com

Page 54: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Deployment

1. Code

2. Push to git

3. Relax

Page 55: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Travis

- Picks up branch (hence environment)

- Runs tests

- Create artifacts

- Transfer artifacts to servers (based on

environment)

- Start application

@ksaitor

Page 56: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Developer

1. Create Artifacts

Push

Build

Fail

Pass

SlackSSH

into

Server

`sh start.sh`3. Get Server

S3 (Artifacts)

2. Upload

5. Start App

4. Transfer Artifacts

Page 57: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Deploy with Git!Don’t mess with the developer workflow

Page 58: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Communication

- New feature

- new channel on slack #jsconf

- builds go to slack

- feature/jsconf get deployed automatically

- eg. jsconf.alpha.redmart.com

Page 59: Lightning branches at RedMart (Js conf Asia 2014  Talk)

COMMUNICATE

WITH CODE

Page 60: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Less Meetings ☑

Page 61: Lightning branches at RedMart (Js conf Asia 2014  Talk)

INVEST INDEVELOP

LIGHTNING BRANCHES ARE IN INVESTMENT IN DEVELOPMENT

ENV

Page 62: Lightning branches at RedMart (Js conf Asia 2014  Talk)

How do we actually

deploy them?

Development develop or feature/*

Page 63: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Nginx

# Feature branches

server {

listen 80;

server_name *.alpha.redmart.com;# serve develop as default feature

set $feature "develop";

...

Page 64: Lightning branches at RedMart (Js conf Asia 2014  Talk)

# change feature based on host

if ($host ~* ^([^.]+)\.alpha\.redmart\.com$){

set $feature $1;

}

# All environments are hosted from a subdirectory

root /path/to/features/$feature;

}

Page 65: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Transfer & unzip artifacts of

‘feature/abc’ to

‘/path/to/features/abc’

Page 66: Lightning branches at RedMart (Js conf Asia 2014  Talk)

It’s that simple? Yes.

Page 67: Lightning branches at RedMart (Js conf Asia 2014  Talk)

It’s that simple? Yes.

Page 68: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Actually there’s more.

Chef - Ruby based

But I value my life.

Page 69: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Thank you LAH.

Page 70: Lightning branches at RedMart (Js conf Asia 2014  Talk)
Page 71: Lightning branches at RedMart (Js conf Asia 2014  Talk)

We’re hiring!

about.redmart.com/careers

Page 72: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Extra

Page 73: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Applications

- Must be environmentally conscious

- Must know start themselves (Just makes it

easier)- ci/start.sh

Page 74: Lightning branches at RedMart (Js conf Asia 2014  Talk)

Developer

1. Create Artifacts

Push

Build

Fail

Pass

Slack SSH

into

Server

Chef Server

`sudo chef-client`

Download

3. Get nodes

S3 (Artifacts)

2. Upload

4. SSH into Node & run

Chef