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.2k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
60
マイクロサービス化を利用した Goへの移行事例
mackee
0
100
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.1k
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.3k
デプロイ今昔物語 〜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
Tuning GraphQL on Rails
pyama86
2
1.2k
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
440
距離関数を極める! / SESSIONS 2024
gam0022
0
220
Contemporary Test Cases
maaretp
0
120
Amazon Qを使ってIaCを触ろう!
maruto
0
390
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
470
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
560
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
現場で役立つモデリング 超入門
masuda220
PRO
15
3.1k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Realtime API 入門
riofujimon
0
150
Quine, Polyglot, 良いコード
qnighy
4
630
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
RailsConf 2023
tenderlove
29
900
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Code Review Best Practice
trishagee
64
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Happy Clients
brianwarren
98
6.7k
It's Worth the Effort
3n
183
27k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Thoughts on Productivity
jonyablonski
67
4.3k
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