51
Strong Practices for Rails Applications Continuous Delivery

Strong practices for rails applications continuous delivery

Embed Size (px)

Citation preview

Strong Practices for Rails Applications Continuous Delivery

Robb Kidd | Developer, Community Engineering | [email protected] | @robbkiddNathan Smith | Developer, Core Engineering | [email protected] | @nlsmith

Robb Kidd

• Developer, Community Engineering at Chef• @robbkidd | [email protected]

Nathan Smith• Developer, Core Engineering at Chef• @nlsmith | [email protected]

Quality and innovation, historically a tradeoffQ

UALIT

Y/C

OM

PLIA

NC

E

RATE OF INNOVATION

Challenges

Manual processesWeeks to setup new systems or software

Legacy systems and toolsInflexible, hard-to-change hardware and software

Organizational silosUnwieldy divisions of responsibility

Infrequent, large releasesFear of deployment due to risk to SLAs

Regulatory burdensCompliance bottleneck at the end of a project

Idea Value

æ

S

ƴ

Ä

Nj

Manual processesWeeks to setup new systems or software

Legacy systems and toolsInflexible, hard-to-change hardware and software

Organizational silosUnwieldy divisions of responsibility

Regulatory burdensCompliance bottleneck at the end of a project

Infrequent, large releasesFear of deployment due to risk to SLAs

AutomationNew systems and software updates deployed in minutes

Solutions to the challenges

Idea Value

æ

S

ƴ

Ä

Nj

Manual processesWeeks to setup new systems or software

Legacy systems and toolsInflexible, hard-to-change hardware and software

Organizational silosUnwieldy divisions of responsibility

Regulatory burdensCompliance bottleneck at the end of a project

Infrequent, large releasesFear of deployment due to risk to SLAs

Dynamic infrastructureEasy migration to on-demand, cloud-based infrastructure and management of heterogeneous networks

AutomationNew systems and software updates deployed in minutes

Solutions to the challenges

Idea Value

æ

S

ƴ

Ä

Nj

Manual processesWeeks to setup new systems or software

Legacy systems and toolsInflexible, hard-to-change hardware and software

Organizational silosUnwieldy divisions of responsibility

Regulatory burdensCompliance bottleneck at the end of a project

Infrequent, large releasesFear of deployment due to risk to SLAs

Increased cooperation and trustTeams are aligned towards common goals

Dynamic infrastructureEasy migration to on-demand, cloud-based infrastructure and management of heterogeneous networks

AutomationNew systems and software updates deployed in minutes

Solutions to the challenges

Idea Value

æ

S

ƴ

Ä

Nj

Manual processesWeeks to setup new systems or software

Legacy systems and toolsInflexible, hard-to-change hardware and software

Organizational silosUnwieldy divisions of responsibility

Regulatory burdensCompliance bottleneck at the end of a project

Infrequent, large releasesFear of deployment due to risk to SLAs

Increased cooperation and trustTeams are aligned towards common goals

Dynamic infrastructureEasy migration to on-demand, cloud-based infrastructure and management of heterogeneous networks

AutomationNew systems and software updates deployed in minutes

Solutions to the challenges

Continuous delivery of infrastructure and applicationsSafe, rapid delivery of incremental value

Idea Value

æ

S

ƴ

Ä

Nj

Manual processesWeeks to setup new systems or software

Legacy systems and toolsInflexible, hard-to-change hardware and software

Organizational silosUnwieldy divisions of responsibility

Regulatory burdensCompliance bottleneck at the end of a project

Infrequent, large releasesFear of deployment due to risk to SLAs

Compliance at velocity Integration of compliance into the workflow using automated tests

Increased cooperation and trustTeams are aligned towards common goals

Dynamic infrastructureEasy migration to on-demand, cloud-based infrastructure and management of heterogeneous networks

AutomationNew systems and software updates deployed in minutes

Continuous delivery of infrastructure and applicationsSafe, rapid delivery of incremental value

Solutions to the challenges

The game changer: rapid time to value

Innovation

Quality/Compliance

DynamicInfrastructure

Infrastructure as CodeAutomate the Stack

DevOps

+ +

DEVOPSA cultural and professional movement, focused on how we build and operate high velocity organizations, born from the experiences of its practitioners.

PEOPLE

PRODUCTS

COMPANIES

DIVERSITY

WE ARE LEAN• Eliminate non-value-added action (Waste/Muda)• Pull over Push• Kaizen (Continuous Improvement)• Kaikaku (Disruptive Change)• Small Batch + Experimentation

UBIQUITOUS WORKFLOW

AUTOMATION

The rewards?*

*source: Dr. Nicole Forsgren research on DevOps

More deployments

Ship faster

Faster MTTR after issues

More profits, market share, and productivity

Market cap goes up

MANAGE RISK

• Small batches, near term hypothesis• Validation comes from customers• Introduce near-term volatility to gain decreased

long-term risk

CONTINUOUS INTEGRATION

• Always integrate branches to master• They should be short lived, iterative branches• Fix the build when it goes red

THE FOUR-EYE RULE

WRITE TESTS

• Unit test (a single function)• Integration tests (multiple classes/units)• Functional tests (user-oriented, high-level, full

stack)• Smoke tests (quickly determine if the system is

“working”)

ONE PATH FOR CHANGE

