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.4k
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
【技術書典17】OpenFOAM(自宅で極める流体解析)2次元円柱まわりの流れ
kamakiri1225
0
220
Shift-from-React-to-Vue
calm1205
3
1.3k
プロダクトチームへのSystem Risk Records導入・運用事例の紹介/Introduction and Case Studies on Implementing and Operating System Risk Records for Product Teams
taddy_919
1
170
生成AIの強みと弱みを理解して、生成AIがもたらすパワーをプロダクトの価値へ繋げるために実践したこと / advance-ai-generating
cyberagentdevelopers
PRO
1
180
Commitment vs Harrisonism - Keynote for Scrum Niseko 2024
miholovesq
6
1.1k
Figma Dev Modeで進化するデザインとエンジニアリングの協働 / figma-with-engineering
cyberagentdevelopers
PRO
1
430
新卒1年目が向き合う生成AI事業の開発を加速させる技術選定 / ai-web-launcher
cyberagentdevelopers
PRO
7
1.5k
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.6k
一休.comレストランにおけるRustの活用
kymmt90
3
580
バクラクにおける可観測性向上の取り組み
yuu26
3
420
国土交通省 データコンペ参加者向け勉強会
takehikohashimoto
0
110
Gradle: The Build System That Loves To Hate You
aurimas
2
150
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
107
49k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Being A Developer After 40
akosma
86
590k
Bash Introduction
62gerente
608
210k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Scaling GitHub
holman
458
140k
Designing the Hi-DPI Web
ddemaree
280
34k
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 ϧʔϧͷίʔυԽ