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

E2cb998e15d8e8fdef4f11a1f510fe74?s=128

Yasuo Honda

April 17, 2020
Tweet

Transcript

  1. How to git bisect ruby/ruby repository ۜ࠲Rails#20 Yasuo Honda @yahonda

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

    ʹཔ Δ͜ͱʹͳΔͰ͠ΐ͏ɻ bisect ίϚϯυ͸ίϛοτͷྺ࢙ʹରͯ͠ೋ෼୳ ࡧΛߦ͍ɺͲͷίϛοτͰ໰୊͕ࠞೖͨ͠ͷ͔ΛՄೳͳݶΓखૣ͘ݟ͚ͭ ग़ͤΔΑ͏ʹ͠·͢ɻ • https://git-scm.com/book/ja/v2/Git-ͷ͞·͟·ͳπʔϧ-Git-ʹΑΔσόοά
  3. ruby/rubyͱ͸ • https://github.com/ruby/ruby ʹ͋ΔCRuby ϨϙδτϦ • https://git.ruby-lang.org/ruby.git ͷϛϥʔ

  4. ͍͔ͭ͘ͷgit bisect • RailsͷόʔδϣϯΛ͋͛ͨΒRailsΞϓϦέʔγϣϯͷಈ࡞͕มΘͬͨ • https://sinsoku.hatenablog.com/entry/2019/08/08/020954 ࢀর • Ruby ͷίϛοτ͕ਐΜͩΒRailsϑϨʔϜϫʔΫͷCI͕མͪͨ

    • ຊ೔࿩͢಺༰
  5. git bisect • RubyεΫϦϓτͰ࠶ݱͰ͖Δ৔߹ • https://github.com/mame/rubyfarm-bisect Λར༻͢Δͷָ͕Ͱ͢ • https://gist.github.com/yahonda/fa3dbe7cd4fc831836d71ff661b1b8a1 •

    RailsϑϨʔϜϫʔΫͷunit test(minitest)Ͱ࠶ݱͰ͖Δ৔߹ • ຊ೔࿩͢಺༰
  6. 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ͷΑ͏ͳ΋ͷ)
  7. 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 ࢀর
  8. 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) • ຊ೔࿩͢಺༰
  9. 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'
  10. RubyͷίϛοτΛݟ͚ͭΔ(1) • ࠷৽ͷRuby 2.8.0devͰ࠶ݱ͢Δ͜ͱΛ֬ೝ͢Δ • ࠷ॳʹRedʹͳͬͨRails CI buildʹରԠ͢ΔRubyͷcommit hashΛऔಘ͢Δ •

    Build#68202 • f2c3848a5bf2bec0b27a6035c4b7399594c32509 • ࠷ޙʹGreenͩͬͨbuildʹରԠ͢ΔRubyͷcommit hashΛऔಘ͢Δ • Build#68195 • a01bda594996fdc247e183f107cada43e2c8e3b8
  11. 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))$/"
  12. 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]
  13. 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'
  14. 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] • ऴΘΔ·Ͱ܁Γฦ͢
  15. RubyͷίϛοτΛݟ͚ͭΔ(4) • % git bisect bad • 5c2768181382bf84137759efea66f3aaf212665d is the

    first bad commit
  16. RubyͷίϛοτΛݟ͚ͭΔ(4) • bugs.ruby-lang.org ʹใࠂ͢Δ • https://bugs.ruby-lang.org/issues/16785 • যΒͣ଴ͭ • https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/

    79f3403be0cdbec814be29308c0583599ca5824f Ͱमਖ਼͞Εͨ
  17. ͓ΘΓ • ΋ͬͱָͳ΍Γํ͕͋Γͦ͏ͩͬͨΒڭ͍͑ͯͩ͘͞