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
2019-04-18 CircleCI Meetup Fukuoka #1
Search
Yohei Kawahara
April 18, 2019
2
8.2k
2019-04-18 CircleCI Meetup Fukuoka #1
2019 年 4 月 18 日に行われた CircleCI Meetup Fukuoka #1 でお話させて頂いた死霊です.
Yohei Kawahara
April 18, 2019
Tweet
Share
More Decks by Yohei Kawahara
See All by Yohei Kawahara
20191002_CircleCIMeetupFukuoka#2
inokappa
1
830
kix_009_20190429
inokappa
0
830
開発で使える AWS の API 操作を模倣する (OSS) ツールを探してみた/JAWS-UG Kagoshima Vol.8
inokappa
1
1.2k
隙間時間を使って exercism.io を始め隊 | リモートで勉強会 #2
inokappa
0
430
Congratulations fukuokarb#100
inokappa
0
4k
moto を 'もっと' 使おう/PyFukuoka#4
inokappa
0
4.5k
github-enterprise-user-kai-desuyone
inokappa
0
110
Elixir and AWS Tutorial
inokappa
0
550
AWS Step Functions で検討する crontabless architecture/20170824_serverless_meetup_fukuoka#1
inokappa
1
760
Featured
See All Featured
Side Projects
sachag
452
42k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Bash Introduction
62gerente
611
210k
Navigating Team Friction
lara
183
15k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
The Pragmatic Product Professional
lauravandoore
32
6.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Documentation Writing (for coders)
carmenintech
67
4.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
Making Projects Easy
brettharned
116
6k
Transcript
CircleCI ݕఆ 9 ڃ͔Β 8 ڃʹͳΓ·ͨ͠ ʙ ֎ෆग़ͷݕఆࢼݧରࡦ ʙ CircleCI
ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 @inokappa CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 1
ࣗݾհ • ͔ͬͺ (@inokappa) • גࣜձࣾ YAMAP (2019 1
݄ೖࣾ, ·ͩࢼ༻ظؒத) • ΠϯϑϥΤϯδχΞͰ͢ • ͖ͳ͏ͲΜ͝΅ఱ͏ͲΜͰ͢ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 2
ͪΐͬͱ RubyKaigi 2019 ߦ͖ͬͯ· ͨ͠ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 3
YAMAP ʹ͍ͭͯ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 4
CircleCI ͱ YAMAP • શͯͷγεςϜ͓͍ͯ, ςετσϓϩΠͰ CircleCI ͕ϑϧʹ ׆༻͞Ε͍ͯ·͢ •
ࣾΤϰΝϯδΣϦετͷ @morygonzalez ͞Μ (Γ͝Μ͞ Μ) ͷೖࣾͱڞʹಋೖ͞Ε·ͨ͠ • ͕ࣗೖࣾͨ࣌͠ʹطʹ YAMAP ͷ։ൃγεςϜͷதͰ ͳͯ͘ͳΒͳ͍ଘࡏʹͳ͍ͬͯ·ͨ͠ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 5
CircleCI ͱࢲ • YAMAP ʹೖࣾ͢Δલ Hello World ϨϕϧͰͨ͠ • YAMAP
ͷ ϑΟʔνϟʔڥ (QA ϨϏϡʔ, ৽ػೳͷ͓ࢼ ͠Ͱར༻) ͷཧΛ͞Εͨ͜ͱΛػձʹ, վΊͯ CircleCI Λ ษڧ͢͠Α͏ʹ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 6
ͯ͞, ຊ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 7
CircleCI ݕఆͱ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 8
CircleCI ݕఆͱ (1) • CircleCI ͷεΩϧΛূ໌͢ΔҝͷՍۭͷೝఆࢼݧ੍Ͱ͢ • डݧྉແྉ (CircleCI ʹແྉϓϥϯ͕͋Γ·͢)
• ͍ͭͰ, Ͳ͜Ͱ, Πϯλʔωοτ͕ແͯ͘डݧग़དྷ·͢ (CircleCI ϩʔΧϧ PC Ͱ࣮ߦग़དྷ·͢) • ӳޠ, ຊޠ, YAML Ͱडݧ͢Δ͜ͱ͕ग़དྷ·͢ (ຊޠͷυ Ωϡϝϯτ͋Γ·͢) CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 9
CircleCI ݕఆͱ (2)1 1 CircleCI ݕఆެࣜαΠτ (Ծ) ΑΓҾ༻ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ
#1 10
CircleCI ݕఆͱ (3) • 1 ڃશੈքͰ 40 ਓڧ (CircleCI ͷࣾһͱಉ)2
• 2 ڃҎԼ 10 ສਓڧ (CircleCI ͷϢʔβʔͱಉ)2 2 2018 10 ݄ௐ, CircleCI ݕఆެࣜαΠτ (Ծ) ΑΓҾ༻ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 11
CircleCI ݕఆͱ (4) • ݕఆࢼݧͷग़ൣғ CircleCI 2.0 ͱ 2.1 CircleCI
ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 12
ͱ͍͏͜ͱͰ... ֎ෆग़ͷݕఆࢼݧରࡦ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 13
ҙʂʂ ͔͜͜Β֎ෆग़ͳ༰͕ଓ͖·͢ͷͰ, εϥΠυͷࣸਅࡱӨ ͓͢Δ༰ͷ SNS ͷߘʮ͝ԕྀ͠ͳ͍ͰʯԼ͍͞. ୠ͠, શͯͷ༰͕ެࣜυΩϡϝϯτΠϯλʔωοτ্ʹଘࡏ ͓ͯ͠Γ·͢ͷͰ͝ҙԼ͍͞ !
CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 14
CircleCI Λ࢝ΊΔ (9 ڃ) ઃ 1. ҎԼͷ ( ) ͷதʹͯ·Δݴ༿ΛຒΊͳ͍͞.3
• CircleCI Λ࢝ΊΔʹ, ( (1) ) ຢ ( (2) ) ͷΞΧϯτ͕ඞཁ ʹͳΓ·͢ • ϦϙδτϦͱ CircleCI ͷ ( (3) ) Λ࿈ܞͤ͞Δඞཁ͕͋Γ·͢ 3 (1)Github, (2)BitBucket, (3)࿈ܞ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 15
CircleCI Λ࢝ΊΔ (ղઆ) CircleCI Λ࢝ΊΔʹ, Github ຢ BitBucket ͷΞΧϯτ͕ඞ ཁʹͳΓ·͢ͷͰ,
Github BitBucket ͷΞΧϯτऔಘͯ͠ ͓͖·͠ΐ͏. CircleCI ݕఆࢼݧΛडݧ͢Δҝʹઈରʹඞཁͳ४ උͰ͢. Εͳ͍Α͏ʹ͠·͠ΐ͏. ΞΧϯτΛऔಘͨ͠Β, ϦϙδτϦΛ CircleCI ϓϩδΣΫτͱ ࿈ܞͤ͞·͠ΐ͏. શͯͷϦϙδτϦͱϓϩδΣΫτ͕࿈ܞग़དྷ ΔͱݶΓ·ͤΜͷͰҙ͕ඞཁͰ͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 16
ॳΊͯͷ .circleci/config.yml (9 ڃ) ઃ 2. ҎԼ, ੈքͰ࠷γϯϓϧͳ .circleci/config.yml Ͱ͢.
( ) ͷதʹೖΔΩʔϫʔυΛ͑ͳ͍͞.4 version: ( (1) ) jobs: ( (2) ): docker: - image: docker:18.06.0-ce-git ( (3) ): - run: name: Hello world command: | echo "Hello CircleCI!!" 4 (1)2, (2)jobs, (3)steps CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 17
ॳΊͯͷ .circleci/config.yml (ղઆ) ϦϙδτϦʹ .circleci/config.yml ͱ͍͏ YAML ϑΥʔϚοτͷ ઃఆϑΝΠϧΛՃ͢Δඞཁ͕͋Γ·͢. ओཁͳΩʔ,
ҎԼͷ ௨ΓͰ͢. • version • jobs • steps CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 18
ϩʔΧϧϚγϯͰϏϧυΛ࣮ߦ͢Δ (8 ڃ) ઃ 3. ઃ 2 ͷ .circleci/config.yml Λ༻͍ͯ,
ϩʔΧϧϚγϯ ্ͰߏจͷνΣοΫͱϏϧυΛ࣮ߦ͠ͳ͍͞. • CircleCI Ͱ, circleci ͱ͍͏ίϚϯυϥΠϯπʔϧΛఏڙ͠ ͍ͯ·͢ • macOS Ͱ, Homebrew ΛͬͯΠϯετʔϧ͢Δͱྑ͍Ͱ ͠ΐ͏ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 19
ϩʔΧϧϚγϯͰϏϧυΛ࣮ߦ͢Δ (σϞ 1) • config validate ΦϓγϣϯͰߏจͷνΣοΫ $ circleci config
validate Config file at .circleci/config.yml is valid. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 20
ϩʔΧϧϚγϯͰϏϧυΛ࣮ߦ͢Δ (σϞ 2) • local execute ΦϓγϣϯͰϏϧυΛ࣮ߦ $ circleci local
execute Docker image digest: sha256:5eb8cb710920f567403cc4cbd2de16d5ab8fc9a1b4c6357d2e7137fa5f1a4f62 ====>> Spin up Environment ... தུ ... ====>> Hello world #!/bin/sh -eo pipefail echo "Hello CircleCI!!" Hello CircleCI!! Success! CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 21
CircleCI ͰϏϧυΛ࣮ߦ͢Δ (8 ڃ) ઃ 4. ઃ 3 Ͱ֬ೝͨ͠ .circleci/config.yml
Λ༻͍ͯ, CircleCI ্ͰϏϧυΛ࣮ߦ͠ͳ͍͞. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 22
CircleCI ͰϏϧυΛ࣮ߦ͢Δ (ղઆ) ϦϙδτϦͱͷ࿈ܞ͕ਖ਼͘͠ߦΘΕ͍ͯΔ߹, ϦϙδτϦʹ push ͢ΔͱϏϧυ͕࣮ߦ͞Ε·͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1
23
Ϗϧυڥʹ SSH ϩάΠϯ͢Δ (8 ڃ) ઃ 5. Ϗϧυڥʹ SSH ΛͬͯϩάΠϯ͠ͳ͍͞.
ϩάΠϯ ͨ͠Β, hello.txt ͕࡞͞Ε͍ͯΔ͜ͱΛ֬ೝ͠ͳ͍͞. • Ϗϧυڥʹ SSH ϩάΠϯ͢Δ͜ͱͰ, Ϗϧυͷσόοά ͕ߦ͑·͢ • ࣄલʹ Github ্ʹ SSH ͷެ։伴Λొ͓͖ͯ͠·͠ΐ͏ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 24
Ϗϧυڥʹ SSH ϩάΠϯ͢Δ (8 ڃ) ࣄલʹ, .circleci/config.yml ΛҎԼͷΑ͏ʹमਖ਼͓͖ͯ͠·͢. version: 2
jobs: build: docker: - image: docker:18.06.0-ce-git steps: - run: name: Hello world command: | echo "Hello CircleCI!!" > hello.txt CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 25
Ϗϧυڥʹ SSH ϩάΠϯ͢Δ (σϞ) δϣϒը໘ͷ Rerun workflow ͔Β Rerun job
with SSH Λબ ͯ͠δϣϒΛ࠶࣮ߦ͠·͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 26
Ϗϧυڥʹ SSH ϩάΠϯ͢Δ (σϞ) $ ssh -p 64536 xxx.xxx.xxx.xxx ...
ུ ... ~ # ls -al total 16 drwx------ 3 root root 4096 Apr 16 22:02 . drwxr-xr-x 43 root root 4096 Apr 16 22:01 .. -rw------- 1 root root 7 Apr 16 22:02 .ash_history drwxr-xr-x 2 root root 4096 Apr 16 22:01 project ~ # cd project/ ~/project # ls hello.txt ~/project # cat hello.txt Hello CircleCI!! ~/project # CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 27
ͪΐͬͱϒϨΠΫ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 28
CALLING MOUNTAIN CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 29
CALLING MOUNTAIN CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 30
workflows Λ͏ (7 ڃ) ઃ 6. workflows Λͬͯ, master ϒϥϯνҎ֎Ͱ
build ͕࣮ ߦ͞ΕΔΑ͏ʹ͠ͳ͍͞. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 31
workflows Λ͏ (ղઆ) • workflows Ͱ, ֤εςοϓΛδϣϒͱ͍͏୯ҐͰѻ͍·͢ • workflows Λ͏͜ͱͰ,
ྻͳεςοϓ࣮ߦ͚ͩͰͳ͘, ݅ʹԠͯ͡δϣϒΛ࣮ߦͤ͞Δ͜ͱ͕ग़དྷ·͢ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 32
workflows Λ͏ (ղઆ) ͜Ε·Ͱͷ .circleci/config.yml ʹ workflows ͱ͍͏ηΫγϣϯ ΛՃ͠·͠ΐ͏. ...
ུ ... workflows: version: 2 pr-build: jobs: - build: filters: branches: ignore: - master CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 33
workflows Λ͏ (ղઆ) ผͷϒϥϯνΛ্ͬͨͰ commit, push ͯ͠Έ·͠ΐ͏. (master)$ git checkout
-b development/demo01 Switched to a new branch 'development/demo01' (development/demo01)$ echo 'test' >> README.md (development/demo01)$ git add README.md (development/demo01)$ git commit -m 'demo' [development/demo01 6ef698f] demo 1 file changed, 1 insertion(+) (development/demo01)$ git push -u origin development/demo01 ... Branch 'development/demo01' set up to track remote branch 'development/demo01' from 'origin'. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 34
workflows Λ͏ (ղઆ) development/demo01 ϒϥϯνͰ, build ͕࣮ߦ͞Ε͍ͯ· ͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ
#1 35
ϏϧυͷޮԽ (7 ڃ) ઃ 7. ΩϟογϡΛ༻͍ͯ, Ϗϧυ࣌ؒͷॖΛݕ౼͠ͳ͍͞. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1
36
ϏϧυͷޮԽ (ղઆ) • save_cache εςοϓΛར༻͢Δ͜ͱͰ, ϥΠϒϥϦιʔε ίʔυͷΩϟογϡΛอ࣋ग़དྷ·͢ • restore_cache ʹͯ
key Ͱࢦఆͨ͠ΩϟογϡΛ෮ݩ͠· ͢ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 37
ϏϧυͷޮԽ (ղઆ) ҎԼͷΑ͏ʹ .circleci/config.yml Λमਖ਼͠·͠ΐ͏. steps: - restore_cache: key: cache-data-{{
.Branch }} ... தུ ... echo $n >> data.txt sleep 0.3 done fi - save_cache: key: cache-data-{{ .Branch }} paths: - data.txt ... ࣍ͷϖʔδ ... CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 38
ϏϧυͷޮԽ (ղઆ) ҎԼͷΑ͏ʹ .circleci/config.yml Λमਖ਼͠·͠ΐ͏. ... લͷϖʔδΑΓ ... - run:
name: Remove data.txt command: | rm -rf data.txt && sleep 5 && ls -al - restore_cache: key: cache-data-{{ .Branch }} - run: name: Restore data command: | cat data.txt CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 39
ϏϧυͷޮԽ (ղઆ) • key ʹ {{ .Branch }} {{
.Revision }} ͷςϯϓ Ϩʔτ͕ࢦఆՄೳͰ͢ • paths ʹϑΝΠϧ໊σΟϨΫτϦͷύεΛࢦఆ͠·͢ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 40
ϏϧυͷޮԽ (σϞ 1) ΩϟογϡΛࠐΜͩ͜ͱͰ, ҎԼͷΑ͏ʹॳճͷϏϧυҎ߱Ͱ ܶతʹॲཧ͕࣌ؒॖ͞Ε͍ͯ·͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 41
ϏϧυͷޮԽ (ࢼݧʹग़Δ) restore_cache Ͱ keys ͰෳͷΩϟογϡΩʔΛࢦఆՄೳ Ͱ͢. - restore_cache: keys:
- cache-data-{{ .Branch }} - cache-data CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 42
ϏϧυͷޮԽ (σϞ 2) ҎԼͷΑ͏ʹ, ࢦఆͨ͠ΩʔͷΩϟογϡ͕ଘࡏ͍ͯ͠ͳ͍߹ ʹ, restore_cache εΩοϓ͞Ε, طʹΩϟογϡΩʔ͕ଘ ࡏ͍ͯ͠Δ߹ʹ
save_cache εΩοϓ͞Ε·͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 43
ϏϧυͷޮԽ (ࢼݧʹग़Δ) ࠓͷͱ͜Ζ, ΩϟογϡΛফ͢ज़͕͋Γ·ͤΜʂ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 44
ςετͷޮԽ (7 ڃ) ઃ 8. ύϥϨϧςετΛར༻ͯ͠ςετ࣌ؒͷॖΛݕ౼͠ͳ ͍͞. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1
45
ςετͷޮԽ (ղઆ) • ςετΛϑΝΠϧ୯ҐͰׂ͢Δ͜ͱͰ, ฒߦͯ͠ςετΛ࣮ ߦ͢Δ͜ͱ͕ՄೳͰ͢ • ׂ circleci ίϚϯυΛར༻͠·͢
CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 46
ςετͷޮԽ (ղઆ) ҎԼͷΑ͏ʹ .circleci/config.yml ʹςετΛՃ͠·ͨ͠. test: parallelism: 2 docker: -
image: docker:18.06.0-ce-git steps: - checkout - run: name: Paralell Test command: | echo $(circleci tests glob "tests/*" | circleci tests split) | xargs -n 1 sh CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 47
ςετͷޮԽ (ղઆ) ςετͱݴ͍ͬͯ·͕͢, ҎԼͷΑ͏ͳγϯϓϧͳγΣϧεΫϦ ϓτͰ͢. sleep 5 echo "01" CircleCI
ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 48
ςετͷޮԽ (σϞ 1) γϦΞϧʹςετΛ࣮ߦͨ͠߹, ҎԼͷΑ͏ʹ 26 ඵֻ͔ͬͯ ͍·͢. CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ
#1 49
ςετͷޮԽ (σϞ 2) ύϥϨϧʹςετΛ࣮ߦͨ͠߹, ҎԼͷΑ͏ʹ 16 ඵ·Ͱʹ ॖ͍ͯ͠·͢ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ
#1 50
ͯ͞ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 51
͍͔͕ͩͬͨͰ͠ΐ͏͔ • CircleCI ݕఆͰࢼݧʹඞͣग़ͦ͏ͳϙΠϯτΛૡ͍ఠΜͰ͓ ͠·ͨ͠ • ·ͩ, CircleCI Λ৮ͬͨ͜ͱ͕ແ͍ํੋඇαΠϯΞοϓͯ͠ ͬͯΈ·͠ΐ͏
• υΩϡϝϯτେมॆ࣮͍ͯ͠ΔͷͰ, υΩϡϝϯτੋඇ, Λ௨͠·͠ΐ͏ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 52
͍͞͝ʹ • CircleCI ৮͍ͬͯΔͱ, ͳΜͰ CircleCI Ͱॲཧ͍ͨ͠ͱ͍͏ ཉ͕༙͍͖ͯ·͢ΑͶ • Բͤͣ৮Γଓ͚Δ͜ͱ͕ঢڃ
(্ୡ) ͷۙಓͩͱࢥ͍·͢ • օ͞Μੋඇ, ݕఆΛडݧ͠·͠ΐ͏ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 53
͓ΘΓ CircleCI ϢʔβʔίϛϡχςΟϛʔτΞοϓ #1 54