From af5651565274497e448c3ac9c2239874da01bc09 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 23 Apr 2026 12:55:07 +0800 Subject: [PATCH] ci: cache yarn build-state and install-state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Setup Node.JS action currently caches only .yarn/unplugged. Two other yarn-berry state files meaningfully reduce install time and install-flakiness surface area, but aren't cached today: - .yarn/build-state.yml tracks which unplugged packages have had their postinstall scripts run successfully. Without it, even on a cache hit, yarn re-runs every native build — which is exactly when transient failures like EBADF races can bite. - .yarn/install-state.gz is yarn's compressed resolution/link state; including it lets yarn skip cold-start hydration work. Both are derived from yarn.lock, so the existing cache key is fine. actions/cache tolerates missing paths at save time, so first-run behavior is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/actions/nodejs/action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/nodejs/action.yaml b/.github/actions/nodejs/action.yaml index 537c402977a..17649e1950e 100644 --- a/.github/actions/nodejs/action.yaml +++ b/.github/actions/nodejs/action.yaml @@ -26,8 +26,14 @@ runs: - name: Cache NPM build artifacts uses: actions/cache@v4 with: + # Cache the unplugged packages (unpacked native builds), yarn's + # build-state (so postinstalls don't re-run) and install-state + # (cold-start avoidance). Missing paths are tolerated by the + # action, so first-run behavior is unaffected. path: | .yarn/unplugged + .yarn/build-state.yml + .yarn/install-state.gz key: ${{ runner.os }}/yarn/unplugged/${{ runner.arch }}/${{ hashFiles('yarn.lock') }} restore-keys: | ${{ runner.os }}/yarn/unplugged/${{ runner.arch }}/