Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Continuous Delivery in Ruby

7,075 views

Published on

The Ruby community has driven a lot of technical innovation in deployment and configuration management over the last few years, and so the idea of delivering high-quality software rapidly should be familiar to most of us. But although our tools are state-of-the-art, getting them to work together properly can be surprisingly frustrating. In this talk, I'll explain how to implement a high-quality rapid build and deploy process using standard CI tools, Bundler, RVM, and Capistrano. I'll also discuss how to coach your developers, QAs, and client to be "production-ready, any time."

Published in: Technology
  • Be the first to comment

Continuous Delivery in Ruby

  1. 1. Continuous Deliveryin RubySrushti Ambekallu Brian Guthrie@srshti @bguthriegithub.com/srushti github.com/bguthrie
  2. 2. Delivering great software
  3. 3. Continuous Integration
  4. 4. 1.Unit and integration tests
  5. 5. RSpec or Test::Unit
  6. 6. Tests of specific units of code Tests of multiple layersTests of external integration points
  7. 7. Receive new commitReset testdatabase schema Run tests Reset test data
  8. 8. Receive new commitReset testdatabase schema Run tests Reset test data
  9. 9. 1.Unit and integration tests2.Automated acceptance tests
  10. 10. Cucumber or the test runner of your choice
  11. 11. Selenium or Sahi Capybara
  12. 12. Receive new commitReset test Run Resetdatabase browser test data schema tests Restart test server
  13. 13. 1.Unit and integration tests2.Automated acceptance tests3.User acceptance tests
  14. 14. type click click click click
  15. 15. type click click click click click click click click click type
  16. 16. type click click click click click click click click click type clickclick click type
  17. 17. type click click click click click click click click click click type click clickclick click type
  18. 18. click type click type click click click click click click click click click click click click type click clickclick click type
  19. 19. click type click type click click click click click click ERROR click click click click click click type click clickclick click type
  20. 20. 1.Unit and integration tests2.Automated acceptance tests3.User acceptance tests
  21. 21. 1.Unit and integration tests2.Automated acceptance tests2a.Deploy3.User acceptance tests
  22. 22. Deployment
  23. 23. Super easy in Ruby(those Java guys are suckers)
  24. 24. $ ssh root@production.com
  25. 25. $ ssh root@production.comprod:~ root# cd /var/www/site
  26. 26. $ ssh root@production.comprod:~ root# cd /var/www/siteprod:~ root# git pull a31a0eb569ba2
  27. 27. $ ssh root@production.comprod:~ root# cd /var/www/siteprod:~ root# git pull a31a0eb569ba2prod:~ root# bundle install
  28. 28. $ ssh root@production.comprod:~ root# cd /var/www/siteprod:~ root# git pull a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrate
  29. 29. $ ssh root@production.comprod:~ root# cd /var/www/siteprod:~ root# git pull a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrateprod:~ root# rake jammit:package
  30. 30. $ ssh root@production.comprod:~ root# cd /var/www/siteprod:~ root# git pull a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrateprod:~ root# rake jammit:packageprod:~ root# touch tmp/restart.txt
  31. 31. $ cap deploy production
  32. 32. Why automate?
  33. 33. Digression: The Rails deploy model
  34. 34. $ ssh root@production.com
  35. 35. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2
  36. 36. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2prod:~ root# ln -s /var/ww/site/current /var/www/site/a31a0eb569ba2
  37. 37. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2prod:~ root# ln -s /var/ww/site/current /var/www/site/a31a0eb569ba2prod:~ root# bundle install
  38. 38. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2prod:~ root# ln -s /var/ww/site/current /var/www/site/a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrate
  39. 39. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2prod:~ root# ln -s /var/ww/site/current /var/www/site/a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrateprod:~ root# rake jammit:package
  40. 40. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2prod:~ root# ln -s /var/ww/site/current /var/www/site/a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrateprod:~ root# rake jammit:packageprod:~ root# touch tmp/restart.txt
  41. 41. $ ssh root@production.comprod:~ root# git clone git@scm/myapp.git /var/www/site/a31a0eb569ba2prod:~ root# ln -s /var/ww/site/current /var/www/site/a31a0eb569ba2prod:~ root# bundle installprod:~ root# rake db:migrateprod:~ root# rake jammit:packageprod:~ root# touch tmp/restart.txt
  42. 42. ci-server:~/app/ $ bundle install --deploymentci-server:~/app/ $ rake jammit:packageci-server:~/app/ $ tar zxvf app-<SHA>.tgz *
  43. 43. RVM
  44. 44. RVMNot for production
  45. 45. $ cat ~/projecta/.rvmrcrvm jruby@projecta$ cat ~/projecta/.rvmrcrvm ree@projectb$ cat ~/projecta/.rvmrcrvm 1.9.1@projectc
  46. 46. Environments
  47. 47. Appserver
  48. 48. Appserver Appserver Appserver
  49. 49. Appserver Background jobs server Appserver Appserver
  50. 50. App server Background jobs server App Load serverbalancer App server
  51. 51. App server Background jobs server App Load serverbalancer App server Background jobs server App server
  52. 52. Chef
  53. 53. ChefPuppet
  54. 54. App server Background jobs server App Load serverbalancer App server Background jobs server App server
  55. 55. ConfigurationManagement App server Background jobs server App Load server balancer App server Background jobs server App server
  56. 56. Peace in the kingdom
  57. 57. How often?
  58. 58. Project Lifecycle faf4d2788f ......................... a433f20abbCode Release Six months
  59. 59. Project Lifecycle faf4d2788f f26115c8c c86c1bfea6 56d1dd8accc4 dd35192f8 1b51fee653a f038af17de4 8318b750aec 192410bd2537 631f5c3f58c 7bcafdd2266 2bbed3e4bd2Code Release Every week (iteration)
  60. 60. Project Lifecycle f26115c8c dd35192f8 f038af17de4 631f5c3f58c 7bcafdd2266Code Release Every day?
  61. 61. Project Lifecycle 7bcafdd2266Code Release Multiple times a day??
  62. 62. Features long in development need branches
  63. 63. Branch by abstraction(“if this feature is enabled, show this link”)<% if feature?(:masala) %> <%= render :partial => "dosas/masala", :locals => { :dosa => @dosas.masala.first } %><% else %> <%= render :partial => "dosas/plain", :locals => { :dosa => @dosas.first } %><% end %>
  64. 64. This doesn’t work for everything: big features, config changes
  65. 65. Branch by source control (“fork me”) http://martinfowler.com/bliki/FeatureBranch.html
  66. 66. The Build Pipeline
  67. 67. “...an automated manifestation of your process for getting software from version control into the hands of your users.” - Jez Humble and David Farley, Continuous Delivery
  68. 68. Unit and Automated ManualIntegration Acceptance Acceptance Production (Woohoo!) Tests Tests Tests
  69. 69. Test Test Test runner runner runner Test runner Unit and Automated ManualIntegration Acceptance Acceptance Production (Woohoo!) Tests Tests Tests
  70. 70. “I see CI as primarily giving birth to a releasecandidate at each commit. The job of the CIsystem and deployment process is to disprovethe production-readiness of a release candidate.This model relies on the need to have somemainline that represents the current shared, mostup to date picture of complete.” - David Farley
  71. 71. Automate until human intervention = decision DEPLOY
  72. 72. Internal External users users Feature User Continuousdevelopment Staging acceptance Production integration Bug fixes testing
  73. 73. Human beings
  74. 74. Real testing is hardLet computers do the simple testing Smart humans for smart testing
  75. 75. Automated testing User testingTraditional projects
  76. 76. Automated testing User testingAgilify!
  77. 77. Agilify!
  78. 78. Questions? Srushti Ambekallu @srshti github.com/srushti Brian Guthrie @bguthrie github.com/bguthrie

×