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

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

    View full-size slide

  2. • GoͰAPIαʔόΛ։ൃ͍ͯ͠Δ
    • ୯ҰͷAPIΤϯυϙΠϯτͷςετͰ͸ͳͯ͘ෳ਺ͷAPIΤϯυϙΠϯτΛ·͍ͨͩ
    ςετΛॻ͖͍ͨ
    • ྫ: ϝʔϧೝূΛؚΜͩαΠϯΞοϓ
    • ྫ: γϣοϐϯάΧʔτʢ঎඼બ୒͔Βߪೖ׬ྃ·Ͱʣ
    • APIΤϯυϙΠϯτͰσʔλϕʔεૢ࡞͕͋ΔͷͰ͋Ε͹ςετσʔλϕʔεΛ༻ҙ
    ࣮ͯ͠ࡍʹಡΈॻ͖΋ൃੜ͢ΔςετΛॻ͖͍ͨ
    3
    https://github.com/k1LoW/runn
    ։ൃͷϞνϕʔγϣϯ

    View full-size slide

  3. • 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

    View full-size slide

  4. • 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
    ΞʔΩςΫνϟ

    View full-size slide

  5. 6
    γφϦΦʢRunbookʣΛॻ͘

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. • 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)

    View full-size slide

  16. 17
    https://github.com/k1LoW/runn
    As a test helper using httptest.Server

    View full-size slide

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

    View full-size slide

  18. • γφϦΦࣗମ͕ؒҧ͍ͬͯͳ͍Α͏ʹ͢Δ޻෉ͱͯ͠HTTP Runnerͷ৔߹ɺεΩʔϚʹԊͬͨόϦ
    σʔγϣϯΛಉ࣌ʹ૸ΒͤΔ࢓૊ΈΛఏڙ͍ͯ͠Δʢݱࡏ͸ OpenAPI Spec v3ͷΈରԠʣ
    • ʮͦ΋ͦ΋ͦͷγφϦΦͷϦΫΤετ͕ؒҧ͍ͬͯΔʯΛ๷͙
    • ͍ͭͰʹʮϨεϙϯε͕ؒҧ͍ͬͯΔʯ΋ݟ͚ͭΔ
    19
    https://github.com/k1LoW/runn
    Test helperͱͯ͠ͷརศੑΛ޲্ͤ͞Δ޻෉ (2/2)

    View full-size slide

  19. • ·ͩ࢖͍࢝Ίͨ͹͔Γ͕ͩɺݸਓతʹ͸େ͖Ίͷςετ͕ΧδϡΞϧʹॻ͖΍͘͢
    ͳͬͨͱײ͍ͯ͡Δ
    • σʔλϕʔεͷ஋Λ௚઀࢖༻ͨ͠ςετ͕ॻ͚Δͷ͕Τά͍͕ศར
    • ࠓճ঺հ͍ͯ͠ͳ͍Include runner΍Bind runnerͳͲʹڵຯ͕͋Δํ͸ README Λ
    ͝ཡ͍ͩ͘͞
    • ࠓޙͷల๬ͱͯ͠͸ɺgRPCରԠΛͯ͠Έ͍ͨ
    21
    https://github.com/k1LoW/runn
    ͓ΘΓʹ

    View full-size slide

  20. ࣗݾ঺հ
    ٕज़෦ɹٕज़ج൫νʔϜ
    2018೥ த్ೖࣾ
    খࢁ ݈Ұ࿠ Ken’ichiro Oyama
    গ࣮͠༻తͰখ͞ͳOSSΛॻ͘ͷ͕झຯɻ
    ● GitHub : k1LoW
    ● Twitter : @k1LoW
    22
    We are hiring!! @pb_recruit

    View full-size slide

  21. Thank You!
    Thank You!
    23

    View full-size slide

  22. • github.com/k1LoW/duration
    • “3 days 4 hours” Έ͍ͨͳจࣈྻ͔Β΋ time.Duration Λੜ੒͢Δ
    • github.com/k1LoW/expand
    • YAMLϑΝΠϧʹҰׅͰ os.ExpandEnv Λద༻ͨ͠Γ͢Δͷʹ࢖༻͍ͯ͠Δ
    25
    ͓·͚
    runnͷgo.modʹ͍ΔΦϨΦϨϥΠϒϥϦ2બ

    View full-size slide