Slide 1

Slide 1 text

͸ͯͳͰͷ GitHub Actions׆༻ࣄྫ CI/CD׆༻ࣄྫˍTIPSൃදձ id:papix (גࣜձࣾ͸ͯͳ)

Slide 2

Slide 2 text

ࣗݾ঺հ • papix (id:papix / @__papix__) • גࣜձࣾ͸ͯͳ WebΞϓϦέʔγϣϯΤϯδχΞ (2017೥ʙ) • ϒϩάMediaνʔϜ → ϚϯΨνʔϜ • Ұൠࣾஂ๏ਓJapan Perl Associationཧࣄ • ϒϩά: https://papix.hatena(blog.(com|jp)|diary.jp)

Slide 3

Slide 3 text

ࠓ೔࿩͢͜ͱ • ň͸ͯͳͰͷGitHub Actions׆༻ࣄྫʼn • 2ͭͷαʔϏεΛ୊ࡐʹͯ͠, ҎԼʹ͍ͭͯ࿩͠·͢: • GitHub Actions΁ͷҠߦ, ͦͷதͷ޻෉, ίετܭࢉ • GitHub ActionsͷϝϦοτ/σϝϦοτ • ͓΋͠ΖςΫ

Slide 4

Slide 4 text

୊ࡐ

Slide 5

Slide 5 text

͸ͯͳϒϩά

Slide 6

Slide 6 text

͸ͯͳϒϩάMedia

Slide 7

Slide 7 text

GigaViewer • ࣾ಺Ͱ։ൃ͍ͯ͠ΔϚϯΨϏϡʔϫ • ϒϥ΢βͰອըΛಡΉͨΊͷػೳΛఏڙ • Ϗϡʔϫ / τοϓϖʔδ / ݕࡧը໘ / ؅ཧը໘ ... • ग़൛༷ࣾ޲͚ʹఏڙ • 11ࣾ / 13ͷαΠτͰ࠾༻

Slide 8

Slide 8 text

