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

ChatBotの重いタスクをCircleCIに持っていってみた / How to move h...

mackee
January 16, 2020

ChatBotの重いタスクをCircleCIに持っていってみた / How to move heavy tasks on ChatBot to CircleCI

CircleCI ユーザーコミュニティミートアップ#8
https://circleci.connpass.com/event/157469/

mackee

January 16, 2020
Tweet

More Decks by mackee

Other Decks in Programming

Transcript

  1. CircleCIʹ͍࣋ͬͯ͘ͱ... • λεΫ͕ॏ͍৔߹͸Ωϡʔ͕٧·Δ͕Ωϡʔʹ͸ೖΔ • ແࢹ͞Εͳ͍ • εέʔϧ => ͓ۚΛ෷͑͹͢Δ •

    ฐࣾ͸Performance PlanΛܖ໿͓ͯ͠Γ·͢ • ϒϥϯν͝ͱͷλεΫඇޓ׵ੑ • ϒϥϯνͷεΫϦϓτΛ࣮ߦ͢Δ͔Βղܾ 9
  2. ͕ɺ͔͠͠ɺv1.1 API͸... • CircleCI 2.1ʹ͸ະରԠ • workflow΋ະରԠ • ͦ΋ͦ΋3/1ʹ࢖͑ͳ͘ͳΔͦ͏Ͱ͢ •

    https://circleci.com/blog/a-deprecation-notice- on-job-triggering-with-api-v1-1/ 12
  3. v2 APIͷಛ௃ • pipeline parametersͷಋೖ • 2.1 config͔Βಋೖ͞Εͨparametersͷworkflow ʹద༻Ͱ͖Δ൛ •

    workflow಺ͰjobΛىಈ͢Δͱ͖ͷparametersʹ ࢖͑ͨΓɺpipeline parametersͷঢ়ଶΛݟͯ workflowΛىಈ͢Δ͔ܾΊΒΕΔ 14
  4. 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
  5. 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