Lightning branches at RedMart (Js conf Asia 2014 Talk)

Preview:

Citation preview

LIGHTNINGBRANCHESHOW WE SUPERCHARGE DELIVERY OF FEATURES AT

REDMART

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

Getting Code to

Production Fast

Not this talk :(

“No talk all action”

Lesser Meetings

More Productivity

Real World Development

Workflow of a Scaling

Startup

LIGHTNINGBRANCHESHOW WE SUPERCHARGE DELIVERY OF FEATURES AT

REDMART

We just deployed a feature in production in a

matter of minutes

What just happened?

Yes. It was staged..

Yes. It wasn’t really a

feature..

but I’d say..

Specifically Cool for

RedMart

Product Market Fit

BEAR WITH ME

COMPANIES SCALE BRO

COMPANIES SCALE BRO

COMPANIES SCALE BRO

COMPANIES SCALE BRO

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

More Developers working

on More Features at the

Same Time which results

in lots of Merge Hells

More Stakeholders

Huddling behind

developers doesn’t scale

Bring your laptop over

every time? Nah

Less Code :(

More Meetings

Einstein’s Mass Energy Equation

E = MC²

E = Environment that developers love

C = Code they write per day

M = Meetings they attend per day

E = C²/M

Recap

Companies Scale

Empower multiple features ( ↑ E )

More Code ( ↑ C )

Communicate in a Snap ( ↓ M )

Git flow

Empower multiple

features development

BEAR WITH ME

Git Flow - Quick Recap

Master - Official Release History

Release - Combined features

Develop - Integration Branch

Branching Model

Hotfix/ - Bugfixes, based off master branch

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

> git flow feature start jsconf

eg. feature/jsconf

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

> git flow feature finish jsconf

feature/jsconf -> develop

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

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

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

Code review

Pull requests

- feature -> develop

- develop -> release

- develop or release -> master

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

Multiple features ☑

Just having branches

obviously not enough.

Environments

Local

Local

Staging develop or release

Local

Staging develop or release

Production master

Local

Staging develop or release

Production master

Development develop or feature/*

Development *.alpha.redmart.com

develop to

alpha.redmart.com

feature/jsconf to

jsconf.alpha.redmart.com

Deployment

1. Code

2. Push to git

3. Relax

Travis

- Picks up branch (hence environment)

- Runs tests

- Create artifacts

- Transfer artifacts to servers (based on

environment)

- Start application

@ksaitor

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

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

Communication

- New feature

- new channel on slack #jsconf

- builds go to slack

- feature/jsconf get deployed automatically

- eg. jsconf.alpha.redmart.com

COMMUNICATE

WITH CODE

Less Meetings ☑

INVEST INDEVELOP

LIGHTNING BRANCHES ARE IN INVESTMENT IN DEVELOPMENT

ENV

How do we actually

deploy them?

Development develop or feature/*

Nginx

# Feature branches

server {

listen 80;

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

set $feature "develop";

...

# 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;

}

Transfer & unzip artifacts of

‘feature/abc’ to

‘/path/to/features/abc’

It’s that simple? Yes.

It’s that simple? Yes.

Actually there’s more.

Chef - Ruby based

But I value my life.

Thank you LAH.

We’re hiring!

about.redmart.com/careers

Extra

Applications

- Must be environmentally conscious

- Must know start themselves (Just makes it

easier)- ci/start.sh

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