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.4k
GolangでDockerベースのCIを作る
duck8823
3
3.5k
Other Decks in Technology
See All in Technology
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.6k
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
500
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.4k
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.9k
UI State設計とテスト方針
rmakiyama
3
790
TypeScript開発にモジュラーモノリスを持ち込む
sansantech
PRO
2
660
podman_update_2024-12
orimanabu
1
290
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
240
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
300
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
120
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
330
Storage Browser for Amazon S3
miu_crescent
1
290
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Optimising Largest Contentful Paint
csswizardry
33
3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Side Projects
sachag
452
42k
What's in a price? How to price your products and services
michaelherold
244
12k
BBQ
matthewcrist
85
9.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
How to Ace a Technical Interview
jacobian
276
23k
The Language of Interfaces
destraynor
154
24k
Visualization
eitanlees
146
15k
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 ϧʔϧͷίʔυԽ