Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Update Early, Update Often

Juanito Fatas
December 12, 2015

Update Early, Update Often

Keeping your codebase updated is great. Most of the RubyGem authors only interested in bugs from recent versions, newer gems normally come with security fixes, performance improvements. A rails major version upgrade is easier with codebase of newer gems.

This talk is about a good engineering practice, frequent update. Why frequent update and how to do it. How I ended up built a service called deppbot, and some interesting stories from building deppbot.

Juanito Fatas

December 12, 2015
Tweet

More Decks by Juanito Fatas

Other Decks in Technology

Transcript

  1. Update Early
    Update Often
    #RubyKaigi 2015

    View full-size slide

  2. Jolly Good Code
    Juanito Fatas from Taiwan
    ءٝؖه٦ٕ⠓爡

    View full-size slide

  3. WHY!

    FREQUENT UPDATE
    WHY?

    View full-size slide

  4. MAKE FUTURE
    UPGRADE EASIER

    View full-size slide

  5. REDUCE
    TECHNICAL DEBT

    View full-size slide

  6. MAINTAINER
    LOVE NEW BUGS

    View full-size slide

  7. DEVELOPERS
    DISLIKE LEGACY

    View full-size slide

  8. PERFORMANCE
    IMPROVEMENTS

    View full-size slide

  9. SECURITY
    VULNERABILITY

    View full-size slide

  10. LEARN FROM
    GEM UPDATES

    View full-size slide

  11. SHIP LATEST
    SOFTWARE
    https://jollygoodcode.github.io/2015/09/03/the-birth-of-deppbot.html

    View full-size slide

  12. HOWTO
    bundle-update(1)
    Quick Demo

    View full-size slide

  13. $ git checkout
    master

    View full-size slide

  14. $ git checkout -b
    bundle-update-2015-12-12

    View full-size slide

  15. $ bundle updaet

    View full-size slide

  16. Could not find
    command
    "updaet"

    View full-size slide

  17. $ bundle update

    View full-size slide

  18. $ git add Gemfile.lock

    View full-size slide

  19. $ git comit -m
    "Bundle Update 2015-12-12"

    View full-size slide

  20. git: 'comit' is not a git
    command. See 'git --help'.
    Did you mean this?
    commit

    View full-size slide

  21. $ git commit -m
    "Bundle Update 2015-12-12"

    View full-size slide

  22. $ git pull-request -m
    "Bundle Update 2015-12-12"
    git pull-request command is from github.com/github/hub

    View full-size slide

  23. ~ 10 minutes

    View full-size slide

  24. 7200
    per hour
    Juanito Fatas

    View full-size slide

  25. 7200*10/60
    ~= 1200 ¥

    View full-size slide

  26. 3.times a month,
    1200*3 = 3600¥

    View full-size slide

  27. 3600 ¥
    蔦拉麵
    900¥





    View full-size slide

  28. May I use
    tachikoma.io?

    View full-size slide

  29. Sure What is it?

    View full-size slide

  30. A service which
    runs bundle update
    automatically.

    View full-size slide

  31. Sounds good. Can
    try, can try.

    View full-size slide

  32. But...
    It only costs a
    little, $49/month.

    View full-size slide

  33. Hmm...

    Can’t you write
    a simple script
    that does that?

    View full-size slide

  34. today = Time.current.strftime("%F")
    new_branch = "bundle-update-#{today}"
    `git checkout master`
    `git pull`
    `git checkout -b #{new_branch}`
    `bundle update`
    `git push origin #{new_branch}`
    `git pull-request -m "Bundle Update
    #{today}"
    script 'depbot'

    View full-size slide

  35. Works except I need
    to run 'depbot'
    from time to time

    View full-size slide

  36. Then I am busy

    View full-size slide

  37. No bundle updates

    View full-size slide

  38. Could you make
    a cronjob that
    runs every day?

    View full-size slide

  39. How about make
    it a service?

    View full-size slide

  40. Sure, do it.

    View full-size slide

  41. From Script
    to Rails app

    View full-size slide

  42. GitHub Org. API
    deppbot will send a Pull Request like a human

    View full-size slide

  43. git clone

    works for project hosts on bitbucket, submodules too

    View full-size slide

  44. bundle update

    Updates Gemfile.lock and install gems

    View full-size slide

  45. TravisCI?
    Not all kinds of gems can be installed on a single VPS

    View full-size slide

  46. bundle lock --update

    Updates Gemfile.lock without installing
    This command re-introduced in bundler v1.10 #3439

    View full-size slide

  47. diff -u

    "BUNDLED WITH" will be preserved

    View full-size slide

  48. Delete Repo on VPS

    immediately when we got the diff

    View full-size slide

  49. Cook Pull Request

    gem links, compare views, changelogs, time savings

    View full-size slide

  50. Pull Request
    &YBN
    QMF

    View full-size slide

  51. nokogiri

    Query RubyGems.org API
    Gem authors, please fill in your metadata

    View full-size slide

  52. 1.6.6.4…1.6.7

    Parse diff and link_to repository compare view for code review
    Gem authors, please push your tags when release a gem

    View full-size slide

  53. CHANGELOG

    Query GitHub API, jollygoodcode/whatsnew
    Don’t let your friends dump git logs into CHANGELOGs

    View full-size slide

  54. Time Savings

    Sum every Pull Request processed time

    View full-size slide

  55. Update Early

    View full-size slide

  56. Update Often

    View full-size slide

  57. "Continuous Updates"

    View full-size slide

  58. https://www.deppbot.com
    1108
    Pull Requests Sent
    94
    hours
    Engineering Time Saved

    View full-size slide

  59. WHAT’S NEXT?

    View full-size slide

  60. "Automated Security
    Updates"
    Powered by Bundler Audit

    View full-size slide

  61. hor hor hor
    Christmas
    '

    View full-size slide

  62. Any Questions
    Any Suggestions
    )

    View full-size slide

  63. Please come talk
    to me or

    View full-size slide

  64. I have stickers

    View full-size slide