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

Unity開発現場を支えるJenkins

Cygames
November 30, 2015

 Unity開発現場を支えるJenkins

2015/11/15 Cygames Tech Fes

Cygames

November 30, 2015
Tweet

More Decks by Cygames

Other Decks in Programming

Transcript

  1. 自己紹介
    • ݹֶؓ ΤϯδχΞ
    • ήʔϜۀք೥
    • ωΠςΟϒΞϓϦͷݱ৔ʹೖΓ௚઀αϙʔτɻ
    ΫϥΠΞϯτϝΠϯɻαʔόʔ΋؀ڥߏங΋ϦʔμʔͰ΋
    ඞཁͰ͋Ε͹ԿͰ΋ɻ
    • ࠷ۙ͸िҰࣾ಺ษڧձͱ͔։͍ͨΓ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  2. アジェンダ
    • ੩తղੳ
    • ςετ
    • ·ͱΊ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  3. アジェンダ
    • ੩తղੳ
    • ςετ
    • ·ͱΊ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  4. 静的解析って?
    ίϯϐϡʔλͷιϑτ΢ΣΞͷղੳख๏ͷҰछͰ͋Γɺ
    ࣮ߦϑΝΠϧΛ࣮ߦ͢Δ͜ͱͳ͘ղੳΛߦ͏͜ͱ
    ιʔείʔυʹରͯ͠ߦΘΕΔ͜ͱ͕ଟ͍
    XJLJQFEJBΑΓ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  5. 静的解析って?
    ίϯϐϡʔλͷιϑτ΢ΣΞͷղੳख๏ͷҰछͰ͋Γɺ
    ࣮ߦϑΝΠϧΛ࣮ߦ͢Δ͜ͱͳ͘ղੳΛߦ͏͜ͱ
    ιʔείʔυʹରͯ͠ߦΘΕΔ͜ͱ͕ଟ͍
    ૣظʹજࡏతͳΤϥʔ΍όάͷൃݟ͕Ͱ͖Δ
    XJLJQFEJBΑΓ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  6. 静的解析のきっかけ
    • ਓͷίʔυϨϏϡʔͰͷݟམͱ͠ɺଐਓԽ
    • πʔϧͷࢦఠͳΒɺݏͳإΛ͞ΕΔͷͰ͸
    ͳ͍͔ͱؾʹ͔͚Δࣄ͕ແ͍
    • DPDPTEYϓϩδΣΫτͰ੩తղੳͷಋೖ͕
    ੒ޭͨ͠ͷͰɺ6OJUZͰ΋΍Γ͔ͨͬͨ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  7. 付属の静的解析ツール
    ίϯύΠϥ ੩తղੳπʔϧ
    DTDFYF 'Y$PQ
    NDT (FOEBSNF
    ジャンダルム
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  8. 付属の静的解析ツール
    ίϯύΠϥ ੩తղੳπʔϧ
    DTDFYF 'Y$PQ
    NDT (FOEBSNF
    ジャンダルム
    εΫϦϓτΤϯδϯͰ࢖༻͍ͯ͠Δ.POP੡Λ࢖༻
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  9. Gendarme ルール
    w (FOEBSNF3VMFT#BE1SBDUJDF
    w (FOEBSNF3VMFT$PODVSSFODZ
    w (FOEBSNF3VMFT$PSSFDUOFTT
    w (FOEBSNF3VMFT%FTJHO
    w (FOEBSNF3VMFT%FTJHO(FOFSJD
    w (FOEBSNF3VMFT%FTJHO-JOR
    w (FOEBSNF3VMFT&YDFQUJPOT
    w (FOEBSNF3VMFT*OUFSPQFSBCJMJUZ
    w (FOEBSNF3VMFT.BJOUBJOBCJMJUZ
    w (FOEBSNF3VMFT/BNJOH
    w (FOEBSNF3VMFT1FSGPSNBODF
    w (FOEBSNF3VMFT1PSUBCJMJUZ
    w (FOEBSNF3VMFT4FDVSJUZ
    w (FOEBSNF3VMFT4FDVSJUZ$BT
    w (FOEBSNF3VMFT4FSJBMJ[BUJPO
    w (FOEBSNF3VMFT4NFMMT
    w (FOEBSNF3VMFT6J
    http://www.mono-­‐project.com/docs/tools+libraries/tools/gendarme/
    ɾόουϓϥΫςΟε
    ɾϝϯςφϯεੑ
    ɾύϑΥʔϚϯεੑͳͲ
    Ҏ্ͷϧʔϧʂ
    大カテゴリ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  10. PreferStringIsNullOrEmptyRule
    Bad
    QVCMJDCPPM4FOE.FTTBHF TUSJOHNFTTBHF

    \
    JG NFTTBHFOVMM
    cc NFTTBHF-FOHUI

    \
    SFUVSOGBMTF
    ^
    SFUVSO4FOE.FTTBHF &ODPEF NFTTBHF


    ^
    QVCMJDCPPM4FOE.FTTBHF TUSJOHNFTTBHF

    \
    JG 4USJOH*T/VMM0S&NQUZ NFTTBHF

    \
    SFUVSOGBMTF
    ^
    SFUVSO4FOE.FTTBHF &ODPEF NFTTBHF


    ^
    Maintainability
    4USJOHͷ/VMMۭνΣοΫ͕޷·͘͠ͳ͍
    Good
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  11. AvoidUncalledPrivateCodeRule
    Bad
    QVCMJDDMBTT.Z$MBTT\
    QSJWBUFWPJE.BLF4VGG

    \

    ^
    QVCMJDWPJE.FUIPE

    \
    $POTPMF8SJUF-JOF 'PP

    ^
    ^
    QVCMJDDMBTT.Z$MBTT\
    QVCMJDWPJE.FUIPE

    \
    $POTPMF8SJUF-JOF 'PP

    ^
    ^
    QSJWBUFͳͷʹݺ͹Ε͍ͯͳ͍
    Performance
    Good
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  12. Gendarme for Unity
    ެࣜϑΥʔϥϜ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  13. Gendarme for Unity
    w (FOEBSNF3VMFT#BE1SBDUJDF
    w (FOEBSNF3VMFT$PODVSSFODZ
    w (FOEBSNF3VMFT$PSSFDUOFTT
    w (FOEBSNF3VMFT%FTJHO
    w (FOEBSNF3VMFT%FTJHO(FOFSJD
    w (FOEBSNF3VMFT%FTJHO-JOR
    w (FOEBSNF3VMFT&YDFQUJPOT
    w (FOEBSNF3VMFT*OUFSPQFSBCJMJUZ
    w (FOEBSNF3VMFT.BJOUBJOBCJMJUZ
    w (FOEBSNF3VMFT/BNJOH
    w (FOEBSNF3VMFT1FSGPSNBODF
    w (FOEBSNF3VMFT1PSUBCJMJUZ
    w (FOEBSNF3VMFT4FDVSJUZ
    w (FOEBSNF3VMFT4FDVSJUZ$BT
    w (FOEBSNF3VMFT4FSJBMJ[BUJPO
    w (FOEBSNF3VMFT4NFMMT
    w (FOEBSNF3VMFT6J
    https://github.com/fderudder/unity-­‐gendarme
    w 6OJUZ3VMFT1FSGPSNBODF
    w 6OJUZ3VMFT.BJOUBJOBCJMJUZ
    ベースルール
    Unity独自ルール
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  14. AvoidEmptyComponentsMethodsRule
    QVCMJDDMBTT.Z$MBTT.POP#FIBWJPVS\
    WPJE"XBLF

    \
    ^
    WPJE4UBSU

    \
    %FCVH-PH l4UBSU

    ^
    ^
    QVCMJDDMBTT.Z$MBTT.POP#FIBWJPVS\
    WPJE4UBSU

    \
    %FCVH-PH l4UBSU

    ^
    ^
    Unity.Rules.Performance
    .POP#FIBWJPVSͷۭϝιουݺͼग़͠
    Bad Good
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    Φʔόʔϔου͕͔͔Δ

    View full-size slide

  15. AvoidUsingFindObjectInUpdateRule
    Bad
    QVCMJDDMBTT.Z$MBTT.POP#FIBWJPVS\
    WPJE6QEBUF

    \
    (BNF0CKFDUSPPU(BNF0CKFDU'JOE lNBJOSPPUz

    ^
    ^
    Good
    QVCMJDDMBTT.Z$MBTT.POP#FIBWJPVS\
    WPJE6QEBUF

    \
    (BNF0CKFDUSPPU@SPPU
    ^
    ^
    'JOE0CKFDUܥ͸6QEBUFܥͰݺ͹ͳ͍ํ͕ྑ͍
    Unity.Rules.Performance
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    'JOE0CKFDUܥ͸଎౓ʹ೉͋Γ

    View full-size slide

  16. ࢖༻ϓϥάΠϯɿ
    リリース直前のプロジェクトに試験導入
    参考:[Unite  Japan  2013]Unity  × Jenkins:一歩進んだ使い方
    https://vimeo.com/64378910
    8BSOJOHT1MVHJO
    7JPMBUJPOTQMVHJO
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  17. 結果
    ղੳʹ͔͔ͬͨओͳ΋ͷ
    • ະ࢖༻QSJWBUFϝιου
    • /6--νΣοΫ͕ແ͍
    • 4ZTUFN4USJOHͱ
    4ZTUFN$IBSͷ࿈݁
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  18. 結果
    ղੳʹ͔͔ͬͨओͳ΋ͷ
    ༗ྉΞηοτ͕݁ߏͻ͔͔ͬΔ
    • ະ࢖༻QSJWBUFϝιου
    • /6--νΣοΫ͕ແ͍
    • 4ZTUFN4USJOHͱ
    4ZTUFN$IBSͷ࿈݁
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    *HOPSFࢦఆΛؤுΔʜ

    View full-size slide

  19. 目に見えた成果は出なかった…
    ɾϦϦʔεޙʹΫϦςΟΧϧͰͳ͍΋ͷΛ௚͢ͷ͸ϦεΫ
    ɾن໿ʹຒ΋ΕͯΫϦςΟΧϧͳॴΛݟམͱ͕ͪ͠ʹ
    成果として
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  20. 目に見えた成果は出なかった…
    ɾϦϦʔεޙʹΫϦςΟΧϧͰͳ͍΋ͷΛ௚͢ͷ͸ϦεΫ
    ɾن໿ʹຒ΋ΕͯΫϦςΟΧϧͳॴΛݟམͱ͕ͪ͠ʹ
    成果として
    ࠓޙͷίʔσΟϯάϧʔϧΛఆٛ͢Δ༻్ʹ͸
    ඇৗʹ࢖͑Δ
    とはいえ
    ৽نҊ݅ʹ͸औΓೖΕ͍ͯ͘Α͏ల։த
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  21. アジェンダ
    • ੩తղੳ
    • ςετ
    • ·ͱΊ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  22. テストのきっかけ
    • νΣοΫ؀ڥ͕ଟͯ͘ਏ͍
    ։ൃɺεςʔδϯάɺຊ൪ɺJ04ɺ"OESPJEɺFUD

    • Ϗϧυ͸௨Δ͕ɺىಈ͠ͳ͍ࣄ͕͋Δ
    ֬ೝෆ଍ɺؼΓࡍͷQVTI

    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  23. テストのきっかけ
    • νΣοΫ؀ڥ͕ଟͯ͘ਏ͍
    ։ൃɺεςʔδϯάɺຊ൪ɺJ04ɺ"OESPJEɺFUD

    • Ϗϧυ͸௨Δ͕ɺىಈ͠ͳ͍ࣄ͕͋Δ
    ֬ೝෆ଍ɺؼΓࡍͷQVTI

    ΠʔδʔϛεʹΑΔ࡞ۀޮ཰ͷ௿Լ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  24. スモークテスト
    ίϯύΠϧ΍Ϗϧυͨ͠௚ޙʹͦͷιϑτ΢ΣΞ͕
    ಈ͘ࣄΛ֬ೝ͢Δ
    ʮىಈ͢Δʯʮجຊػೳ͕ಈ࡞͢Δʯ
    ͳͲͷ؆қςετ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  25. 生成物の作成
    GitHub
    ①pull
    ②ビルド
    apk
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  26. 監視スクリプトの起動
    ؂ࢹεΫϦϓτ
    ᶅεΫϦϓτىಈ
    GitHub
    ˞QZUIPOҎ֎Ͱ΋
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  27. ④インストール
    genymotion
    インストール&起動
    インストール :  adb  install  app.apk
    起動 :  adb  shell  am  start  -­‐n  {packagename}/{mainActivity}
    ⑤起動
    GitHub
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  28. ⑤ログの書き出し
    .log
    ログ :  adb  logcat  Unity:V  *:S  >  output.log  
    logcat
    ؂ࢹεΫϦϓτ͔ΒMPHDBUͰϩάΛॻ͖ग़͢
    ϩάͷதʹIFBSUCFBUΛ࢓ࠐΈɺ؂ࢹεΫϦϓτͰݕ஌͢Δ
    heart
    beat
    GitHub
    heartbeatの検知
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  29. jenkinsへの通知
    ᶈ੒ޭɿIFBSUCFBU͕ಧ͍ͨ
    ࣦഊɿҰఆ࣌ؒಧ͔ͳ͍
    GitHub
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  30. テストまとめ
    • KFOLJOT͔Βੜ੒෺ͷ࡞੒
    • ؂ࢹ༻εΫϦϓτΛ্ཱͪ͛ɺੜ੒෺Λ
    Πϯετʔϧ͠ΤϛϡϨʔλʔͰىಈ
    • ϩάʹ͸ಛఆͷจࣈྻ͕࢓ࠐ·Ε͍ͯΔ
    ৗறͰ6QEBUF͕૸ΔΑ͏ͳ.BOBHFSܥʹ࢓ࠐΜͰ͍Δ

    • ؂ࢹεΫϦϓτ͔ΒಛఆͷจࣈྻΛݕ஌͠௨஌
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  31. 失敗通知
    • ࣾ಺4/4΁౤ߘ
    • BGQMBZͰԻΛ໐Β͢
    • CMJOL
    Ͱ-&%ΛޫΒͨ͠Γ
    • "SVEVJOPͰ૊ΜͰΈͨΓ
    ざわ…ざわ…
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  32. 今後やりたい事
    • ֤γʔϯͷΤʔδϯά
    ɾ IFBSUCFBUͷ࢓૊ΈΛྲྀ༻͢Δͱ͔
    • ϞϯΩʔςετ
    ɾBECͰΩʔΠϕϯτͱ͔
    ɾNPOLFZSVOOFSΛ࢖༻͢Δͱ͔
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  33. まとめ
    • ඼࣭ͷվળʹ͸࣮֬ʹܨ͕Δ
    ɾ ίʔυϨϏϡʔͷෛ୲ܰݮ
    ɾ Πʔδʔϛεͷ௿Լ
    ɾ ݟ͑ΔԽͰ཰ઌͯ͠௚͕ͨ͠Δਓ΋ग़Δ
    • ҰͭͰ΋֬ೝ࡞ۀΛࣗಈԽͰݮΒ͢
    ɾ ࡞ͬͯྑ͔ͬͨͱࢥ͏͕࣌ඞͣདྷΔ
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide

  34. ご清聴ありがとうございました
    $POGJEFOUJBM $PQZSJHIU ˜$ZHBNFT *OD "MM3JHIUT3FTFSWFE

    View full-size slide