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
GitHub と連携する CI を作る
Search
Shunsuke Maeda
February 21, 2019
Technology
3
2.5k
GitHub と連携する CI を作る
CI/CD TestNight #3 で発表したスライドです
Shunsuke Maeda
February 21, 2019
Tweet
Share
More Decks by Shunsuke Maeda
See All by Shunsuke Maeda
静的解析ツール detekt で任意の条件で警告させる
duck8823
1
1.3k
GolangでDockerベースのCIを作る
duck8823
3
3.4k
Other Decks in Technology
See All in Technology
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
あなたの知らない Function.prototype.toString() の世界
mizdra
PRO
2
410
SSMRunbook作成の勘所_20241120
koichiotomo
3
170
TypeScript、上達の瞬間
sadnessojisan
48
14k
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
LINEヤフーにおけるPrerender技術の導入とその効果
narirou
1
160
OS 標準のデザインシステムを超えて - より柔軟な Flutter テーマ管理 | FlutterKaigi 2024
ronnnnn
1
300
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
150
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
450
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
7
690
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
180
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
32
1.5k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Unsuck your backbone
ammeep
668
57k
The World Runs on Bad Software
bkeepers
PRO
65
11k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Writing Fast Ruby
sferik
627
61k
Building Applications with DynamoDB
mza
90
6.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
The Invisible Side of Design
smashingmag
298
50k
For a Future-Friendly Web
brad_frost
175
9.4k
Transcript
GitHub ͱ࿈ܞ͢Δ CI Λ࡞Δ CI/CD Test Night 2019.02.21 [THU] Shunsuke
Maeda (@duck8823)
ࣗݾհ • @duck8823 • ॴଐ • גࣜձࣾΤεɾΤϜɾΤε • ιϑτΣΞΤϯδχΞ •
झຯ • duck8823/duci
GitHub ͱ࿈ܞ͢Δ CI Λ࡞Δ • https://github.com/duck8823/duci
طଘͷCIͷਏ͍ͱ͜Ζ • ઃఆϑΝΠϧ • CircleCI / TravisCI / Jenkins.. •
*.yml / Jenkinsfile (= Groovy based DSL) • ϩʔΧϧͰͷ࠶ݱͷ͞ 05443d6 Fix ci setting ce8332d Fix ci setting 8c155fa Fix ci setting e6c24e0 Fix ci setting
Continuous Integration
Continuous Integration • ఆظతʹ • ϏϧυςετΛ࣮ߦ ͢Δ͜ͱͰ • ૣظʹ ϑΟʔυόοΫ
Λಘͯ όά͕ຊ൪ڥʹࠞೖ͢ΔͷΛ͙
CIͰߟ͑Δඞཁ͕͋Δ͜ͱ • ఆظతʹ • ࣮ߦλΠϛϯά • ϏϧυςετΛ࣮ߦ • ࣮ߦڥ •
ϑΟʔυόοΫ • ࣮ߦ݁Ռ
CIͷߏ • ࣮ߦλΠϛϯά • ࣮ߦڥ • ࣮ߦ݁Ռ Λૄͳ࡞Γʹ͓ͯ͘͠ͱॊೈ
CIͷߏ(ࠓճ • ࣮ߦλΠϛϯά • GitHub ͷ Webhook • ࣮ߦڥ •
Docker x λεΫϥϯφʔ • ࣮ߦ݁Ռ • GitHub ͷ Commit Status / ϩάUI
࣮ߦλΠϛϯά
࣮ߦλΠϛϯά • GitHub ͷ Webhook https://github.com/<owner>/<repo>/settings/hooks • ҙͷλΠϛϯάͰ Payload Λඈ͢
• ඇಉظͰϨεϙϯεΛฦ͞ͳ͍ͱ Timeout
GitHub ͷ Webhook • Event ͱ Action ͷΈ߹ΘͤͰλΠϛϯά੍ޚ • Event
• Webhookͷछྨ (Header: X-GitHub-Event) ྫ. push, issue_comment, pull_request • Action • Eventຖͷࡉ͔͍छྨ (JSON payload) ྫ. created, opened, synchronize
Fork ͨ͠ϦϙδτϦ͔Βͷ Pull Request • push ΠϕϯτͰऔಘͰ͖ͳ͍ => pull_request Πϕϯτͷ
synchronize Ͱऔಘ
Pull Request ͷίϝϯτ • issue_comment ͰऔಘՄೳ • Payload ʹ pull_request
ͷใ͕ͳ͍ (※ head branch/commit ͳͲ) => GitHub API Ͱऔಘ
࣮ߦڥ
࣮ߦڥ • Docker • ϗετΛԚ͞ͳ͍ • ϩʔΧϧ / CI Ͱͷಈ࡞ʹ࠶ݱੑΛͱΓ͍͢
• ϦϙδτϦ্ͷ Dockerfile Λར༻
Dockerfile FROM golang:1.11.5-alpine RUN apk --update add --no-cache alpine-sdk COPY
. . ENTRYPOINT ["make"] # λεΫϥϯφʔͷίϚϯυ ྫ. ./gradlew, mvn CMD ["test"] # σϑΥϧτͷλεΫ • docker build ͱ docker run Λ࣮ߦ • issue_comment ͷ߹ CMD ΛࢦఆՄೳ
ϩʔΧϧͰͷ࣮ߦ ಉ͡ Dockerfile ͰϩʔΧϧͰಈ࡞֬ೝ͕Ͱ͖Δ docker build -t job -f path/to/Dockerfile
. docker run --rm job [CMD]
ϗετͷϦιʔε༗ݶ • ฒྻͱλΠϜΞτ • Golang ͷ goroutine ͱ context ͕૬ੑ͕Α͍
(࣮͕ؾʹͳΔํ) https://github.com/duck8823/duci/blob/master/ application/service/executor/executor.go
࣮ߦ݁Ռ
࣮ߦ݁Ռ • GitHub ͷ Commit Status
݁Ռͷৄࡉ ϩάͷอଘͱදࣔ - Commit Status ʹৄࡉϦϯΫΛ͚ͭΔ͜ͱ͕Ͱ͖Δ
Έͳ͞Μ͕։ൃ͠ɺGitHubͰ࣮ߦ https://github.blog/jp/2018-10-24-action-demos/
Why not using GitHub Actions? A. ͍ͬͯ·͢
GitHub Actions ͷΠέͯΔͱ͜Ζ GITHUB_TOKEN Λ͍ग़ͯ͘͠ΕΔ = Personal Access Token (Bot
Account) ͕͍Βͳ͍
GitHub Actions ͷ࣮ߦλΠϛϯά (Event • Event ͷछྨ Webhook ͱجຊతʹಉ͡ •
GitHub Actions https://developer.github.com/actions/creating- workflows/workflow-configuration-options/#events- supported-in-workflow-files • Webhooks https://developer.github.com/webhooks/#events
GitHub Actions ͷ࣮ߦλΠϛϯά (Action • Webhook ͷ Payload ͱಉͷ JSON
͕ஔ͞ΕΔ ڥม GITHUB_EVENT_PATH • ެࣜͷ Filter • action Ͱ filter actions/bin
·ͱΊ • CI࡞ΕΔ • ࣮ߦλΠϛϯά / ࣮ߦڥ / ࣮ߦ݁Ռ •
GitHub Actions ͍͍ͧ • CIΛ࡞ͬͨࣝ͑Δ
CIΛ࡞ͬͯΈΑ͏
͓·͚ Danger Λ GitHub Actions Ͱ͑ΔΑ͏ʹ͠·ͨ͠ • Pull Request ͷνΣοΫΛࣗಈԽ͢ΔͨΊͷج൫
= Pull Request ϧʔϧͷίʔυԽ