$30 off During Our Annual Pro Sale. View Details »

runn is a package/tool for running operations following a scenario. / golang.tokyo #32

runn is a package/tool for running operations following a scenario. / golang.tokyo #32

Ken’ichiro Oyama

May 19, 2022
Tweet

More Decks by Ken’ichiro Oyama

Other Decks in Technology

Transcript

  1. runn is a package/tool for running operations following a scenario.

    খࢁ݈Ұ࿠ / GMO PEPABO inc. 2022.5.19 golang.tokyo #32 1
  2. 2

  3. • GoͰAPIαʔόΛ։ൃ͍ͯ͠Δ • ୯ҰͷAPIΤϯυϙΠϯτͷςετͰ͸ͳͯ͘ෳ਺ͷAPIΤϯυϙΠϯτΛ·͍ͨͩ ςετΛॻ͖͍ͨ • ྫ: ϝʔϧೝূΛؚΜͩαΠϯΞοϓ • ྫ:

    γϣοϐϯάΧʔτʢ঎඼બ୒͔Βߪೖ׬ྃ·Ͱʣ • APIΤϯυϙΠϯτͰσʔλϕʔεૢ࡞͕͋ΔͷͰ͋Ε͹ςετσʔλϕʔεΛ༻ҙ ࣮ͯ͠ࡍʹಡΈॻ͖΋ൃੜ͢ΔςετΛॻ͖͍ͨ 3 https://github.com/k1LoW/runn ։ൃͷϞνϕʔγϣϯ
  4. • runn ( means "Run N" ) is a package/tool

    for running operations following a scenario. • γφϦΦΛYAMLʹॻ͍ͯͦΕΛ࢖ͬͨςετΛ࣮ߦͰ͖Δύοέʔδ/πʔϧ • ࣮੷ͷ͋ΔΑ͘஌ΒΕ͍ͯΔπʔϧͱͯ͠͸ https://github.com/zoncoen/scenarigo ͕͋Δ • ಛ௃ͱͯ͠͸ҎԼͷ௨Γ • γφϦΦ࣮ߦͷCLIίϚϯυʢπʔϧʣͱͯ͠࢖༻Ͱ͖Δ • GoͷTest Helperʢύοέʔδʣͱͯ͠࢖༻Ͱ͖Δ • γφϦΦϑΝΠϧͷϑΥʔϚοτ͕OpenAPI SpecϥΠΫ • γφϦΦ಺ͷεςοϓؒͷ஋ͷ࿈ܞ͕ߟྀ͞Ε͍ͯΔ 4 https://github.com/k1LoW/runn runn
  5. • runn͸࠷ऴతʹ1ͭҎ্ͷγφϦΦΛ࣮ߦͯ͠ɺͦΕͧΕͷ੒ޭ/ࣦഊΛΈΔ • γφϦΦ͸1ͭҎ্ͷεςοϓ͔Βߏ੒͞Ε͍ͯΔ • 1γφϦΦ1YAMLϑΝΠϧʹͳ͍ͬͯΔʢRunbookͱݺΜͰ͍Δʣ • γφϦΦ͝ͱʹRunnerͱݺΜͰ͍Δεςοϓ࣮ߦίϯϙʔωϯτΛఆٛ͠ɺͦͷRunnerΛ࢖֤ͬͯ εςοϓΛ࣮ߦ͍ͯ͘͠ •

    Runnerʹ͸γφϦΦ಺ʹఆ͕ٛඞཁͳ௨ৗͷRunnerͱɺطʹrunnͰ༻ҙ͍ͯ͠ΔBuilt-in runnerͷ2 छྨ͕͋Δ • Runner: HTTP Runner, DB Runner • Built-in runner: Exec runner, Test runner, Dump runner, Include runner, Bind runner 5 https://github.com/k1LoW/runn ΞʔΩςΫνϟ
  6. 6 γφϦΦʢRunbookʣΛॻ͘

  7. 7 https://github.com/k1LoW/runn

  8. 8 https://github.com/k1LoW/runn

  9. 9 https://github.com/k1LoW/runn

  10. 10 https://github.com/k1LoW/runn

  11. 11 https://github.com/k1LoW/runn

  12. 12 https://github.com/k1LoW/runn

  13. 13 https://github.com/k1LoW/runn

  14. 14 https://github.com/k1LoW/runn

  15. 15 https://github.com/k1LoW/runn

  16. • runn͸Test helperͱͯ͠࢖༻͢Δͱ͖ɺγφϦΦʹఆٛͯ͠ΔRunnerΛࠩ͠ସ͑Δ͜ͱ͕Ͱ͖Δ • HTTP RunnerͷϦΫΤετઌΛ httptest.Server ͷURLʹͨ͠Γ • http.HandlerΛ౉ͯ͠௚઀

    http.Handler ʹϦΫΤετΛ౉͢Α͏ʹͨ͠Γ • DB RunnerͷΫΤϦ࣮ߦઌΛผͷςετσʔλϕʔεʹͨ͠Γ 16 https://github.com/k1LoW/runn Test helperͱͯ͠ͷརศੑΛ޲্ͤ͞Δ޻෉ (1/2)
  17. 17 https://github.com/k1LoW/runn As a test helper using httptest.Server

  18. 18 https://github.com/k1LoW/runn As a test helper with http.Handler

  19. • γφϦΦࣗମ͕ؒҧ͍ͬͯͳ͍Α͏ʹ͢Δ޻෉ͱͯ͠HTTP Runnerͷ৔߹ɺεΩʔϚʹԊͬͨόϦ σʔγϣϯΛಉ࣌ʹ૸ΒͤΔ࢓૊ΈΛఏڙ͍ͯ͠Δʢݱࡏ͸ OpenAPI Spec v3ͷΈରԠʣ • ʮͦ΋ͦ΋ͦͷγφϦΦͷϦΫΤετ͕ؒҧ͍ͬͯΔʯΛ๷͙ •

    ͍ͭͰʹʮϨεϙϯε͕ؒҧ͍ͬͯΔʯ΋ݟ͚ͭΔ 19 https://github.com/k1LoW/runn Test helperͱͯ͠ͷརศੑΛ޲্ͤ͞Δ޻෉ (2/2)
  20. ͓ΘΓʹ 20

  21. • ·ͩ࢖͍࢝Ίͨ͹͔Γ͕ͩɺݸਓతʹ͸େ͖Ίͷςετ͕ΧδϡΞϧʹॻ͖΍͘͢ ͳͬͨͱײ͍ͯ͡Δ • σʔλϕʔεͷ஋Λ௚઀࢖༻ͨ͠ςετ͕ॻ͚Δͷ͕Τά͍͕ศར • ࠓճ঺հ͍ͯ͠ͳ͍Include runner΍Bind runnerͳͲʹڵຯ͕͋Δํ͸ README

    Λ ͝ཡ͍ͩ͘͞ • ࠓޙͷల๬ͱͯ͠͸ɺgRPCରԠΛͯ͠Έ͍ͨ 21 https://github.com/k1LoW/runn ͓ΘΓʹ
  22. ࣗݾ঺հ ٕज़෦ɹٕज़ج൫νʔϜ 2018೥ த్ೖࣾ খࢁ ݈Ұ࿠ Ken’ichiro Oyama গ࣮͠༻తͰখ͞ͳOSSΛॻ͘ͷ͕झຯɻ •

    GitHub : k1LoW • Twitter : @k1LoW 22 We are hiring!! @pb_recruit
  23. Thank You! Thank You! 23

  24. 24 ͓·͚

  25. • github.com/k1LoW/duration • “3 days 4 hours” Έ͍ͨͳจࣈྻ͔Β΋ time.Duration Λੜ੒͢Δ

    • github.com/k1LoW/expand • YAMLϑΝΠϧʹҰׅͰ os.ExpandEnv Λద༻ͨ͠Γ͢Δͷʹ࢖༻͍ͯ͠Δ 25 ͓·͚ runnͷgo.modʹ͍ΔΦϨΦϨϥΠϒϥϦ2બ