From 7a77881728dce98ea8cbd78f25b6e28e10dfc1ea Mon Sep 17 00:00:00 2001 From: Cayman Date: Fri, 23 May 2025 08:05:49 -0400 Subject: [PATCH] chore: remove node_modules from actions cache (#7820) **Motivation** - looking at our actions cache usage, trying to improve usage of the 10GB total capacity **Description** - It looks like we were caching both: - yarn global cache - node_modules - Remove node_modules from the cache since the yarn global cache should suffice --------- Co-authored-by: Nazar Hussain Co-authored-by: Nico Flaig --- .github/actions/setup-and-build/action.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/actions/setup-and-build/action.yml b/.github/actions/setup-and-build/action.yml index 8912e75d8e..cd6fd32e4b 100644 --- a/.github/actions/setup-and-build/action.yml +++ b/.github/actions/setup-and-build/action.yml @@ -13,6 +13,8 @@ runs: with: node-version: ${{inputs.node}} check-latest: true + # The hash of yarn.lock file will be used as cache key + # So unless our dependencies change, we can reuse the cache cache: yarn - name: Node.js version @@ -20,28 +22,26 @@ runs: shell: bash run: echo "v8CppApiVersion=$(node --print "process.versions.modules")" >> $GITHUB_OUTPUT + - name: Create cache key + id: build-cache + shell: bash + # This build cache will be reused among different jobs for the same commit + run: echo "key=build-cache-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node }}-${{ github.sha }}" >> $GITHUB_OUTPUT + - name: Restore build uses: actions/cache/restore@v4 id: cache-build-restore with: path: | - node_modules - packages/*/node_modules lib/ packages/*/lib packages/*/.git-data.json - key: ${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node }}-${{ github.sha }} + key: ${{ steps.build-cache.outputs.key }} - name: Install & build - if: steps.cache-build-restore.outputs.cache-hit != 'true' shell: bash run: yarn install --frozen-lockfile && yarn build - - name: Build - if: steps.cache-build-restore.outputs.cache-hit == 'true' - shell: bash - run: yarn build - - name: Check Build shell: bash run: yarn check-build @@ -58,9 +58,7 @@ runs: uses: actions/cache@v4 with: path: | - node_modules - packages/*/node_modules lib/ packages/*/lib packages/*/.git-data.json - key: ${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node }}-${{ github.sha }} + key: ${{ steps.build-cache.outputs.key }}