Slide 1

Slide 1 text

self-hosted runnerと actions/cache の噛み合わせが悪かった件 株式会社サイバーエージェント CIU Development div 
 Nakanishi Kento @whywaita GitHub Actions Meetup Tokyo # 2 @ サイボウズ株式会社 2023/09/21

Slide 2

Slide 2 text

Nakanishi Kento / whywaita • 株式会社サイバーエージェント 2019新卒 • 業務: CAグループ向けプライベートクラウド開発 • GitHub Actions ベースCIサービス 
 (Managed myshoes) PM • 社内向け IaaS 開発者 • 趣味: ポーカー / XREAL Air / ⾃宅インフラ ISUCON本買ってね! #isucon →

Slide 3

Slide 3 text

本⽇ • スライド: 48枚 • 発表時間: 10分 = 600秒 • 12.5秒/枚!!!!!! 3

Slide 4

Slide 4 text

周辺知識 4

Slide 5

Slide 5 text

action/cache • https://github.com/actions/cache • 依存ライブラリのファイルをキャッシュす ることでCI時間を短くするモジュール • 任意のファイルを保存できる • 1 0 GB / repo まで無料 5

Slide 6

Slide 6 text

self-hosted runner • ↔ GitHub-hosted runner • ⾃前のインフラでrunner起動するやつ • ⾃宅 社内サーバ プライベートクラウド... • ネットワーク CPU メモリなど嬉しい要素 6

Slide 7

Slide 7 text

[PR] whywaita/myshoes • Auto-scaling VirtualMachine runner 🏃 for GitHub Actions • 様々なクラウドでrunnerを作成可能 • https://github.com/whywaita/myshoes 7

Slide 8

Slide 8 text

[PR] Cycloud 8 •Cy(berAgent)cloud •各種サービスの提供 •IaaS / KaaS / PaaS / ML Platform •Cycloud-hosted runner (myshoes)

Slide 9

Slide 9 text

9 https://www.cyberagent.co.jp/news/detail/id= 2 84 8 4

Slide 10

Slide 10 text

10 https://isucon.net/archives/ 55 5 3 3 0 13 .html

Slide 11

Slide 11 text

[PR] Cycloud-hosted runner • Cycloud VMをStadiumとしGitHub-hostedよりも安価に 提供 • LXDイメージはGitHub-hostedとほぼ同じイメージを利⽤ • https://github.com/whywaita/actions-runner-images- lxd • runnerスペック 2Core 20 GB ~ 16 Core 1 60 GB 11

Slide 12

Slide 12 text

[PR] 規模感 • Stadium台数: 約80台 ( 1 6 c 160 gb) • 導⼊数: エンジニアの50% が利⽤! • アカウント数ベース • Linux版GAから: 1年8ヶ⽉ • 1⽇の実⾏job数: 約1万個 • 常時500〜700インスタンスぐらい 12

Slide 13

Slide 13 text

13 https://speakerdeck.com/whywaita/evolution-myshoes-cicd-test-night- 6

Slide 14

Slide 14 text

14 Internal actions/cache

Slide 15

Slide 15 text

GitHub owned by Microsoft • GitHub Actionsのバックエンドは 
 (現状)ほぼAzure Pipelines • 関連サービスもAzureの製品を⽤いて実装 されている(ことが多い) 15

Slide 16

Slide 16 text

GitHub owned by Microsoft trigger: - main pool: vmImage: 'ubuntu-latest' steps: - task: Maven@4 inputs: mavenPomFile: 'pom.xml' mavenOptions: '-Xmx3072m' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.11' jdkArchitectureOption: 'x64' 16 https://learn.microsoft.com/ja-jp/azure/devops/pipelines/customize-pipeline?view=azure-devops

Slide 17

Slide 17 text

ぽい 17

Slide 18

Slide 18 text

GitHub owned by Microsoft • (whywaita 調べ) • GitHub Actionsのバックエンドは 
 (現状)ほぼAzure Pipelines • 関連サービスもAzureの製品を⽤いて実装 されている(ことが多い) 18

Slide 19

Slide 19 text

GitHub owned by Microsoft • (whywaita 調べ) • GitHub Actionsのバックエンドは 
 (現状)ほぼAzure Pipelines • 関連サービスもAzureの製品を⽤いて実装 されている(ことが多い) 19

Slide 20

