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

iOS 開発での Pull Request と テストカバレッジの連携

iOS 開発での Pull Request と テストカバレッジの連携

71ce746e94f84be1cef8e57e8277bd6d?s=128

star__hoshi

March 13, 2017
Tweet

Transcript

  1. iOS ։ൃͰͷ Pull Request ͱ ςετΧόϨοδͷ࿈ܞ iOS Test Night #3

    by @star__hoshi
  2. ΞδΣϯμ • ࣗݾ঺հ • ςετΧόϨοδܭଌ • ϓϧϦΫͱͷ࿈ܞ • ͓·͚ 

  3. ࣗݾ঺հ • Twitter: @star__hoshi • GitHub: starhoshi • Classiגࣜձࣾ •

    iOS ΤϯδχΞ 
  4. ΧόϨοδͬͯʁ  ϝϦοτ͸ʁσϝϦοτ͸ʁ ΧόϨοδΛຬͨ͢ͱ඼্࣭͕͕Δͷʁ ΧόϨοδϙϦεϝϯ

  5. ͱ͍͏࿩͸͠·ͤΜ ͳͥͳΒ5෼͔͠ͳ͍͔Β 

  6. ࣮ࡍʹܭଌ͢Δ ͱ͍͏࿩Λ͠·͢ 

  7. ׬੒ܥ 

  8. Xcode ʹ͓͚Δ ΧόϨοδܭଌํ๏ 

  9. Xcode: EditScheme > XxxTests Gather coverage data ʹνΣοΫೖΕΔ 

  10. ͜Μͳײ͡Ͱ݁Ռ͕ग़Δ 

  11. ϩʔΧϧͰܭଌͰ͖Δ ͕ ϓϧϦΫʹ࿈ܞ͍ͨ͠ 

  12. fastlane scan + fastlane action 

  13. fastlane scan  ؆୯ʹςετΛ࣮ߦ (ઃఆϑΝΠϧ͸ඞཁ) IUUQTHJUIVCDPNGBTUMBOFGBTUMBOFUSFFNBTUFSTDBO

  14. fastlane action | grep coverage • lcov • xcov •

    gcovr • slather 
  15. fastlane action | grep coverage • lcov • xcov •

    gcovr • slather 
  16. nakiostudio/xcov IUUQTHJUIVCDPNOBLJPTUVEJPYDPW 

  17. nakiostudio/danger-xcov IUUQTHJUIVCDPNOBLJPTUVEJPEBOHFSYDPW 

  18. danger IUUQEBOHFSTZTUFNT ϓϧϦΫʹ merge OK ͔νΣοΫͰ͖Δ 

  19. IUUQOJXBUBLPIBUFOBCMPHKQFOUSZ 

  20. fastlane scan + danger-xcov + CI Server 

  21. gem 'fastlane' gem 'danger-xcov' gem 'danger' Gemfile 

  22. scheme "HogeTests" configuration "Staging" device "iPad Retina" workspace "hoge.xcworkspace" clean

    true skip_build true fastlane/Scanfile 
  23. xcov.report( workspace:"hoge.xcworkspace", scheme:"HogeTests", minimum_coverage_percentage:40 ) Dangerfile minimum_coverage_percentage ΛԼճΔͱ Merge Ͱ͖ͳ͍

    
  24. lane :test do scan danger end fastlane/Fastfile 

  25. test: override: - bundle exec fastlane test CI Ͱ࣮ߦ CircleCI

    Ͱͷྫ: 
  26. DANGER_GITHUB_API_TOKEN  https://github.com/settings/tokens/new ͰAPIτʔΫϯΛऔಘɺCI Ͱઃఆ

  27. ݁Ռ 

  28. ͍͍͜ͱ • 100% ΛݟΔͱॆ࣮ײ͕͋Δ • ΋ͬͱ΍Δͧ • ✅ ϨϏϡϫʔͷෛ୲ݮ •

    ςετॻ͍ͯͳ͍ͷ͕ҰॠͰόϨΔ • ݾͷະख़͞Λײ͡Δ ( 43%) 
  29. ͓·͚ 

  30. require 'date' max = 90 diff = Date.today - Date.new(2017,3,13)

    min = max > diff ? diff : max xcov.report( workspace: 'workspace', scheme: 'scheme', minimum_coverage_percentage: min) 90೔ޙʹ90%Λ࣮ݱ͢Δํ๏ ຖ೔1%ͣͭ Merge ͷਫ४Λ্͍͛ͯ͘ 
  31. Ҏ্