Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
はてなにおけるGitHub Actions活用事例 / GitHub Actions in Hatena
papix
January 26, 2021
Technology
0
1.3k
はてなにおけるGitHub Actions活用事例 / GitHub Actions in Hatena
papix
January 26, 2021
Tweet
Share
More Decks by papix
See All by papix
イベントの中の人 / Inside the Events
papix
0
19
2022年に始めるPerlでWebサービス開発(趣味)
papix
0
300
ワーケーションに関する考察
papix
3
1.7k
(今更)Amplifyさっくり体験
papix
0
750
ミススペルを発見するmisspellのご紹介 / Introduce misspell
papix
0
740
「知らなかった」を聞きに行く 〜海外カンファレンス参加のススメ〜 / builderscon 2019
papix
0
260
Perl in Japan
papix
0
2.1k
Perlでもトレーシングがしたい! 〜はてなブログの"見える化"への挑戦〜 / Tracing in Perl
papix
1
1k
1on1をするときに考えていること / 1on1
papix
0
1.1k
Other Decks in Technology
See All in Technology
Astroで始める爆速個人サイト開発
takanorip
12
8.2k
大企業がアジャイルになる途中で 起きること/What happens on the way big company becomes agile
chinmo
0
2.7k
マネーフォワードクラウドを支える事業者基盤
machisuke
0
210
Cloudflare Workersで動くOG画像生成器
aiji42
1
430
JAWS-UG朝会_41_NakagawaAkihiro.pptx.pdf
anakagawa
2
610
証明書って何だっけ? 〜AWSの中間CA移行に備える〜
minorun365
3
1.9k
音をアレする
koba789
0
330
20230117_JAWS-UG_朝会_41_LT資料
tsumita
0
290
Kubernetes_EKSに入門してみる
toru_kubota
0
220
テクニカルライターよ概念図を描くのです 〜テクニカルライターのためのイラストテクニック2〜 / cybozu illust technique2
yuki_kondo
13
3.6k
UNIX は知らない。でも AWS は知ってる。 そんな僕が『 UNIX という考え方』を 読んでみた件
kentosuzuki
1
270
MoT/コネヒト/Kanmu が語るプロダクト開発xデータ分析 - 分析から機械学習システムの開発まで一人で複数ロールを担う大変さ
masatakashiwagi
2
520
Featured
See All Featured
The Language of Interfaces
destraynor
149
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
317
22k
Design by the Numbers
sachag
271
18k
The Straight Up "How To Draw Better" Workshop
denniskardys
226
130k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
175
9.1k
Faster Mobile Websites
deanohume
295
29k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
109
16k
Imperfection Machines: The Place of Print at Facebook
scottboms
254
12k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Code Reviewing Like a Champion
maltzj
508
38k
What's in a price? How to price your products and services
michaelherold
233
9.7k
Writing Fast Ruby
sferik
613
58k
Transcript
ͯͳͰͷ GitHub Actions׆༻ࣄྫ CI/CD׆༻ࣄྫˍTIPSൃදձ id:papix (גࣜձࣾͯͳ)
ࣗݾհ • papix (id:papix / @__papix__) • גࣜձࣾͯͳ WebΞϓϦέʔγϣϯΤϯδχΞ (2017ʙ)
• ϒϩάMediaνʔϜ → ϚϯΨνʔϜ • Ұൠࣾஂ๏ਓJapan Perl Associationཧࣄ • ϒϩά: https://papix.hatena(blog.(com|jp)|diary.jp)
ࠓ͢͜ͱ • ňͯͳͰͷGitHub Actions׆༻ࣄྫʼn • 2ͭͷαʔϏεΛࡐʹͯ͠, ҎԼʹ͍ͭͯ͠·͢: • GitHub ActionsͷҠߦ,
ͦͷதͷ, ίετܭࢉ • GitHub ActionsͷϝϦοτ/σϝϦοτ • ͓͠ΖςΫ
ࡐ
ͯͳϒϩά
ͯͳϒϩάMedia
GigaViewer • ࣾͰ։ൃ͍ͯ͠ΔϚϯΨϏϡʔϫ • ϒϥβͰອըΛಡΉͨΊͷػೳΛఏڙ • Ϗϡʔϫ / τοϓϖʔδ /
ݕࡧը໘ / ཧը໘ ... • ग़൛༷͚ࣾʹఏڙ • 11ࣾ / 13ͷαΠτͰ࠾༻
গδϟϯϓʴ גࣜձࣾूӳ༷ࣾ (https://shonenjumpplus.com/)
ίϛοΫDAYS גࣜձࣾߨஊ༷ࣾ (https://comic-days.com/)
ίϛοΫϒγϩʔυ WEB גࣜձࣾϒγϩʔυϝσΟΞ༷ (https://comicbushi-web.com/)
͜Ε·Ͱͷ͋Β͢͡
ैདྷͷCIڥ • EC2্ʹߏஙͨ͠Jenkins • ։ൃʹؾΛऔΒΕͯ, Ͳ͏ͯ͠อकཧ͕ޙճ͠ʹ͞Ε͕ͪ.. • ྺ࢙తܦҢʹΑΓ, ಉ࣌ʹ࣮ߦͰ͖ͳ͍ςετ •
ಉ࣌ʹͨ͘͞Μͷpush͕ߦΘΕΔͱ, ςετ͕ऴΘΔ·Ͱे ͭඞཁ...
GitHub.comԽͱGitHub Actionsͷొ • ͦͷࠒ, GitHub EnterpriseΛGitHub.comʹஔ͖͑Δಈ͖͕͋ͬͨ • ͦͷྲྀΕͷதͰ, GitHub Actionsొ͖ͯͨ͠
• ň͜Ε͏͔͠ͳ͍!!!ʼn • ...ͱ͍͏͜ͱͰ, ࠷େͷωοΫͩͬͨňςετʼnͷGitHub ActionsԽ ͔ΒऔΓΉ͜ͱʹͨ͠
GitHub Actionsͱ?
GitHub Actions • GitHub͕ఏڙ͢ΔCI/CDڥ • Linux, macOS, WindowsڥʹରԠ • GitHub
ActionsͰͷॲཧϫʔΫϑϩʔΛॻ͘ࣄͰఆٛ • ϦϙδτϦͷ .github/work f l ow σΟϨΫτϦʹYAMLͰهड़
GitHub Actions • GitHubͱ"ྑ͍ҙຯͰ"ີ݁߹͍ͯ͠Δ • pushͨ͠Βଈ࠲ʹॲཧΛ࣮ߦͯ͘͠ΕΔ • ྉۚ • Linuxͷ߹,
1͋ͨΓ $0.008 • GitHub Enterprise CloudͳΒ݄50,000ͷແྉ͋Γ
ςετͷGitHub ActionsԽ
։ൃڥͷDockerԽ • ࠷ॳʹ։ൃڥΛDockerԽ͓͖ͯ͠·͠ΐ͏ • ࣗͷPCͰςετ͕DockerͰ݁͢Ε, GitHub ActionsͰ ςετͪΌΜͱಈͣ͘! •
docker-compose.yml ʹඞཁͳϛυϧΣΞͳͲͷఆٛΛॻ͍ͯ, docker-compose run ͰςετΛ࣮ߦͰ͖ΔΑ͏ʹ͢Δ
ϫʔΫϑϩʔͷߏங • ։ൃڥͷDockerԽ͕͍ྃͯ͠Ε, ͦ͏͘͠ͳ͍ͣ • ΠϝʔδΛϏϧυͯ͠, docker-compose runͰςετΛ࣮ߦͯ͠...
GitHub ActionsԽ ʙʙ
...ͱ, ؆୯ʹ͍͔ͳ͍ • ͍Ζ͍Ζߟ͑Δࣄ͕͋Δ! • ςετͷ࣌ؒΛͳΔ͘͘͢Δ • ίετͷࢼࢉ • Jenkins͔Βͷஔ͖͑࡞ઓ
• etc...
࣮ߦ࣌ؒͷݮ
DockerͷΠϝʔδϏϧυ͠ͳ͍ • ňͦΓΌͦ͏ͩ!ʼnͱ͍͏ײ͡Ͱ͕͢... • ։ൃڥͷdocker imageΛECRʹొͯ͠, ςετ͢Δ͝ͱʹ pull͢Δͱ͍͏࡞ઓ͕͑Δ
ECR͔Β pull͢Δྫ name: tes t on : pull_request : jobs
: test : - uses: actions/
[email protected]
4 - name: Configure AWS Credential s uses: aws-actions/configure-aws-
[email protected]
5 with: .. . - name: Login to Amazon EC R uses: aws-actions/
[email protected]
1 - name: Pull from EC R run: docker pull ...
ςετͦͷͷʹ͕͔͔࣌ؒΔ • GitHub ActionsAzureͷStandard_DS2_v2্Ͱಈ࡞͢Δ • εϖοΫvCPU 2, ϝϞϦ 7GB •
ී௨ʹςετΛճ͢ͱ, 1࣌ؒܦաͯ͠ऴΘΒͳ͍...
࡞ઓ • ͦ͜Ͱ, ࣍ͷΑ͏ͳ࡞ઓΛߟ͑·ͨ͠: • self-hosted runnerΛ͏ • AWS CodeBuildΛ͏
self-hosted runner • ͕ࣗ࡞ͬͨڥͰGitHub ActionsͷॲཧΛ࣮ߦͰ͖ΔΈ • ඞཁͳڥΛߏஙͯ͠, GitHubʹొ͢Δͱར༻Ͱ͖Δ • ϦϙδτϦ/Organization/EnterpriseͷϨϕϧͰڞ༗Ͱ͖Δ
• ੲϦϙδτϦ୯ҐͰ͔͠ొ͕ग़དྷͳ͔ͬͨهԱ͕͋Δ
self-hosted runner • self-hosted runnerجຊతʹىಈͬ͠ͺͳ͠ • = ॲཧΛ͍ͯ͠ͳͯ͘ίετ͕͔͔Δ • self-hosted
runner 1ʹ͖ͭ1ͭͷॲཧ͔͠ग़དྷͳ͍ • ෳͷॲཧΛ͚ͨ͠Ε, ෳͷself-hosted runner͕ඞཁ
AWS CodeBuild • AWS CodeBuildͳΒ, vCPU 32, ϝϞϦ144GBͷڥ͕͋Δ! • self-hosted
runnerͱҧ͍, ࣮ߦ/՝ۚ • ͨͩ, ňGitHub Actions͔ΒAWS CodeBuildΛىಈʼnͲ͏ͳͷ͔? • ͩͬͨΒňJenkins͔ΒAWS CodeBuildΛىಈʼnͰྑ͘ͳ͍? • ߋʹݴ͑ňAWS CodePipelineʼnͰྑ͘ͳ͍???
͏1ͭͷબࢶ • ňTravisCI ͰૈࡶʹςετΛׂ࣮ߦ͢Δʼn • https://ssig33.com/text/distributed_test_on_TravisCI • ͭ·ΓͲ͏͍͏͜ͱ͔ͱݴ͏ͱ...
ςετΛ16ׂ!!!!!
ϏϧυϚτϦοΫεͷ׆༻ • GitHub ActionsʹňϏϧυϚτϦοΫεʼnͱ͍͏֓೦͕͋Δ • ຊདྷ, Perlͷ5.32ܥ, 5.30ܥ, 5.28ܥ... ͷΑ͏ʹ,
ෳͷڥͰಉ࣌ ʹςετΛ࣮ߦ͢ΔͨΊͷͷ • ͜ΕΛͬͯ, ςετΛ16ׂ࣮ͯ͠ߦ͢Δ!!! • ίετવ16ഒ͕ͩ, ͦͷૉૣ͘ऴΘΔͷͰेʹϖΠ͢Δ
ϏϧυϚτϦοΫεͷ׆༻ • ϏϧυϚτϦοΫεͱͯ͠࿈൪Λࢦఆ • = ࿈൪ͷ͚ͩςετΛׂ࣮ͯ͠ߦ͢Δ • ྫ͑1͔Β16·Ͱͷ࿈൪ͳΒ, 16ׂ •
f i ndΛͬͯςετରͷҰཡΛऔಘ → splitͰׂ → ࣮ߦ • ҙͱͯ͠, ςετΛׂ͢Δ݁ՌႈͰͳ͚ΕͳΒͳ͍
ϫʔΫϑϩʔͷ ༷ࢠ jobs : test : strategy : # ׂͨ͠ςετͷ͏ͪ,
1͕ͭίέͯଞͷશͯΛcancel͠ͳ͍Α͏ʹ͢Δ fail-fast: fals e matrix : test_id: ["01", "02", "03"] # ࿈൪Λࢦఆ steps : ... ॾʑͷ४උ .. . # findͱsplitΛͬͯ, ςετରͱͳΔϑΝΠϧ໊͕ॻ͔Εͨ # test01, test02, test03 ͱ͍͏ϑΝΠϧΛ࡞ - name: Split tests into chunk s run: | find t -name "*.t" -not -type d > test_files.tx t split -n r/${{ strategy.job-total }} \ --numeric-suffixes=1 \ --elide-empty-files test_files.txt tes t # ↑Ͱ࡞ͬͨ test01, test02, test03ͷ͍ͣΕ͔Λରͱͯ͠ # ςετΛ࣮ߦ͢Δ - name: tes t run: | docker-compose run --rm --no-deps app \ carton exec -- prove < test${{ matrix.test_id }} ※ 3ׂͷྫ
prepareδϣϒͷ༻ҙ • ςετΛ࣮ߦ͢Δʹ͋ͨͬͯඞཁͳॲཧprepareδϣϒʹԡ͠ࠐΉ • 16ׂͨ͠ςετͦΕͧΕͰ࣮ߦ͢ΔͱඇޮͳͨΊ • ςετprepareϑΣΠζޙʹ࣮ߦ͢ΔΑ͏ʹ͢Δ • prepareδϣϒͰ༻ҙͨ͠ϑΝΠϧ, ଞͷδϣϒͰͦͷ··͑ͳ͍
• ͋Δδϣϒͱผͷδϣϒ, ผͷڥͰॲཧ͕࣮ߦ͞ΕΔͨΊ • prepareδϣϒͰΩϟογϡͯ͠, ͦΕΛར༻͢ΔΑ͏ʹ͢Δ
ϫʔΫϑϩʔͷ ༷ࢠ jobs : prepare : runs-on: ubuntu-20.0 4 steps
: - uses: actions/
[email protected]
4 - name: Configure AWS Credential s uses: aws-actions/configure-aws-
[email protected]
5 with: .. . # path-to-cache ͱ͍͏ϑΝΠϧΛ # Ωϟογϡ͢Δྫ - uses: papix/
[email protected]
3 env: .. . with : bucket: ${{ env.cache-bucket } } key: ${{ hashFiles('path-to-cache') } } path: path-to-cach e
ϫʔΫϑϩʔͷ ༷ࢠ jobs : prepare : ... prepareͷॲཧ .. .
test : needs: prepare # needs Ͱ prepare ʹґଘ͢Δ͜ͱΛఆٛ strategy : fail-fast: fals e matrix : id: ["01", "02", "03" ] steps : ... ςετͷॲཧ ...
actions/cache • ΩϟογϡपΓެࣜͷactions/cache͕͋Δ • ͦͦ͜͜ͷසͰΩϟογϡͷऔಘʹࣦഊ͢Δ͜ͱ͕͋ͬͨ • 16ׂ͍ͯ͠Δͱ, ݁ߏͳ֬Ͱऔಘʹࣦഊ͢Δ • ߋʹ,
ň16ׂͨ͠͏ͪͷࣦഊͨ͠1ͭʼnΛ࣮ߦ͢ΔͷෆՄೳ • 16ׂશͯ࠶࣮ߦ͠ͳ͚ΕͳΒͳ͍...
papix/action-cache-s3 • https://github.com/papix/action-cache-s3 • ͦ͜Ͱ, S3Λར༻ͨ͠ΩϟογϡͷΈΛ࡞ͬͨ • ͜ΕͰ, ΩϟογϡΛऔಘग़དྷͣʹࣦഊ͢Δྫ͍ͩͿݮͬͨ
͜͏ͯ͠... • ϒϩάͷςετpush͔ͯ͠Β7ʙ10Ͱऴྃ͢ΔΑ͏ʹͳΓ·ͨ͠ • ͔͠, GitHub Actionsͷδϣϒεέʔϧ͢ΔͷͰ, ෳͷpush͕ ͋ͬͯৗʹಉ࣌ʹͬͯ͘ΕΔ! •
΄΅ϝϯςφϯεϑϦʔͰ, ։ൃମݧ͕େ෯ʹ্!!! • Jenkins࣌ͱൺΔͱ, ࢼࢉͰίετ2/3ʹͳΓ·ͨ͠ • ※ ແྉΛߟྀ͠ͳ͍߹
σϝϦοτ • ϫʔΫϑϩʔactionͷσόοά͕͍͠ • JenkinsͷΑ͏ʹ, ࣮ࡍʹαʔόʔʹೖͬͯڍಈΛݟΔ... ͱ͍͏ͷ͕ ͍͠ • σόοάϩΪϯάΛݩʹ,
ϩά͔Βௐࠪ͢Δඞཁ͕͋Δ • tmuxͷηογϣϯΛੜ͢tmateͱaction-tmateΛͬͯ SSHଓ͢Δ͜ͱՄೳ͕ͩ...
GitHub Actions ͓͠ΖςΫ
Linter/Formatter + reviewdog • reviewdog • https://github.com/reviewdog/reviewdog • GitHubͳͲͷίʔυʹίϝϯτΛ͢͜ͱ͕Ͱ͖Δ •
Linterͷ݁ՌΛ͢ͱ, ܯࠂΛग़ͯ͘͠ΕΔ • ྫ rubocop: https://github.com/reviewdog/action-rubocop • work f l ow commandͰΞϊςʔγϣϯΛ͚Δํ๏͋Γ·͢
Perl::Critic + reviewdog • Perl::Critic • PerlͷߏจΛղੳ͠, ฆΒΘ͍͠ߏจΛࢦఠͯ͘͠ΕΔπʔϧ • Perl::CriticʹରԠͨ͠reviewdogͷactionଘࡏ͠ͳ͍͕...
• Perl::Criticͷग़ྗΛreviewdogʹରԠͨ͠ͷʹมߋ͢ΕOK
Perl::Critic + reviewdog • ৄ͘͠... • ňreviewdog x perlcritic x
Jenkins Ͱ࠷ߴͷ GitHub ϨϏϡʔϥΠ ϑʼn • https://tech.mirrativ.stream/entry/reviewdog-perlcritic-jenkins-for-github-reviewing
GitHub ActionsͰ Perl::CriticΛ͏ name: criti c on : pull_request :
critic : runs-on: ubuntu-lates t steps : - uses: actions/
[email protected]
4 - name: Setup reviewdo g uses: reviewdog/
[email protected]
2 - name: Criticiz e run: | perlcritic --profile .perlcriticrc --verbose '%f:%l:%c:**%m**, near <code>%r</code>.<br>(Ref: [%p] (https://metacpan.org/pod/Perl::Critic::Policy::%p))\n' lib t | reviewdog -efm=%f:%l:%c:%m -name=perlcritic -reporter=github-pr-review
Perl::Critic + reviewdog
misspell + reviewdog • misspell: https://github.com/client9/misspell • GoͰॻ͔Εͨ, ϛεεϖϧΛൃݟͯ͘͠ΕΔπʔϧ •
ίʔυதͷtypoΛڭ͑ͯ͘ΕΔ • reviewdog/action-misspell • Pull Requestʹࣗಈతʹίϝϯτͯ͘͠ΕΔ
GitHub ActionsͰ misspellΛ͏ name: misspel l on : pull_request :
jobs : misspell : runs-on: ubuntu-lates t steps : - uses: actions/
[email protected]
4 - name: misspel l uses: reviewdog/
[email protected]
0 with : reporter: 'github-pr-review '
reviewdog/action-misspell
ϥϕϧͷνΣοΫ • Pull RequestʹϥϕϧΛ͚ͭΔӡ༻ϑϩʔ • ྫ: ϦϦʔεʹΑͬͯϢʔβʔͷӨڹ͕͋Δ࣌ňӨڹ͋Γʼn, ͦ͏Ͱͳ͍࣌ňӨڹͳ͠ʼnͷϥϕϧΛ͚ͭΔ •
GitHub ActionsͰ, ϥϕϧͷ͚ͭΕʹܯࠂ͢Δ͜ͱՄೳ • https://github.com/danielchabr/pr-labels-checker
ϥϕϧͷ ࣗಈνΣοΫ name: label-chec k on : pull_request : jobs
: check-labels : runs-on: ubuntu-lates t steps : - uses: danielchabr/
[email protected]
2 with : hasSome: Өڹ͋Γ,Өڹͳ͠
·ͱΊ
·ͱΊ • ͯͳͰͷGitHub Actionsͷ׆༻ࣄྫΛհ͠·ͨ͠ • Jenkins͔ΒGitHub ActionsʹҠߦ͢Δ͜ͱͰ, ϝϯςφϯεϑϦʔ ͳCIڥΛैདྷΑΓίετͰ࣮ݱग़དྷΔΑ͏ʹͳΓ·ͨ͠ •
GitHub ActionsͷศརͳactionΛ׆༻͢Δ͜ͱͰ, ༷ʑͳޮԽΛ ࣮ݱ͢Δ͜ͱՄೳͰ͢
We are hiring! ͯͳͰ, CI/CD, ͦͯࣗ͠ಈԽʹڵຯͷ͋Δ ΤϯδχΞΛืू͍ͯ͠·͢!!!! https://hatenacorp.jp/recruit/engineer