ci: add .nvmrc to cache key and cache node_modules in build pipelines

Include .nvmrc hash in the test pipeline cache key so a Node.js
version bump invalidates the cache. Add node_modules caching to
studio-publish and studio-build-non-production pipelines so
subsequent builds with the same deps skip yarn install. These
use runner.arch in the key since they build across x64 and arm64.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthew Rathbone
2026-03-11 13:09:10 -05:00
parent 763588a9b1
commit 3a794fbccd
3 changed files with 30 additions and 6 deletions

View File

@@ -87,12 +87,24 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: yarn
- name: Cache node_modules
id: cache-nm
uses: actions/cache@v4
with:
path: |
node_modules
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
- name: Clean cache
if: steps.cache-nm.outputs.cache-hit != 'true'
run: yarn cache clean
- name: Check dependencies
if: steps.cache-nm.outputs.cache-hit != 'true'
run: "yarn install --frozen-lockfile --network-timeout 100000"
env:
npm_config_node_gyp: ${{ github.workspace }}${{ runner.os == 'Windows' && '\node_modules\node-gyp\bin\node-gyp.js' || '/node_modules/node-gyp/bin/node-gyp.js' }}

View File

@@ -225,13 +225,24 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: yarn
- name: Cache node_modules
id: cache-nm
uses: actions/cache@v4
with:
path: |
node_modules
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v3
if: matrix.os.type == 'linux' && matrix.os.arch != 'arm64'
- name: Clean cache
if: steps.cache-nm.outputs.cache-hit != 'true'
run: yarn cache clean --all
# FIXME (matthew) Windows needs retries. It sometimes fails to build
@@ -239,6 +250,7 @@ jobs:
# But only sometimes. I cannot figure out why.
# Someone should at some point.
- name: yarn install (with retry)
if: steps.cache-nm.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
timeout_minutes: 20

View File

@@ -49,7 +49,7 @@ jobs:
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
key: node-modules-${{ runner.os }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
if: steps.cache-nm.outputs.cache-hit != 'true'
@@ -83,7 +83,7 @@ jobs:
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
key: node-modules-${{ runner.os }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- name: Lint
@@ -137,7 +137,7 @@ jobs:
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
key: node-modules-${{ runner.os }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- name: Install libaio (for oracle)
@@ -202,7 +202,7 @@ jobs:
apps/studio/node_modules
apps/ui-kit/node_modules
apps/sqltools/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
key: node-modules-${{ runner.os }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- name: Start postgres container