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

How to git bisect ruby/ruby repository

How to git bisect ruby/ruby repository

Yasuo Honda

April 17, 2020
Tweet

More Decks by Yasuo Honda

Other Decks in Technology

Transcript

  1. “git bisect”ͱ͸ • ೋ෼୳ࡧ • ϑΝΠϧͷ஫هΛ࢖͑͹ɺͦͷ໰୊͕Ͳͷ࣌఺Ͱ࢝·ͬͨͷ͔Λ஌Δ͜ͱ͕ Ͱ͖·͢ɻ Կ͕͓͔͘͠ͳͬͨͷ͔͕Θ͔Βͣɺ࠷ޙʹ͏·͘ಈ࡞͍ͯͨ͠ ͱ͖͔ΒԿेԿඦ΋ͷίϛοτ͕ߦΘΕ͍ͯΔ৔߹ͳͲ͸ɺgit bisect

    ʹཔ Δ͜ͱʹͳΔͰ͠ΐ͏ɻ bisect ίϚϯυ͸ίϛοτͷྺ࢙ʹରͯ͠ೋ෼୳ ࡧΛߦ͍ɺͲͷίϛοτͰ໰୊͕ࠞೖͨ͠ͷ͔ΛՄೳͳݶΓखૣ͘ݟ͚ͭ ग़ͤΔΑ͏ʹ͠·͢ɻ • https://git-scm.com/book/ja/v2/Git-ͷ͞·͟·ͳπʔϧ-Git-ʹΑΔσόοά
  2. Rails CIͱRubyόʔδϣϯ • Buildkite : https://buildkite.com/rails/rails Ͱ࣮ߦ͞Ε͍ͯΔ • Ruby 2.5,

    2.6, 2.7ͱ2.8.0devʹରͯ͠Railsͷ֤commit/PRʹCI͕૸Δ • Ruby 2.5, 2.6, 2.7 - failͨ͠ΒBuild͕redʹͳΔ • Ruby 2.8.0-dev - failͯ͠΋Build͸greenͰ͋Δ(Travis CIͷAllowed FailuresͷΑ͏ͳ΋ͷ)
  3. Ruby DockerΠϝʔδ • https://hub.docker.com/_/ruby • Rails CIͰ͸ɺRuby 2.5, 2.6, 2.7Λར༻

    • https://hub.docker.com/r/rubylang/ruby/ • Rails CIͰ͸ɺrubylang/ruby:master-nightly-bionic Λ2.8.0devͰར༻ • Ұ೔Ұճߋ৽͞ΕΔ • https://hub.docker.com/r/rubylang/rubyfarm/ • Ruby r57410͔Βͷ͢΂ͯͷcommit͝ͱͷDockerΠϝʔδ͕͋Δ • https://www.slideshare.net/znzjp/dockerruby ࢀর
  4. Ruby 2.8.0devͰͷΈredʹͳ͍ͬͯΔRails CI • guides (master) • https://bugs.ruby-lang.org/issues/14183 "Real" keyword

    argument ରԠ / Rails 6.0.3ϦϦʔε·ͪ • railties (master) • https://bugs.ruby-lang.org/issues/14183 "Real" keyword argument ରԠ / sprocketsͱsprockets-rails ϦϦʔε·ͪ • actionview(master) • https://bugs.ruby-lang.org/issues/16669 ͕मਖ਼͞ΕΕ͹greenʹͳΔ͸ͣ • actionpack(master) • ຊ೔࿩͢಺༰
  5. Rails CIΛϩʔΧϧͰ࣮ߦ͢Δ • Install Docker on your PC • %

    git clone https://github.com/rails/rails • % cd rails ; git clone https://github.com/rails/buildkite-config .buildkite/ • % RUBY_IMAGE=rubylang/ruby:master-nightly-bionic docker-compose -f .buildkite/docker-compose.yml build base && CI=1 docker-compose -f .buildkite/docker-compose.yml run default runner actionpack 'rake test'
  6. RubyͷίϛοτΛݟ͚ͭΔ(1) • ࠷৽ͷRuby 2.8.0devͰ࠶ݱ͢Δ͜ͱΛ֬ೝ͢Δ • ࠷ॳʹRedʹͳͬͨRails CI buildʹରԠ͢ΔRubyͷcommit hashΛऔಘ͢Δ •

    Build#68202 • f2c3848a5bf2bec0b27a6035c4b7399594c32509 • ࠷ޙʹGreenͩͬͨbuildʹରԠ͢ΔRubyͷcommit hashΛऔಘ͢Δ • Build#68195 • a01bda594996fdc247e183f107cada43e2c8e3b8
  7. RubyͷίϛοτΛݟ͚ͭΔ(2) • minitest_bisectΛར༻ͯ͠ɺϛχϚϜͳ࠶ݱέʔεΛͭ͘Δ • Railsͷminitest͕ςετͷॱং΍Parallel testingͰ݁Ռ͕มΘΔ͜ͱ͕͋ΔͨΊ • Action ViewͱAction PackͰ͸PARALLEL_WORKERS=1Λࢦఆ͠ɺParallel

    testingΛແޮʹ͢Δ • https://gist.github.com/yahonda/b67b19304d34fc1150a9db79ee325bccɹࢀর • ϛχϚϜͳ࠶ݱέʔεΛ<Ϟδϡʔϧ>/rep.shͳͲͱͯ͠อଘ͢Δ • actionview/rep.sh • PARALLEL_WORKERS=1 bin/test test/actionpack/controller/render_test.rb --seed 53177 -n "/ ^(?:RenderTest#(?:test_render_call_to_partial_with_layout_in_main_layout_and_within_content_for_l ayout|test_nested_partial_with_form_builder))$/"
  8. RubyͷίϛοτΛݟ͚ͭΔ(2) • % git clone https://github.com/ruby/ruby • % cd ruby

    • % git bisect start • % git bisect good a01bda594996fdc247e183f107cada43e2c8e3b8 # ࠷ޙͷgreen • % git bisect bad f2c3848a5bf2bec0b27a6035c4b7399594c32509 # ࠷ॳͷred • Bisecting: 3 revisions left to test after this (roughly 2 steps) • [3825662d777ae406136fa7d720b60fe04c6eafd2] Set up environment variable for pager [Feature #16754]
  9. RubyͷίϛοτΛݟ͚ͭΔ(3) • [3825662d777ae406136fa7d720b60fe04c6eafd2] Set up environment variable for pager [Feature

    #16754] Λࢦఆͯ͠ϩʔΧϧͰ࠶ݱ͢Δ͔֬ೝ ͢Δ • % RUBY_IMAGE=rubylang/ rubyfarm:3825662d777ae406136fa7d720b60fe04c6eafd2 docker- compose -f .buildkite/docker-compose.yml build base && CI=1 docker- compose -f .buildkite/docker-compose.yml run default runner actionview 'sh ./rep.sh'
  10. RubyͷίϛοτΛݟ͚ͭΔ(4) • Τϥʔ͕࠶ݱͨ͠Β git bisect bad / ࠶ݱ͠ͳ͔ͬͨΒ git bisect

    good • % git bisect bad • Bisecting: 1 revision left to test after this (roughly 1 step) • [f22c4ff359498ab342e4b6d6feb21af6004ee270] View the help message with PAGER [Feature #16754] • ऴΘΔ·Ͱ܁Γฦ͢