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

DangerでスムーズなPRレビューを

masakazu sano
September 12, 2017

 DangerでスムーズなPRレビューを

2017/09/12 iOS社内勉強会 @OHAKO.inc にて公開したスライドです

masakazu sano

September 12, 2017
Tweet

More Decks by masakazu sano

Other Decks in Technology

Transcript

  1. You can use Danger to codify your teams norms, leaving

    humans to think about harder problems.
  2. Danger ͷछྨ • ݱࡏ js൛ͱruby൛͕͋Δ • ࠷ۙ swift൛ʢ·ͩβͬΆ͍ʣ͕௥Ճ͞Εͨ! • iOS

    11 / swift 4 ʹͯಈ࡞ • https://github.com/danger/danger-swift ※ ࠓճ͸ruby൛Ͱ࿩ΛਐΊ·͢
  3. ಋೖํ๏ ༻ҙ͢Δ΋ͷ • Bundler • ԿΒ͔ͷCI (CircleCI , Bitrize ...)

    • Danger௨஌༻ͷ bot • organization / private repoͷࡍ͸ඞཁʹͳΔ
  4. ಋೖํ๏ 1. ϩʔΧϧ؀ڥʹDangerΛೖΕΔ • ੜ੒͞ΕͨGemFileʹ gem "danger" Λ௥ه $ bundle

    install ʢ࣮ߦ࣌ɺର࿩ܗࣜʹͯηοτΞοϓΛߦ͑Δ͕ɺͱΓ͋͑ͣ Enter࿈ଧͯ͠΋Α͍ʣ ➡ Πϯετʔϧ੒ޭ͢ΔͱDangerFile͕ੜ੒͞ΕΔ
  5. ಋೖํ๏ 2. GithubʹbotΛઃఆ͢Δ • ن໿্ɺmachine user ͸1ͭͷ organization ʹ͖ͭ1ମͷΈ ͱͳ͍ͬͯΔͷͰ஫ҙ

    • https://developer.github.com/v3/guides/managing- deploy-keys/#machine-users • machine userͷ௥Ճํ๏ • http://www.wikihow.com/Use-Deploy-Keys-on- Github#CreatingaMachineUsersub
  6. ಋೖํ๏ 2. GithubʹbotΛઃఆ͢Δ ʢOSSͷ৔߹͸ࣗ਎ͷΞΧ΢ϯτͷtokenΛ࡞Γ·͠ΐ͏!ʣ • botʹDanger༻ͷprivate access tokenΛ௥Ճ͢Δ • botͰϩάΠϯ

    • Setting -> Personal access tokens -> ʮGenerate new tokenʯԡԼ • ͦͷࡍɺtokenͷݖݶ͸ repos શͯʹνΣοΫ͢Δ͜ͱ
  7. ಋೖํ๏ 3. CI্ͰDangerFileΛධՁ Ͱ͖ΔΑ͏ʹηοτ͢Δ • ઌʹ༻ҙͨ͠bot (OSSͷ৔߹͸ࣗ਎ ͷ) ͷ private

    access token Λη οτ͢Δ • workflow editor಺ͷʮEnv Varsʯ λϒԡԼ • ʮAdd newʯԡԼ͠ɺ ʮDANGERGITHUBAPI_TOKENʯ ͱ͍͏໊শͰtokenొ࿥
  8. DangerFileΛΧελϚΠζ͢Δ • message / warn / fail ͷࡾछͰϢʔβʔʹνΣοΫ಺༰Λप ஌Ͱ͖Δ •

    markdownͰͷهड़΋Մɿ • markdown("## ࡞ۀதͰ͢") • ಛఆͷίʔυͷdiffΛදࣔ͢Δ͜ͱ΋Ͱ͖Δ
  9. DangerFileΛΧελϚΠζ͢Δ ڞ௨Ͱ࢖͑ͦ͏ͳνΣοΫɿ # ϚΠϧετʔϯͷνΣοΫ message("ϚΠϧετʔϯ͕ະઃఆͰ͢") unless has_milestone # ࡞ۀऀͷνΣοΫ warn("࡞ۀऀΛΞαΠϯ͠·͠ΐ͏",

    sticky: false) unless has_assignee # ϚʔδઌͷνΣοΫ warn("ϚʔδઌΛdevelopʹઃఆ͠·͠ΐ͏") if !github.branch_for_base == "develop" # ߦ਺νΣοΫ warn("500ߦ௒͑ͯ·͢ɻ෼ׂͰ͖ΔͱϕλʔͰ͢Ͷ") if git.lines_of_code > 500
  10. DangerFileΛΧελϚΠζ͢Δ iOS։ൃ༻్ͷνΣοΫɿ # App.xcodeproj/project.pbxproj ͷมߋνΣοΫ message ("`App.xcodeproj/project.pbxproj` ͕มߋ͞Ε͍ͯ·͢") if git.modified_files.include?

    "App.xcodeproj/project.pbxproj" # Cartfile ͷมߋνΣοΫ message ("`Cartfile` ͕มߋ͞Ε͍ͯ·͢") if git.modified_files.include? "Cartfile" message ("`Cartfile.resolved` ͕มߋ͞Ε͍ͯ·͢") if git.modified_files.include? "Cartfile.resolved" # Podfile ͷมߋνΣοΫ message ("`Podfile` ͕มߋ͞Ε͍ͯ·͢") if git.modified_files.include? "Podfile" message ("`Podfile.lock` ͕มߋ͞Ε͍ͯ·͢") if git.modified_files.include? "Podfile.lock"
  11. DangerFileΛΧελϚΠζ͢Δ LGTMɿ # add lgtm pic lgtm.check_lgtm • ʮwarn /

    failͰͻ͔͔ͬΒͳ͍࣌ͷΈʯLGTM͞ΕΔ • ͻͱ໨ͰϨϏϡʔՄೳ͔൑Δʂ! • GemFileʹ௥ه͕ඞཁɿ gem "danger-lgtm"
  12. ྑͦ͞͏ͳDanger Plugin clorox • file header(ॺ໊)ͷܗࣜνΣοΫ • https://github.com/barbosa/danger-clorox todoist •

    TODO/FIXMEͷهड़ʹର͠ࡉ͔ͳ௨஌͕Ͱ͖Δ • https://github.com/hanneskaeufler/danger-todoist