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
AWS CodePipelineでコンテナアプリをデプロイした際に、古いイメージを自動で削除する
smt7174
1
100
2024-10-30-reInventStandby_StudyGroup_Intro
shinichirokawano
1
630
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
290k
Automated Promptingを目指すその前に / Before we can aim for Automated Prompting
rkaga
0
110
「 SharePoint 難しい」ってよく聞くけど、そんなに言うなら8歳の息子に試してもらった
taichinakamura
1
620
MAMを軸とした動画ハンドリングにおけるAI活用前提の整備と次世代ビジョン / abema-ai-mam
cyberagentdevelopers
PRO
1
120
物価高なラスベガスでの過ごし方
zakky
0
380
チームを主語にしてみる / Making "Team" the Subject
ar_tama
4
310
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
130
GitHub Universe: Evaluating RAG apps in GitHub Actions
pamelafox
0
180
[JAWS-UG金沢支部×コンテナ支部合同企画]コンテナとは何か
furuton
3
260
マネジメント視点でのre:Invent参加 ~もしCEOがre:Inventに行ったら~
kojiasai
0
470
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Testing 201, or: Great Expectations
jmmastey
38
7k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Automating Front-end Workflow
addyosmani
1365
200k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.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 ϧʔϧͷίʔυԽ