গ೥δϟϯϓʴ גࣜձࣾूӳ༷ࣾ (https://shonenjumpplus.com/)

Slide 9

Slide 9 text

ίϛοΫDAYS גࣜձࣾߨஊ༷ࣾ (https://comic-days.com/)

Slide 10

Slide 10 text

ίϛοΫϒγϩʔυ WEB גࣜձࣾϒγϩʔυϝσΟΞ༷ (https://comicbushi-web.com/)

Slide 11

Slide 11 text

͜Ε·Ͱͷ͋Β͢͡

Slide 12

Slide 12 text

ैདྷͷCI؀ڥ • EC2্ʹߏஙͨ͠Jenkins • ։ൃʹؾΛऔΒΕͯ, Ͳ͏ͯ͠΋อक؅ཧ͕ޙճ͠ʹ͞Ε͕ͪ.. • ྺ࢙తܦҢʹΑΓ, ಉ࣌ʹ࣮ߦͰ͖ͳ͍ςετ • ಉ࣌ʹͨ͘͞Μͷpush͕ߦΘΕΔͱ, ςετ͕ऴΘΔ·Ͱ਺े෼ ଴ͭඞཁ΋...

Slide 13

Slide 13 text

GitHub.comԽͱGitHub Actionsͷొ৔ • ͦͷࠒ, GitHub EnterpriseΛGitHub.comʹஔ͖׵͑Δಈ͖͕͋ͬͨ • ͦͷྲྀΕͷதͰ, GitHub Actions΋ొ৔͖ͯͨ͠ • ň͜Ε͸࢖͏͔͠ͳ͍!!!ʼn • ...ͱ͍͏͜ͱͰ, ࠷େͷωοΫͩͬͨňςετʼnͷGitHub ActionsԽ 
 ͔ΒऔΓ૊Ή͜ͱʹͨ͠

Slide 14

Slide 14 text

GitHub Actionsͱ͸?

Slide 15

Slide 15 text

GitHub Actions • GitHub͕ఏڙ͢ΔCI/CD؀ڥ • Linux, macOS, Windows؀ڥʹରԠ • GitHub ActionsͰͷॲཧ͸ϫʔΫϑϩʔΛॻ͘ࣄͰఆٛ • ϦϙδτϦͷ .github/work f l ow σΟϨΫτϦʹYAMLͰهड़

Slide 16

Slide 16 text

GitHub Actions • GitHubͱ"ྑ͍ҙຯͰ"ີ݁߹͍ͯ͠Δ • pushͨ͠Βଈ࠲ʹॲཧΛ࣮ߦͯ͘͠ΕΔ • ྉۚ • Linuxͷ৔߹, 1෼͋ͨΓ $0.008 • GitHub Enterprise CloudͳΒ݄50,000෼ͷແྉ࿮΋͋Γ

Slide 17

Slide 17 text

ςετͷGitHub ActionsԽ

Slide 18

Slide 18 text

։ൃ؀ڥͷDockerԽ • ࠷ॳʹ։ൃ؀ڥΛDockerԽ͓͖ͯ͠·͠ΐ͏ • ࣗ෼ͷPCͰςετ͕DockerͰ׬݁͢Ε͹, GitHub ActionsͰ΋ 
 ςετ͸ͪΌΜͱಈ͘͸ͣ! • docker-compose.yml ʹඞཁͳϛυϧ΢ΣΞͳͲͷఆٛΛॻ͍ͯ, 
 docker-compose run ͰςετΛ࣮ߦͰ͖ΔΑ͏ʹ͢Δ

Slide 19

Slide 19 text

ϫʔΫϑϩʔͷߏங • ։ൃ؀ڥͷDockerԽ͕׬͍ྃͯ͠Ε͹, ͦ͏೉͘͠͸ͳ͍͸ͣ • ΠϝʔδΛϏϧυͯ͠, docker-compose runͰςετΛ࣮ߦͯ͠...

Slide 20

Slide 20 text

GitHub ActionsԽ ʙ׬ʙ

Slide 21

Slide 21 text

...ͱ, ؆୯ʹ͸͍͔ͳ͍ • ͍Ζ͍Ζߟ͑Δࣄ͕͋Δ! • ςετͷ࣌ؒΛͳΔ΂͘୹͘͢Δ • ίετͷࢼࢉ • Jenkins͔Βͷஔ͖׵͑࡞ઓ • etc...

Slide 22

Slide 22 text

࣮ߦ࣌ؒͷ࡟ݮ

Slide 23

Slide 23 text

DockerͷΠϝʔδ͸౎౓Ϗϧυ͠ͳ͍ • ňͦΓΌͦ͏ͩ!ʼnͱ͍͏ײ͡Ͱ͕͢... • ։ൃ؀ڥͷdocker imageΛECRʹొ࿥ͯ͠, ςετ͢Δ͝ͱʹ 
 ౎౓pull͢Δͱ͍͏࡞ઓ͕࢖͑Δ

Slide 24

Slide 24 text

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 ...

Slide 25

Slide 25 text

ςετͦͷ΋ͷʹ͕͔͔࣌ؒΔ • GitHub Actions͸AzureͷStandard_DS2_v2্Ͱಈ࡞͢Δ • εϖοΫ͸vCPU 2, ϝϞϦ 7GB • ී௨ʹςετΛճ͢ͱ, 1࣌ؒܦաͯ͠΋ऴΘΒͳ͍...

Slide 26

Slide 26 text

࡞ઓ • ͦ͜Ͱ, ࣍ͷΑ͏ͳ࡞ઓΛߟ͑·ͨ͠: • self-hosted runnerΛ࢖͏ • AWS CodeBuildΛ࢖͏

Slide 27

Slide 27 text

self-hosted runner • ࣗ෼͕࡞ͬͨ؀ڥͰGitHub ActionsͷॲཧΛ࣮ߦͰ͖Δ࢓૊Έ • ඞཁͳ؀ڥΛߏஙͯ͠, GitHubʹొ࿥͢Δͱར༻Ͱ͖Δ • ϦϙδτϦ/Organization/EnterpriseͷϨϕϧͰڞ༗Ͱ͖Δ • ੲ͸ϦϙδτϦ୯ҐͰ͔͠ొ࿥͕ग़དྷͳ͔ͬͨهԱ͕͋Δ

Slide 28

Slide 28 text

self-hosted runner • self-hosted runner͸جຊతʹىಈͬ͠ͺͳ͠ • = ॲཧΛ͍ͯ͠ͳͯ͘΋ίετ͕͔͔Δ • self-hosted runner 1୆ʹ͖ͭ1ͭͷॲཧ͔͠ग़དྷͳ͍ • ෳ਺ͷॲཧΛ͚ͨ͠Ε͹, ෳ਺୆ͷself-hosted runner͕ඞཁ

Slide 29

Slide 29 text

AWS CodeBuild • AWS CodeBuildͳΒ, vCPU 32, ϝϞϦ144GBͷ؀ڥ͕͋Δ! • self-hosted runnerͱҧ͍, ౎౓࣮ߦ/౎౓՝ۚ • ͨͩ, ňGitHub Actions͔ΒAWS CodeBuildΛىಈʼn͸Ͳ͏ͳͷ͔? • ͩͬͨΒňJenkins͔ΒAWS CodeBuildΛىಈʼnͰ΋ྑ͘ͳ͍? • ߋʹݴ͑͹ňAWS CodePipelineʼnͰྑ͘ͳ͍???

Slide 30

Slide 30 text

΋͏1ͭͷબ୒ࢶ • ňTravisCI ͰૈࡶʹςετΛ෼ׂ࣮ߦ͢Δʼn • https://ssig33.com/text/distributed_test_on_TravisCI • ͭ·ΓͲ͏͍͏͜ͱ͔ͱݴ͏ͱ...

Slide 31

Slide 31 text

ςετΛ16෼ׂ!!!!!

Slide 32

Slide 32 text

ϏϧυϚτϦοΫεͷ׆༻ • GitHub Actionsʹ͸ňϏϧυϚτϦοΫεʼnͱ͍͏֓೦͕͋Δ • ຊདྷ͸, Perlͷ5.32ܥ, 5.30ܥ, 5.28ܥ... ͷΑ͏ʹ, ෳ਺ͷ؀ڥͰಉ࣌ ʹςετΛ࣮ߦ͢ΔͨΊͷ΋ͷ • ͜ΕΛ࢖ͬͯ, ςετΛ16෼ׂ࣮ͯ͠ߦ͢Δ!!! • ίετ͸౰વ16ഒ͕ͩ, ͦͷ෼ૉૣ͘ऴΘΔͷͰे෼ʹϖΠ͢Δ

Slide 33

Slide 33 text

ϏϧυϚτϦοΫεͷ׆༻ • ϏϧυϚτϦοΫεͱͯ͠࿈൪Λࢦఆ • = ࿈൪ͷ਺͚ͩςετΛ෼ׂ࣮ͯ͠ߦ͢Δ • ྫ͑͹1͔Β16·Ͱͷ࿈൪ͳΒ, 16෼ׂ • f i ndΛ࢖ͬͯςετର৅ͷҰཡΛऔಘ → splitͰ෼ׂ → ࣮ߦ • ஫ҙ఺ͱͯ͠, ςετΛ෼ׂ͢Δ݁Ռ͸ႈ౳Ͱͳ͚Ε͹ͳΒͳ͍

Slide 34

Slide 34 text

ϫʔΫϑϩʔͷ ༷ࢠ 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෼ׂͷྫ

Slide 35

Slide 35 text

prepareδϣϒͷ༻ҙ • ςετΛ࣮ߦ͢Δʹ͋ͨͬͯඞཁͳॲཧ͸prepareδϣϒʹԡ͠ࠐΉ • 16෼ׂͨ͠ςετͦΕͧΕͰ࣮ߦ͢Δͱඇޮ཰ͳͨΊ • ςετ͸prepareϑΣΠζޙʹ࣮ߦ͢ΔΑ͏ʹ͢Δ • prepareδϣϒͰ༻ҙͨ͠ϑΝΠϧ͸, ଞͷδϣϒͰͦͷ··࢖͑ͳ͍ • ͋Δδϣϒͱผͷδϣϒ͸, ผͷ؀ڥͰॲཧ͕࣮ߦ͞ΕΔͨΊ • prepareδϣϒͰΩϟογϡͯ͠, ͦΕΛར༻͢ΔΑ͏ʹ͢Δ

Slide 36

Slide 36 text

ϫʔΫϑϩʔͷ ༷ࢠ 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

Slide 37

Slide 37 text

ϫʔΫϑϩʔͷ ༷ࢠ jobs : prepare : ... prepareͷॲཧ .. . test : needs: prepare # needs Ͱ prepare ʹґଘ͢Δ͜ͱΛఆٛ strategy : fail-fast: fals e matrix : id: ["01", "02", "03" ] steps : ... ςετͷॲཧ ...

Slide 38

Slide 38 text

actions/cache • ΩϟογϡपΓ͸ެࣜͷactions/cache͕͋Δ • ͦͦ͜͜ͷස౓ͰΩϟογϡͷऔಘʹࣦഊ͢Δ͜ͱ͕͋ͬͨ • 16෼ׂ͍ͯ͠Δͱ, ݁ߏͳ֬཰Ͱऔಘʹࣦഊ͢Δ • ߋʹ, ň16෼ׂͨ͠͏ͪͷࣦഊͨ͠1ͭʼnΛ࣮ߦ͢Δͷ͸ෆՄೳ • 16෼ׂ෼શͯ࠶࣮ߦ͠ͳ͚Ε͹ͳΒͳ͍...

Slide 39

Slide 39 text

papix/action-cache-s3 • https://github.com/papix/action-cache-s3 • ͦ͜Ͱ, S3Λར༻ͨ͠Ωϟογϡͷ࢓૊ΈΛ࡞ͬͨ • ͜ΕͰ, ΩϟογϡΛऔಘग़དྷͣʹࣦഊ͢Δྫ͸͍ͩͿݮͬͨ

Slide 40

Slide 40 text

͜͏ͯ͠... • ϒϩάͷςετ͸push͔ͯ͠Β7ʙ10෼Ͱऴྃ͢ΔΑ͏ʹͳΓ·ͨ͠ • ͔͠΋, GitHub Actionsͷδϣϒ͸εέʔϧ͢ΔͷͰ, ෳ਺ͷpush͕ ͋ͬͯ΋ৗʹಉ࣌ʹ૸ͬͯ͘ΕΔ! • ΄΅ϝϯςφϯεϑϦʔͰ, ։ൃମݧ͕େ෯ʹ޲্!!! • Jenkins࣌୅ͱൺ΂Δͱ, ࢼࢉͰ͸ίετ΋໿2/3ʹͳΓ·ͨ͠ • ※ ແྉ࿮Λߟྀ͠ͳ͍৔߹

Slide 41

Slide 41 text

σϝϦοτ • ϫʔΫϑϩʔ΍actionͷσόοά͕೉͍͠ • JenkinsͷΑ͏ʹ, ࣮ࡍʹαʔόʔʹೖͬͯڍಈΛݟΔ... ͱ͍͏ͷ͕ ೉͍͠ • σόοάϩΪϯάΛݩʹ, ϩά͔Βௐࠪ͢Δඞཁ͕͋Δ • tmuxͷηογϣϯΛੜ΍͢tmateͱaction-tmateΛ࢖ͬͯ 
 SSH઀ଓ͢Δ͜ͱ͸Մೳ͕ͩ...

Slide 42

Slide 42 text

GitHub Actions ͓΋͠ΖςΫ

Slide 43

Slide 43 text

Linter/Formatter + reviewdog • reviewdog • https://github.com/reviewdog/reviewdog • GitHubͳͲͷίʔυʹίϝϯτΛ࢒͢͜ͱ͕Ͱ͖Δ • Linterͷ݁ՌΛ౉͢ͱ, ܯࠂΛग़ͯ͘͠ΕΔ • ྫ rubocop: https://github.com/reviewdog/action-rubocop • work f l ow commandͰΞϊςʔγϣϯΛ෇͚Δํ๏΋͋Γ·͢

Slide 44

Slide 44 text

Perl::Critic + reviewdog • Perl::Critic • PerlͷߏจΛղੳ͠, ฆΒΘ͍͠ߏจΛࢦఠͯ͘͠ΕΔπʔϧ • Perl::CriticʹରԠͨ͠reviewdogͷaction͸ଘࡏ͠ͳ͍͕... • Perl::Criticͷग़ྗΛreviewdogʹରԠͨ͠΋ͷʹมߋ͢Ε͹OK

Slide 45

Slide 45 text

Perl::Critic + reviewdog • ৄ͘͠͸... • ňreviewdog x perlcritic x Jenkins Ͱ࠷ߴͷ GitHub ϨϏϡʔϥΠ ϑʼn • https://tech.mirrativ.stream/entry/reviewdog-perlcritic-jenkins-for-github-reviewing

Slide 46

Slide 46 text

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 %r.
(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

Slide 47

Slide 47 text

Perl::Critic + reviewdog

Slide 48

Slide 48 text

misspell + reviewdog • misspell: https://github.com/client9/misspell • GoͰॻ͔Εͨ, ϛεεϖϧΛൃݟͯ͘͠ΕΔπʔϧ • ίʔυதͷtypoΛڭ͑ͯ͘ΕΔ • reviewdog/action-misspell • Pull Requestʹࣗಈతʹίϝϯτͯ͘͠ΕΔ

Slide 49

Slide 49 text

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 '

Slide 50

Slide 50 text

reviewdog/action-misspell

Slide 51

Slide 51 text

ϥϕϧͷνΣοΫ • Pull RequestʹϥϕϧΛ͚ͭΔӡ༻ϑϩʔ • ྫ: ϦϦʔεʹΑͬͯϢʔβʔ΁ͷӨڹ͕͋Δ࣌͸ňӨڹ͋Γʼn, 
 ͦ͏Ͱͳ͍࣌͸ňӨڹͳ͠ʼnͷϥϕϧΛ͚ͭΔ • GitHub ActionsͰ, ϥϕϧͷ͚ͭ๨Εʹܯࠂ͢Δ͜ͱ΋Մೳ • https://github.com/danielchabr/pr-labels-checker

Slide 52

Slide 52 text

ϥϕϧͷ ࣗಈνΣοΫ name: label-chec k on : pull_request : jobs : check-labels : runs-on: ubuntu-lates t steps : - uses: danielchabr/pr-labels-checker@v2. 2 with : hasSome: Өڹ͋Γ,Өڹͳ͠

Slide 53

Slide 53 text

·ͱΊ

Slide 54

Slide 54 text

·ͱΊ • ͸ͯͳͰͷGitHub Actionsͷ׆༻ࣄྫΛ঺հ͠·ͨ͠ • Jenkins͔ΒGitHub ActionsʹҠߦ͢Δ͜ͱͰ, ϝϯςφϯεϑϦʔ ͳCI؀ڥΛैདྷΑΓ΋௿ίετͰ࣮ݱग़དྷΔΑ͏ʹͳΓ·ͨ͠ • GitHub ActionsͷศརͳactionΛ׆༻͢Δ͜ͱͰ, ༷ʑͳޮ཰ԽΛ 
 ࣮ݱ͢Δ͜ͱ΋ՄೳͰ͢

Slide 55

Slide 55 text

We are hiring! ͸ͯͳͰ͸, CI/CD, ͦͯࣗ͠ಈԽʹڵຯͷ͋Δ ΤϯδχΞΛืू͍ͯ͠·͢!!!! https://hatenacorp.jp/recruit/engineer