Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ChatBotの重いタスクをCircleCIに持っていってみた / How to move h...
Search
mackee
January 16, 2020
Programming
1
4.1k
ChatBotの重いタスクをCircleCIに持っていってみた / How to move heavy tasks on ChatBot to CircleCI
CircleCI ユーザーコミュニティミートアップ#8
https://circleci.connpass.com/event/157469/
mackee
January 16, 2020
Tweet
Share
More Decks by mackee
See All by mackee
perl for shell, awk and sed programmers
mackee
2
1.3k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
63
マイクロサービス化を利用した Goへの移行事例
mackee
0
100
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.2k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.8k
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
mackee
0
1.1k
Go向けORM sqllaの紹介と JOINやUNIONを含んだクエリの扱い方
mackee
0
4.4k
デプロイ今昔物語 〜CGIからサーバーレスまで〜 / The deployment technics
mackee
10
12k
E2Eテストから負荷試験シナリオを作ってみた / Why do we make a scenario of load testing from E2E testing scenarios
mackee
3
5.4k
Other Decks in Programming
See All in Programming
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Outline View in SwiftUI
1024jp
1
320
イベント駆動で成長して委員会
happymana
1
320
subpath importsで始めるモック生活
10tera
0
300
Jakarta EE meets AI
ivargrimstad
0
130
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
200
最新TCAキャッチアップ
0si43
0
140
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Optimizing for Happiness
mojombo
376
70k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
It's Worth the Effort
3n
183
27k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Scaling GitHub
holman
458
140k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
GraphQLとの向き合い方2022年版
quramy
43
13k
Transcript
ChatBotͷॏ͍λεΫΛ CircleCIʹ͍࣋ͬͯͬͯΈͨ CircleCIϢʔβʔίϛϡχςΟϛʔ τΞοϓ#8 2020-01-16 ໘ന๏ਓΧϠοΫ @mackee_w 1
୭ • macopy, twitter: @mackee_w, GitHub: @mackee • ໘ന๏ਓΧϠοΫ •
αʔόαΠυΤϯδχΞ 2
͓͍ͨ͜͠ͱ CircleCIͷδϣϒ Ͳ͔͜ΒτϦΨʔ͢Δ͔ 3
ҰൠతʹϦϙδτϦͷpush 4
ChatBot͔ΒδϣϒΛΩοΫ͍ͨ͠ 5
ͳͥ => pushʹඥ͔ͳ͍λεΫ͕͋Δ • PullRequestͷϨϏϡʔΞαΠϯΨνϟ • Google Spreadsheet͔ΒCSVΛग़ྗͯ͠pushͯ͠ Pull Requestʹ͢Δ
• ςετ͕ΊͪΌॏ͍ͷͰҙͷλΠϛϯάͰςετΛ τϦΨʔ͍ͨ͠ 6
ैདྷChatBot͕͍ࣗͬͯͨ • BotPerlͰॻ͔ΕͨSlack RTMΛ͠ΌΔ܅ • ΠϕϯτۦಈͰಈ͘ϑϨʔϜϫʔΫ্ʹ͍ͬͯΔ • ίϚϯυ͕དྷΔͱλεΫ͕ॻ͔ΕͨεΫϦϓτΛىಈ ͢Δ •
͏͔ͬΓϒϩοΩϯάIOͳίʔυΛॻ͘ͱɺδϣϒ ΛฒߦͰड͚ΒΕͳ͘ͳͬͨΓɺ٧·ͬͯࢮΜͩ 7
ChatBot͕ͦͷ··λεΫΛ࣮ߦ͢Δࡍͷ • ॏ͍λεΫ͕͋Δͱ٧·Δ • ผϓϩηεʹͨ͠Βσόοά͕ҟৗʹ͘͠ͳͬͨ • εέʔϧ͠ͳ͍ SPOF • ChatBot͕ॅΉαʔόΛۀ࣌ؒதʹམͱͤͳ͍
• ϒϥϯν͝ͱͷλεΫͷඇޓͷରԠ͕ΊΜͲ͍͘͞ • chatbotͷίʔυͱϒϥϯνͷதͷίʔυͷඇޓ 8
CircleCIʹ͍࣋ͬͯ͘ͱ... • λεΫ͕ॏ͍߹Ωϡʔ͕٧·Δ͕ΩϡʔʹೖΔ • ແࢹ͞Εͳ͍ • εέʔϧ => ͓ۚΛ͑͢Δ •
ฐࣾPerformance PlanΛܖ͓ͯ͠Γ·͢ • ϒϥϯν͝ͱͷλεΫඇޓੑ • ϒϥϯνͷεΫϦϓτΛ࣮ߦ͢Δ͔Βղܾ 9
Γ͍ͨ͜ͱΛ·ͱΊΔͱ ҙͷλεΫΛ CircleCIͰ ͖ͳͱ͖ʹ࣮ߦ͍ͨ͠ʂ 10
͜͜ʹAPI͕͋Γ·͢ 11
͕ɺ͔͠͠ɺv1.1 API... • CircleCI 2.1ʹະରԠ • workflowະରԠ • ͦͦ3/1ʹ͑ͳ͘ͳΔͦ͏Ͱ͢ •
https://circleci.com/blog/a-deprecation-notice- on-job-triggering-with-api-v1-1/ 12
͜͜ʹv2 API͕͋Γ·͢ 13
v2 APIͷಛ • pipeline parametersͷಋೖ • 2.1 config͔Βಋೖ͞Εͨparametersͷworkflow ʹద༻Ͱ͖Δ൛ •
workflowͰjobΛىಈ͢Δͱ͖ͷparametersʹ ͑ͨΓɺpipeline parametersͷঢ়ଶΛݟͯ workflowΛىಈ͢Δ͔ܾΊΒΕΔ 14
config.ymlൈਮ workflows: version: 2.1 test: when: << pipeline.parameters.do_test >> jobs:
- app_test: filters: branches: only: - /^feature\/.*/ run_task: when: << pipeline.parameters.do_daiku >> jobs: - do_task: taskname: << pipeline.parameters.daiku_task >> 15
APIΛ͛ͯΈ·͠ΐ͏ my $base_uri = "https://circleci.com/api/v2/project/gh/kayac/project_name/pipeline"; my $circleci_token = $ENV{CIRCLECI_TOKEN}; my
$body = encode_json({ branch => $branch, parameters => { do_test => bool(0), do_daiku => bool(1), daiku_task => escape_task_name($job, @args), }, }); http_post "${base_uri}?circle-token=${circleci_token}", $body, headers => { "content-type" => "application/json" }, $cb; 16
·ͱΊ • ChatBot͕ͬͯͨॏͦ͏ͳλεΫΛCircleCIʹ࣋ͬ ͍ͯͬͨΑ • ͦͦChatBot͕ΔͷʹෆదͳλεΫͩͬͨ Ͷ • CircleCI v2Λ͑APIͰworkflowΛenqueueͰ͖Δ
Α 17
·ͱΊ • ϒϩάͰΞφϯε͕͋ͬͨΑ https://circleci.com/ blog/introducing-circleci-api-v2/ • ͬͱৄ͍ͪ͜͠Β https:// techblog.kayac.com/circleci-api-v2 18