From 48130679d23eef67943c514ea9114f89d422e9b6 Mon Sep 17 00:00:00 2001 From: sgash708 Date: Sun, 9 Aug 2026 11:28:29 +0900 Subject: [PATCH] =?UTF-8?q?perf:=20Noto=20CJK=E3=83=95=E3=82=A9=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92actions/cache=E3=81=A7=E3=82=AD=E3=83=A3?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5(=E6=A4=9C=E8=A8=BC=E4=B8=AD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fonts-noto-cjkは約61MBあり apt install の大半を占める。/usr/share/fonts, /var/cache/fontconfig はroot所有なのでactions/cacheが復元できるよう 事前に所有権をrunnerユーザーへ渡す方式で実装。まずchromagic-demoで ブランチ直接参照して権限エラーが出ないか検証してからマージする。 --- action.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a4789be..9eaac07 100644 --- a/action.yml +++ b/action.yml @@ -62,12 +62,44 @@ outputs: runs: using: "composite" steps: - - name: Install Japanese fonts (Noto CJK) + # fonts-noto-cjk は約61MBあり apt install の大半の時間を占める。 + # /usr/share/fonts, /var/cache/fontconfig は root 所有なので、actions/cache が + # restore 時に書き込めるよう事前に所有権を runner ユーザーへ渡しておく。 + - name: Prepare fonts cache dir + if: ${{ inputs.install-fonts == 'true' && runner.os == 'Linux' }} + shell: bash + run: | + sudo mkdir -p /usr/share/fonts/opentype/noto /var/cache/fontconfig + sudo chown -R "$(id -u):$(id -g)" /usr/share/fonts/opentype/noto /var/cache/fontconfig + + - name: Restore Noto CJK fonts cache if: ${{ inputs.install-fonts == 'true' && runner.os == 'Linux' }} + id: fonts-cache + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: | + /usr/share/fonts/opentype/noto + /var/cache/fontconfig + key: chromagic-noto-cjk-${{ runner.os }} + + - name: Install Japanese fonts (Noto CJK) + if: ${{ inputs.install-fonts == 'true' && runner.os == 'Linux' && steps.fonts-cache.outputs.cache-hit != 'true' }} shell: bash run: | sudo apt-get update sudo apt-get install -y --no-install-recommends fonts-noto-cjk + # apt が root 所有に戻すので、save 前に再度 runner ユーザーへ渡す + sudo chown -R "$(id -u):$(id -g)" /usr/share/fonts/opentype/noto /var/cache/fontconfig + fc-cache -f + + - name: Save Noto CJK fonts cache + if: ${{ inputs.install-fonts == 'true' && runner.os == 'Linux' && steps.fonts-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: | + /usr/share/fonts/opentype/noto + /var/cache/fontconfig + key: ${{ steps.fonts-cache.outputs.cache-primary-key }} # browser-actions/setup-chrome は RUNNER_TOOL_CACHE 配下にキャッシュする作りだが、 # GitHub-hosted runner は毎回使い捨て VM なのでジョブをまたいでは残らない。