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

OSS Forward Workshop

OSS Forward Workshop

011714704c4a925e542d426d4cdaa4e3?s=128

giginet

May 12, 2022
Tweet

More Decks by giginet

Other Decks in Programming

Transcript

  1. OSSίϛολʔʹͳΖ͏ʂ 5/12 ϫʔΫγϣοϓ @ Money Forward @giginet 1/51

  2. ࣗݾ঺հ • @giginet • Core Contributor of Carthage/fastlane/ XcodeGen etc...

    • https://github.com/giginet • https://twitter.com/giginet • ؾܰʹmention͍ͯͩ͘͠͞ʂ 2/51
  3. ! ໨త • ओʹiOS෼໺ͰͷOSS΁ͷίϛοτΛମݧΛ͢Δ • ࣮ࡍʹϚʔδ͞ΕΔΑ͏ͳPRΛૹΓɺOSSʹߩݙ͢Δ • ৺ཧతোนΛݮΒ͢ɻඞཁʹԠ͡OSSʹߩݙͰ͖ΔΑ͏ʹ͢ Δ •

    MoneyForward iOSΤϯδχΞؒͷަྲྀ • ϫʔΫγϣοϓ಺ͰऔΓ૊Μͩ՝୊Λݩʹަྲྀ͢Δ 3/51
  4. ⏱ λΠϜςʔϒϧ 14:00 ߨٛ 14:20~ ! OSSମݧϫʔΫγϣοϓ 17:20~ " ൃදձ

    + ࣗݾ঺հ 18:00~ # 4/51
  5. PR͕Ϛʔδ͞ΕΔ·Ͱ 5/51

  6. 1. ωλ୳͠ 2. ௐࠪ 3. ࣮૷ 4. ςετ 5. Pull

    Request 6. Ϛʔδ ! 6/51
  7. 1. ωλ୳͠ • ԿΛ࣮૷͢Δ͔ܾΊΔ • OSSߩݙʹ͓͍ͯҰ൪೉͍͠ • ՝୊ൃݟΛͲͷΑ͏ʹ͍͔͕ͯ͘͠ॏཁ 7/51

  8. i. ࢖͍ͬͯͯػೳཁ๬΍όάΛݟ͚ͭΔ • ೔ৗతʹ࢖͍ͬͯΔπʔϧ΍OSSͷதͰෆ۩߹΍ཁ๬Λൃݟ͢ Δ • ͜Μͳػೳཉ͍͠ • ͜ͷڍಈʹࠔͬͨ •

    typoൃݟ • Ұ൪ྑ͍՝୊ൃݟํ๏͕ͩɺ͜Ε͕Ͱ͖Ε͹ۤ࿑͠ͳ͍ 8/51
  9. ii. issueτϥοΧʔΛݟΔ • ීஈ࢖͍ͬͯΔϥΠϒϥϦɺπʔϧ΍ɺ༗໊OSSʹ͍ͭͯ GitHub issueΛோΊͯΈΔɻͳΜͱͳ͘՝୊͕΄͍͠৔߹ʹ޲ ͍͍ͯΔɻ • ϓϩδΣΫτʹΑͬͯ͸ॳ৺ऀ׻ܴϥϕϧ͕෇͍͍ͯΔ৔߹΋ •

    appleͷϦϙδτϦ͸Good First Issue ϥϕϧ͕෇͍͍ͯΔ ͷͰɺमߦʹ͍࣋ͬͯ͜ 9/51
  10. iii. υΩϡϝϯτͷߩݙɺ • ίϚϯυͷϛεɺtypoɺϦϯΫ੾ΕͳͲ͸Α͘ݟ͚ͭΒΕΔͷ Ͱݟ͚ͭͨΒŢœŕͱ௚ͤΔ • ܰඍͳमਖ਼Ͱ΋໰୊ͳ͍ɻ 10/51

  11. ߩݙ͠΍͍͢issue • Ϛʔδͷ͞Ε΍͢͞ • ෆ۩߹ɺΤοδέʔεͷߟྀ࿙ΕͳͲɺؒҧ͍ͬͯΔ͜ͱ͕ ໌֬ͳ΋ͷ • issue্Ͱٞ࿦͕ਐΜͰ͓Γɺ࣮૷଴ͪͷঢ়ଶͷ΋ͷ(ϥϕϧ ͳͲ͕෇͍͍ͯΔέʔε΋) •

    ޙํޓ׵Λ่͞ͳ͍΋ͷɻ໭ͯ͠΋໰୊ͳ͍΋ͷ 11/51
  12. ߩݙ͕େมͳissue • େن໛ͳػೳ௥Ճ͸Ϛʔδ·Ͱ೉͍͠ • ࢓༷΍࣮૷ʹ͍ͭͯɺAuthorͱٞ࿦ͯ͠ຏ͘ඞཁ͕͋Δ • ద੾ͳ࢓༷͔ • ߟྀ࿙Ε͸ͳ͍͔ •

    ίʔσΟϯάنൣʹଇ͍ͯ͠Δ͔ɾΑΓྑ͍ॻ͖ํ͸ͳ͍ ͔ 12/51
  13. ωλ୳͕͠Ұ൪೉͍͠ • OSSʹߩݙ͠Α͏ͱ͍͏ϞνϕʔγϣϯΛ࡞Δͷ͕Ұ൪೉͍͠ • ΍Δ͜ͱ͕໌֬ͩͬͨΓɺࣗ෼ʹͱͬͯඞཁͳΒखΛ෇͚΍͢ ͍ • ࠓճ͸͍͔ͭ͘खΛ෇͚΍͍͢issueΛ༧Ί୳͖ͯͨ͠ͷͰɺ͜ ͷաఔΛ͋Δఔ౓εΩοϓͰ͖·͢ 13/51

  14. 2. ௐࠪ 14/51

  15. ௐࠪͷखॱ 1. ։ൃ؀ڥͷߏங 2. ࠶ݱঢ়گͷ༻ҙ 3. ݪҼͷௐࠪ • σόοΨʔͷར༻ 15/51

  16. 1. ։ൃ؀ڥͷߏங • ϦϙδτϦͷclone • Ϗϧυ؀ڥͷߏங • खݩͰ࣮ߦͰ͖ΔΑ͏ʹ͢Δ 16/51

  17. 2. ࠶ݱঢ়گͷ༻ҙ • ࠷খ࠶ݱ؀ڥΛ࡞Δ • ৽نϓϩδΣΫτ࡞੒ɺcloneͨ͠ґଘϥΠϒϥϦΛऔΓࠐΉ • લఏ৚݅Λௐ΂Δɺ༻ҙ͢Δ • ಛఆͷঢ়گԼͰ໰୊͕ى͖Δͱ͖ɺͦͷέʔεΛ༻ҙ͢Δ

    ʢઃఆϑΝΠϧͳͲʣ • ςετέʔεͷ༻ҙ 17/51
  18. 3. ݪҼͷௐࠪ • lldb(σόοΨʔ)ɺbreakpointͳͲɺ௨ৗͷσόοάख๏Λۦ࢖ ͢Δʢޙड़ʣ 18/51

  19. ςετίʔυͷ࣮૷ • ͘͢͝େࣄɻ࣮૷1ߦʹରͯ͠ςετ͸਺ഒͱ͍͏ͷ͸βϥ • ઌʹςετέʔε͔Βॻ͍ͯ΋ྑ͍(TDD) 19/51

  20. ྑ͍ςετ • PRͷલʹςετ͕མ͍͕ͪͯͨɺमਖ਼ʹΑͬͯ௚ΔΑ͏ͳςε τ͕ཧ૝త • ૝ఆ͞ΕΔΤοδέʔε΍೉͍͠ঢ়گ͕໢ཏ͞Ε͍ͯΔ • Α͍ςετέʔε͕͋ΔͱϨϏϡʔ͞Ε΍͍͢ɹ 20/51

  21. PRΛग़͢ 21/51

  22. Description • ʮ΍Γ͍ͨ͜ͱʯʮલఏ৚݅ʯʮͲͷΑ͏ʹղܾ͔ͨ͠ʯʮͦ ͷଞݒ೦ʯ • ςϯϓϨʔτʹԊ͏ͱָ • ແݴPR͸ආ͚Δ 22/51

  23. ## Motivation & Context <!-- Ͳ͏͍͏ঢ়گͰ͜Ε͕ى͖Δ͔ --> <!-- ͳͥ͜ͷػೳ͕ඞཁͳͷ͔ɺԿʹࠔ͍ͬͯΔ͔ -->

    ## Description <!-- ͲͷΑ͏ʹ࣮૷͔ͨ͠ --> <!-- ͲͷΑ͏ͳέʔεͰಈ࡞֬ೝ͔ͨ͠ --> <!-- Τοδέʔε͸ͳ͍͔ --> 23/51
  24. ϨϏϡʔ͞ΕΔ΂͖ͱ͜Ζ • ςετέʔε͸ద੾͔ • Τοδέʔε͸ͳ͍͔ • ঢ়گ͕໢ཏ͞Ε͍ͯΔʁ • ίʔσΟϯάنൣʹै͍ͬͯΔ͔ •

    ࣮૷͔ॴɺϓϩδΣΫτ͝ͱͷنଇ 24/51
  25. Ϛʔδ 25/51

  26. Ϛʔδ͞Ε΍͍͢PR • ٞ࿦ͷ༨஍͕ͳ͍ • MotivationΛ͔ͬ͠Γͱઆ໌͍ͯ͠Δ • ςετ΍ಈ࡞֬ೝ͕໌֬ 26/51

  27. αϯϓϧ https://github.com/yonaskolb/XcodeGen/pull/720 27/51

  28. 28/51

  29. 29/51

  30. ਐΊํ 30/51

  31. ՝୊ • ࣄલʹड़΂ͨΑ͏ʹωλ୳͕͠ͱͯ΋೉͍͠ɻ༧Ίணख͠΍͢ ͍՝୊Λ͍͔ͭ͘༻ҙͯ͠Έ·ͨ͠ • https://hackmd.io/@giginet/BJQulUAr5 • ͜͜ʹͳ͍issue΋΋ͪΖΜ׻ܴ • ݸਓతʹ๊͍͑ͯΔ՝୊ײ΍ɺڵຯͷ͋ΔOSSͷௐࠪ΋׻ܴ

    31/51
  32. ਐΊํ • ωλாΛݟͯɺSlackͰ௅ઓ͍ͨ͠issueΛڭ͍͑ͯͩ͘͞ • 1ਓͰ΋ྑ͍͠ɺ՝୊͕ඃͬͨΒదٓνʔϜΛ૊ΜͰ΋Α͍Ͱ ͢ɻϞϒϓϩɺϖΞϓϩ׻ܴ 32/51

  33. ! ϝϯλʔ • ͷखआΓ์୊ɻͲΜͲΜฉ͍͍ͯͩ͘͞ • Ͳͷissue΍͍͍͔ͬͯΘ͔Βͳ͍ʂ • ؀ڥߏஙηοτΞοϓͰ͖ͳ͍ʂ(खݩͰͷ࣮ߦɺσόο Ψʔ) •

    ࣮૷ํ๏Θ͔Βͳ͍ʂ • ςετॻ͚ͳ͍ʂ 33/51
  34. (෇࿥) ؀ڥߏங σόοάςΫχοΫ 34/51

  35. iOSϥΠϒϥϦͷςετ • 1. ςετ༻ͷiOSϓϩδΣΫτΛ࡞Δ • 2. Ϋϩʔϯͨ͠ϩʔΧϧϦϙδτϦΛΞϓϦʹ૊ΈࠐΉ • SwiftPM •

    CocoaPods 35/51
  36. SwiftPM Package Dependencies > + > Add Local Ͱcloneͨ͠σΟϨΫτ ϦΛࢦఆ

    36/51
  37. CocoaPods $ git clone https://github.com/ReactiveX/RxSwift.git /path/to/repos/RxSwift pod 'RxSwift', path: '/path/to/repos/RxSwift'

    37/51
  38. CLIπʔϧͷςετ(ྫ: XcodeGen) ShellͰͷ࣮ߦɺςετ $ git clone https://github.com/yonaskolb/XcodeGen.git $ cd XcodeGen

    $ swift build $ swift test $ swift run xcodegen --help 38/51
  39. • ΋͘͠͸XcodeͰϏϧυͨ͠όΠφϦΛShell͔Β࣮ߦͯ͠΋ྑ ͍ • Products > Show Build Folder in

    FinderͰόΠφϦͷҐஔ͕ Θ͔Δ 39/51
  40. XcodeͰσόοΨʔʹ઀ଓ͢Δ 1. Debug > Attach to Process by ID ͰίϚϯυ໊ΛೖΕΔ

    2. Edit Scheme > Arguments Passed on Launch 3. Run 40/51
  41. 41/51

  42. XcodeͷRunϘλϯ͔ΒҾ਺Λ౉͢ XcodeͰͷ࣮ߦ࣌ʹίϚϯυϥΠϯҾ਺Λ౉͢͜ͱ΋Ͱ͖Δɻ࠷ ॳ͔ΒσόοΨʔ͕ܨ͕Γ։ൃ͠΍͍͢ • xcodegen > Edit Scheme > Arguments

    Passed On Launch. 42/51
  43. 43/51

  44. ShellΛ࢖ͬͨςετ؀ڥͷ࡞Γํ(ྫ: swift- argument-parser) 44/51

  45. ։ൃ͍ͨ͠ύοέʔδΛclone $ git clone https://github.com/apple/swift-argument-parser.git 45/51

  46. ։ൃ༻ϓϩδΣΫτͷ࡞੒ $ mkdir oss-forward-workshop $ cd oss-forward-workshop $ swift package

    init 46/51
  47. ϓϩδΣΫτΛXcodeͰ։͘ Xcode > Open͔Β oss-forward-workshop Λ։͘ 47/51

  48. Package.swift • cloneͨ͠ϩʔΧϧύεΛ Package.swift ʹهड़ • ςετ༻ͷexecutableΛ௥Ճ // swift-tools-version: 5.6

    // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "oss-forward-workshop", products: [ .executable(name: "oss-forward-workshop", targets: ["oss-forward-workshop"]) ], dependencies: [ .package(name: "swift-argument-parser", path: "/path/to/repo/swift-argument-parser"), ], targets: [ .target(name: "oss-forward-workshop", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), ]) ] ) 48/51
  49. Package.swift • cloneͨ͠ϩʔΧϧύεΛ Package.swift ʹهड़ • ςετ༻ͷexecutableΛ௥Ճ // swift-tools-version: 5.6

    // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "oss-forward-workshop", products: [ .executable(name: "oss-forward-workshop", targets: ["oss-forward-workshop"]) ], dependencies: [ .package(name: "swift-argument-parser", path: "/path/to/repo/swift-argument-parser"), ], targets: [ .target(name: "oss-forward-workshop", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), ]) ] ) 48/51
  50. oss-forward-workshop/main.swift import ArgumentParser struct MyCommand: ParsableCommand { static var configuration

    = CommandConfiguration( commandName: "my-command", abstract: "My first command", discussion: "Hello", version: "1.0.0", shouldDisplay: true, helpNames: [.long, .short] ) func run() throws { print("Hello, World!") } } MyCommand.main() 49/51
  51. $ swift run oss-forward-workshop --help OVERVIEW: My first command Hello

    USAGE: my-command OPTIONS: --version Show the version. -h, --help Show help information. 50/51
  52. ͦͷଞ • ྺ࢙ͷ͋Δπʔϧ (fastlane/CocoaPods/danger/xcprettyͳͲ)͸ RubyͰॻ͔Ε͍ͯΔ͜ͱ͕ଟ͘ɺRuby։ൃͷσόοάख๏͕໾ ʹཱͭ • pry, rspec, rubygems

    • ௅ઓ͢Δํ͸ฉ͍͍ͯͩ͘͞ 51/51