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
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
240
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
450
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
500
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
130
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
OTelCol_TailSampling_and_SpanMetrics
gumamon
1
180
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.6k
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.4k
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
610
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
Featured
See All Featured
The Language of Interfaces
destraynor
154
24k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Teambox: Starting and Learning
jrom
133
8.8k
Done Done
chrislema
181
16k
Bash Introduction
62gerente
608
210k
Ruby is Unlike a Banana
tanoku
97
11k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Adopting Sorbet at Scale
ufuk
73
9.1k
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 ϧʔϧͷίʔυԽ