Slide 20 text

actions/cache internal • actions/cache は Azure Blob storage • それっぽい機能が実装されている • CDNっぽく配信するとか • GETしたら Lifecycle 伸ばすとか 20

Slide 21

Slide 21 text

actions/cache internal 21 runner Azure blob storage

Slide 22

Slide 22 text

🙅 22

Slide 23

Slide 23 text

actions/cache internal 23 runner Azure blob storage

Slide 24

Slide 24 text

actions/cache internal 24 runner Azure blob storage GitHub Cache API

Slide 25

Slide 25 text

actions/cache internal • GitHub Cache API (仮称) • 各種情報を確認しているのでは?と推測 • リポジトリ毎の保存ファイル容量 • アクセス状態 • etc etc... 25

Slide 26

Slide 26 text

- name: Cache Primes id: cache-primes uses: actions/cache@v3 with: path: prime-numbers key: ${{ runner.os }}-primes 26

Slide 27

Slide 27 text

Con fi g less 27

Slide 28

Slide 28 text

28 Meets self-hosted runner

Slide 29

Slide 29 text

actions/cache internal 29 runner Azure blob storage GitHub Cache API

Slide 30

Slide 30 text

actions/cache internal 30 GitHub-hosted Azure blob storage GitHub Cache API

Slide 31

Slide 31 text

actions/cache internal 31 self-hosted Azure blob storage GitHub Cache API

Slide 32

Slide 32 text

- name: Cache Primes id: cache-primes uses: actions/cache@v3 with: path: prime-numbers key: ${{ runner.os }}-primes 32 同じcon fi gが利⽤可能

Slide 33

Slide 33 text

actions/cache internal 33 🏠 self-hosted Azure blob storage GitHub Cache API GitHub-hosted Azure blob storage GitHub Cache API

Slide 34

Slide 34 text

actions/cache internal 34 GitHub-hosted Azure blob storage GitHub Cache API self-hosted Azure blob storage GitHub Cache API 同じ or 近い

Slide 35

Slide 35 text

actions/cache internal 35 GitHub-hosted Azure blob storage GitHub Cache API self-hosted Azure blob storage GitHub Cache API 遠い

Slide 36

Slide 36 text

Benchmark 36 https://github.com/google/wireit/issues/ 239

Slide 37

Slide 37 text

遠すぎ🥺 37

Slide 38

Slide 38 text

@actions/cache (= library) • ライブラリとして内部的に組み込み可能 • actions/setup-go@v 4 • Dependency cache is default enable • ruby/setup-ruby • rubyのキャッシュが難しく当初より実装 38

Slide 39

Slide 39 text

避けようがない🥺 39

Slide 40

Slide 40 text

世間の対応

Slide 41

Slide 41 text

Backend as a Amazon S 3 • S 3 などオブジェクトストレージをバックエンドに 
 利⽤したCustom Actionを作る案 • actions/cache に求める物がシンプルならこれでOK • 設定が煩雑になりがち • 各リポジトリごとに AWS_ACCESS_ID 書いたり 41

Slide 42

Slide 42 text

Backend as a Amazon S 3 • https://github.com/whywaita/actions-cache-s 3 
 作ってます (ました) • 社内オブジェクトストレージをバックエンドに採⽤ • 課題もいくつかあり • 設定の煩雑性 • GET時にLifecycleを伸ばす機能がS 3 にない 42

Slide 43

Slide 43 text

BuildJet cache • BuildJet: self-hosted runner 会社 • buildjet/cache@v 3 • バックエンドはCloud fl are R 2 • buildjet/setup-go などを完備 43

Slide 44

Slide 44 text

BuildJet cache 44

Slide 45

Slide 45 text

45 https://buildjet.com/for-github-actions/blog/launch-buildjet-cache

Slide 46

Slide 46 text

46 https://buildjet.com/for-github-actions/blog/launch-buildjet-cache

Slide 47

Slide 47 text

47 https://buildjet.com/for-github-actions/blog/launch-buildjet-cache

Slide 48

Slide 48 text

🥰🥰🥰 48

Slide 49

Slide 49 text

まとめ • self-hosted runnerをactions/cacheで使うと遅い • 海を越えてアクセスを⾏う必要があるため • 各位良い感じのソリューションで 
 最⾼体験をしてください!!!!! • We Are hiring! 49