Share
Embed
Transcript
33 slides
-
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
Bundle update Rails • 何はともあれまずは “bundle update rails” • しかし依存しているgemでrailsのバージョンロックが入っている事
が多く、まずここで時間がかかる • 片っ端から更新のPRを送る ◦ が、その前に、そもそもそのgem本当に必要か再度考える -
Bundle update Rails • そのgem本当に必要ですか? • インストールした際は必要だったとしても、その後要件が変わった りして実は不要になったgemが残ってるかもしれない • 便利かと思っていれてみたが、実はそんなに便利ではなかった(要
件が合わなかった)gemが残ってるかもしれない • Rails本体で同じ機能が提供された事により、不要になった可能性 もある(e.g. quiet_assets) -
Bundle update Rails • Railsのアップグレードの際にgemの掃除も行う ◦ 実際のPRアップグレードのPRとは別で投げたりする • Railsのアップグレードで辛い事の多くはgemの更新(個人の感想) なので、今後の事も考えて負担を減らしていく
• 見直しをした結果、本当に必要なgemにだけ更新のPRを送る ◦ それでも多いかもしれないが、そこは頑張る -
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
Run test • 最初のテスト実行 • ここで落ちる場合、Railsのバグを踏んだ、private APIを使用してい てそれが壊れた、gemが壊れた、等々色々な要因がありえる • ここは頑張って一つずつ対応していくしか無い
• そもそもテストが無いプロジェクトは、色々頑張っていきましょう -
public API / private API • Railsはpublic API(ユーザが使用して良いAPI)とprivate API(ユー ザが使用してはいけないAPI)が明確にわかれている
• public APIはRails API doc にのっているAPI、それ以外は基本 private API • 例えばActive Recordではwhereはpublic APIだが、where!は private API ◦ なのでwhere!は使っては駄目ですよ ◦ Arelも同様 -
public API / private API • public APIは一つのバージョンアップ(major, minor問わず)で挙動 が変わる事は無い
◦ public APIについては、必ず既存の挙動をdeprecationにしてから変えるようにして る ◦ 一部例外あり -
public API / private API • どうしても挙動が変わってしまうAPIについては、A Guide for Upgrading
Ruby on Rails に載る(はず) • それ以外のpublic APIの挙動が変わっていたらそれはバグなの で、issueで報告する -
public API / private API • private APIを多用している場合のアップグレードは大変 ◦ そもそもメソッドが無くなっている場合もあったりで、気付くのが大変
• Railsの機能を拡張するgemでprivate APIを使うのは仕方無いが、 普通のRailsアプリではprivate APIを使用しなくてもどうにかなるは ず -
public API / private API • どうしてもprivate APIが必要な場合は、その部分だけ切り出して gemにする、他のファイルと混ぜない(モンキーパッチである事が明 確にわかる管理にする)ようにきをつける
• または、private APIをpublic APIにするようRails側にPRを送る ◦ 一旦public APIに出来ればこっちのもん • 最大限private APIがアプリ内で使われるのを避けるようにする -
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
Update config • app:updateは使ってない • app:updateは色々と問題がある(rails newで指定したオプ ションを考慮しない、configのappendが出来ない等) ◦ 多少直したい気持ちはある
◦ Do not generate unused components contents in app:update task -
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
Fix deprecate message • deprecateメッセージを片っ端から潰していく • deprecateメッセージに代わりに使うべきメソッド・configが含まれて いる筈なので、基本的にはそれに従う ◦ "without
replacement"なケースもあるが、それで本当に困る事は滅多に無い筈 -
Fix deprecate message • 対応が広範囲に渡る修正は別PRにする、バックポートしても問題 無い対応は別PRにして古いコードに入れる、等を行う • アップグレードのPRが大きくなり過ぎないよう気をつける ◦ 無理に一つのPRに全部を入れない
• また、既存のコードを壊す可能性がある対応も別PRにする(DB周 りは特に) -
Fix deprecate message • Railsのバージョンがrcの場合は少し様子を見る事もある ◦ rcリリース後にdeprecateだったのがdeprecateじゃなくなるケースもたまにあるので ◦ e.g. Remove
implicit coercion deprecation of durations ◦ DHHぱわー(真っ当な意見が多い) -
Upgrading Flow 1. Bundle update Rails 2. Run test 3.
Update config 4. Run test again 5. Fix deprecate message 6. Finally run the test again -
After release • 性能劣化はちょいちょいおきる • 最近だと ◦ Upgrading from Rails
5.0.0.1 to 5.0.1 increases import from... ◦ 5.0.0 -> 5.0.1 mysql foreign_keys is crazy slow -
After release • Rails側でパフォーマンスチェックの為の仕組みが無い ◦ RubyBench - Long Running Ruby
Benchmark とかあるが、公式では無い • これについてはアプリ側で意識するしか現状無い