ci: PRごとのキャッシュ書き込みをやめてビルドキャッシュの追い出しを防ぐ - #350
Closed
tknkaa wants to merge 1 commit into
Closed
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deploying utcode-website with
|
| Latest commit: |
3f8d0c8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a37d0424.utcode-website.pages.dev |
| Branch Preview URL: | https://ci-fix-astro-build-cache.utcode-website.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
どれくらい遅かったか
直近の main push (fd95500) の CI ログを見ると、
Checkワークフロー全体 (~6分10秒) のうちBuildジョブのbun run buildステップだけで 297秒 (約5分) かかっていた。他のジョブ (Check,dirs-small) は30秒前後で終わっているので、ここがボトルネック。なぜ遅かったか
bun run buildの中身はほぼ全部が Astro のアセット最適化フェーズで、記事・プロジェクト・メンバーのサムネイルを avif / webp / png(jpg) の各フォーマット×複数サイズに変換する処理 (合計1,697枚) を sharp で行っていた。これを避けるために
.astro,dist,node_modules/.astro/assetsをactions/cache@v4でキャッシュしていたが、実際には毎回Cache not found for input keys: Linux-astro-build, Linux-astro-buildとなっていて機能していなかった。原因は cache のスコープ。
actions/cache@v4は save も restore も同じキー${{ runner.os }}-astro-buildを使うが、PR ブランチ (refs/pull/N/merge) で保存されたキャッシュは main では読めない。にもかかわらず PR を作るたびに ~420MB のキャッシュが同じキー名で新規保存され続け、リポジトリ全体の cache 容量上限 (10GB) をこれらの使い捨てキャッシュが埋めてしまい、main 用に唯一有効なキャッシュが LRU で追い出されていた。結果、main への連続 push でもほぼ毎回コールドスタートで 1,697 枚を作り直していた。どう直したか
actions/cache@v4(restore + save が一体) をactions/cache/restore@v4+actions/cache/save@v4に分割し、Test plan
Buildジョブが遅いままでないか (キャッシュが保存されるはず)bun run buildが大幅に短縮されているか確認🤖 Generated with Claude Code