• The way change moves through your organization is fixed

• Designed to re-enforce your principles and aid flow

• Flexible at the level of execution

Testing a Rails app – Lint?

Rubocop

Testing a Rails app – Syntax?

Also, Rubocop

Testing a Rails app – Unit?

RSpec

Testing a Rails app – Security?

Bundler Audit & Brakeman

Testing a Rails app – Quality?

Maintain a Baseline measure with …Code Climate?

Flay/Flog?

Chef Provides a Proven Approach to DevOps

...

...

...

Targets/Workloads

Collaborative Dev Production

Chef Server

Chef Server

Chef Supermarket

Assessment

Chef Compliance

� Search

^ Audit

Ǘ Discover

Deploy

Chef Delivery

Local Dev

ê Model

ƨ Build

¿ Test

Chef DK

Chef Client & Cookbooks

Chef Provides a Proven Approach to DevOpsCollaborative DevAssessment

Deploy

Chef Delivery

Local Dev

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

SubmitChange

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SubmitChange

Rails App - Lint

execute 'bundle exec rubocop' docwd delivery_workspace_repoenvironment({"PATH" => '/usr/local/bin:/usr/bin:/bin',"GEM_HOME" => node[’fronty']['gem_cache']

})user node['delivery']['workspace']['build_user']

end

Rails App - Unit

execute 'bundle exec rake spec' docwd delivery_workspace_repoenvironment({"PATH" => '/usr/local/bin:/usr/bin:/bin',"GEM_HOME" => node[’fronty']['gem_cache']

})user node['delivery']['workspace']['build_user']

end

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SubmitChange

Does thiscode changelook good?

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SecurityQualityPublish

LintSyntaxUnit

SubmitChange

Does thiscode changelook good?

Delivering a Rails app – Publish?

Build a release artifact that isas complete as possible.

Delivering a Rails app – Publish?

bundle packagerake assets:precompile } tar czvf app_version.tar.gz

Delivering a Rails app – Publish?app_version.tar.gz

Heroku source API

Heroku build API

Heroku slug

Delivering a Rails app – Publish?app_version.tar.gz

source_escrow = heroku.source.create(heroku_build_app)

escrow_upload = Excon.new(source_escrow['source_blob']['put_url'])escrow_upload.put(body: open(tarball).read)

build = heroku.build.create(...)

build_result = heroku.build.info(heroku_build_app, build['id'])

heroku_slug_id = build_result['slug']['id']

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SecurityQualityPublish

LintSyntaxUnit

ProvisionDeploySmoke

Functional

SubmitChange

Does thiscode changelook good?

Delivering a Rails app – Provision & Deploy

Provision:

app_name = 'project_#{stage}'heroku_app = heroku.app.create(

name: app_name,region: 'us',stack: 'cedar-14’

)

Deploy:

release = heroku.release.create(heroku_app['name'], slug: heroku_slug_id

)

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SecurityQualityPublish

LintSyntaxUnit

ProvisionDeploySmoke

Functional

SubmitChange

Does thiscode changelook good?

Do we wantto ship this?

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SecurityQualityPublish

LintSyntaxUnit

ProvisionDeploySmoke

Functional

ProvisionDeploySmoke

Functional

SubmitChange

Does thiscode changelook good?

Do we wantto ship this?

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SecurityQualityPublish

LintSyntaxUnit

ProvisionDeploySmoke

Functional

ProvisionDeploySmoke

Functional

ProvisionDeploySmoke

Functional

SubmitChange

Does thiscode changelook good?

Do we wantto ship this?

Unified Pipeline Shape

The stages are fixed, and each stage has a fixed set of phases

APPROVE DELIVER

LintSyntaxUnit

SecurityQualityPublish

LintSyntaxUnit

ProvisionDeploySmoke

Functional

ProvisionDeploySmoke

Functional

ProvisionDeploySmoke

Functional

ProvisionDeploySmoke

Functional

SubmitChange

Does thiscode changelook good?

Do we wantto ship this?

What questions can we answer for you?

1500 Attendees! 55+ Speakers! Registration Open! Community Celebration!CHEFCONF 2016 AT A GLANCE

Workshops & Chef Training

Community Summit

Partner Summit

Welcome Reception

Keynotes

Technical Sessions

Happy Hour

Keynotes

Technical Sessions

Awesome Chef Awards

Community Celebration

DAY 1 // JULY 11 DAY 2 // JULY 12 DAY 3 // JULY 13

THREE DAYS OF OPPORTUNITY TO ENGAGE THE CHEF CUSTOMERS AND PARTNER ECOSYSTEM

chefconf.chef.io

DAY 1 // JULY 11« Workshops & Chef Training

« Community Summit

« Par tner Summit

« Welcome Reception

DAY 2 // JULY 12« Keynotes

« Technical Sessions

« Happy Hour

DAY 3 // JULY 13« Keynotes

« Technical Sessions

« Awesome Chef Awards

« Community Celebration

THREE DAYS OF OPPORTUNITY TO ENGAGE THE CHEF CUSTOMERS AND PARTNER ECOSYSTEM

Robb Kidd

• Developer, Community Engineering at Chef• @robbkidd | [email protected]

Nathan Smith• Developer, Core Engineering at Chef• @nlsmith | [email protected]