Skip to content
TypeScript

ci: cache pnpm packages on Blacksmith sticky disks (#19634)

mariaf6ad94d05c9c
diff --git a/.github/actions/setup-ci-deps/action.yml b/.github/actions/setup-ci-deps/action.yml
new file mode 100644
index 00000000000..b3cfce2ae89
--- /dev/null
+++ b/.github/actions/setup-ci-deps/action.yml
@@ -0,0 +1,57 @@
+name: Setup CI dependencies
+description: Install Vite+ dependencies using a Blacksmith sticky pnpm store on Linux.
+inputs:
+ run-install:
+ description: Install arguments forwarded to setup-vp.
+ required: false
+ default: "true"
+runs:
+ using: composite
+ steps:
+ # Cache packages only; node_modules and prepare scripts stay fresh each job.
+ - name: Mount pnpm store
+ id: sticky
+ continue-on-error: true
+ uses: useblacksmith/stickydisk@v1
+ with:
+ key: ${{ github.repository }}-ci-pnpm-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml', 'patches/**') }}
+ path: ${{ runner.temp }}/t3-ci-pnpm-store
+ # Each job gets a private clone. PRs must not publish into main's snapshot.
+ commit: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
+
+ - name: Check pnpm store mount
+ id: store
+ shell: bash
+ env:
+ STICKY_OUTCOME: ${{ steps.sticky.outcome }}
+ STICKY_STORE_PATH: ${{ runner.temp }}/t3-ci-pnpm-store
+ PUBLISHES: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
+ run: |
+ # stickydisk can return success after falling back to an ordinary directory.
+ # An empty disk (no pnpm `v*` store from a main snapshot yet) only helps the
+ # main push that fills it; everyone else keeps the setup-vp cache.
+ if [[ "$STICKY_OUTCOME" == success ]] && mountpoint -q "$STICKY_STORE_PATH" && test -w "$STICKY_STORE_PATH" \
+ && { [[ "$PUBLISHES" == true ]] || compgen -G "$STICKY_STORE_PATH/v*" > /dev/null; }; then
+ echo 'mounted=true' >> "$GITHUB_OUTPUT"
+ else
+ echo 'mounted=false' >> "$GITHUB_OUTPUT"
+ echo '::warning::Sticky pnpm store unavailable or empty; using setup-vp dependency cache.'
+ fi
+
+ - name: Setup Vite+ with sticky store
+ if: steps.store.outputs.mounted == 'true'
+ uses: voidzero-dev/setup-vp@v1
+ env:
+ pnpm_config_store_dir: ${{ runner.temp }}/t3-ci-pnpm-store
+ with:
+ node-version-file: package.json
+ cache: false
+ run-install: ${{ inputs.run-install }}
+
+ - name: Setup Vite+ with cache fallback
+ if: steps.store.outputs.mounted != 'true'
+ uses: voidzero-dev/setup-vp@v1
+ with:
+ node-version-file: package.json
+ cache: true
+ run-install: ${{ inputs.run-install }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 56aefe60244..8e01c17141e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -80,11 +80,7 @@ jobs:
fi
- name: Setup Vite+
- uses: voidzero-dev/setup-vp@v1
- with:
- node-version-file: package.json
- cache: true
- run-install: true
+ uses: ./.github/actions/setup-ci-deps
- name: Ensure Electron runtime is installed
run: vp run --filter @t3tools/desktop ensure:electron
@@ -129,11 +125,7 @@ jobs:
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
- name: Setup Vite+
- uses: voidzero-dev/setup-vp@v1
- with:
- node-version-file: package.json
- cache: true
- run-install: true
+ uses: ./.github/actions/setup-ci-deps
- name: Ensure Electron runtime is installed
id: electron
@@ -222,11 +214,7 @@ jobs:
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
- name: Setup Vite+
- uses: voidzero-dev/setup-vp@v1
- with:
- node-version-file: package.json
- cache: true
- run-install: true
+ uses: ./.github/actions/setup-ci-deps
- name: Ensure Electron runtime is installed
run: vp run --filter @t3tools/desktop ensure:electron
@@ -274,11 +262,7 @@ jobs:
sparse-checkout-cone-mode: false
- name: Setup Vite+
- uses: voidzero-dev/setup-vp@v1
- with:
- node-version-file: package.json
- cache: true
- run-install: true
+ uses: ./.github/actions/setup-ci-deps
- name: Test
run: vp run --filter @t3tools/web test
@@ -316,11 +300,7 @@ jobs:
- name: Setup Vite+
if: steps.changes.outputs.test_server != 'false'
- uses: voidzero-dev/setup-vp@v1
- with:
- node-version-file: package.json
- cache: true
- run-install: true
+ uses: ./.github/actions/setup-ci-deps
# No Electron setup here: `t3` (apps/server) has no Electron dependency
# and none of its tests touch the runtime. Only the non-server `test`