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

runn is a package/tool for running operations f...

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. • 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)
  7. • github.com/k1LoW/duration • “3 days 4 hours” Έ͍ͨͳจࣈྻ͔Β΋ time.Duration Λੜ੒͢Δ

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