diff --git a/.github/actions/install-node-dependencies/action.yml b/.github/actions/install-node-dependencies/action.yml index 3ae48e01da6..de1a0c44933 100644 --- a/.github/actions/install-node-dependencies/action.yml +++ b/.github/actions/install-node-dependencies/action.yml @@ -185,9 +185,10 @@ runs: key: node-cache-${{ runner.os }}-${{ steps.pnpm-store.outputs.arch }}-pnpm-${{ hashFiles(inputs.cache-dependency-path) }} # Producers can refresh access and publish misses without downloading existing archives. + # Not on GitHub-hosted runners: nothing restores that store, and direct installs beat restoring it. - name: Keep pnpm download store without restoring id: pnpm-store-lookup - if: steps.pnpm-store-mode.outputs.lookup-only == 'true' + if: steps.pnpm-store-mode.outputs.lookup-only == 'true' && runner.environment != 'github-hosted' uses: actions/cache@v5 with: # Twice-nested composite cleanup loses internal step outputs. diff --git a/config/scripts/ci-dependency-download-cache.test.mjs b/config/scripts/ci-dependency-download-cache.test.mjs index fe7edadf006..f6e9e2f74d0 100644 --- a/config/scripts/ci-dependency-download-cache.test.mjs +++ b/config/scripts/ci-dependency-download-cache.test.mjs @@ -81,7 +81,9 @@ describe('CI dependency download caches', () => { const restore = action.runs.steps.find((step) => step.id === 'pnpm-store-restore') expect(action.inputs['cache-pnpm-store-lookup-only'].default).toBe('auto') expect(lookup.uses).toBe('actions/cache@v5') - expect(lookup.if).toBe("steps.pnpm-store-mode.outputs.lookup-only == 'true'") + expect(lookup.if).toBe( + "steps.pnpm-store-mode.outputs.lookup-only == 'true' && runner.environment != 'github-hosted'" + ) expect(lookup.with).toEqual({ path: '${{ env.ORCA_PNPM_STORE_CACHE_PATH }}', key: restore.with.key, diff --git a/config/scripts/ci-pnpm-store-mode.test.mjs b/config/scripts/ci-pnpm-store-mode.test.mjs index 7cebed7b989..87cc4a8d1cc 100644 --- a/config/scripts/ci-pnpm-store-mode.test.mjs +++ b/config/scripts/ci-pnpm-store-mode.test.mjs @@ -76,9 +76,10 @@ describe('automatic pnpm store mode', () => { ) const nodeSetup = action.runs.steps.find((step) => step.id === 'default-node') expect(evaluate(nodeSetup.with.cache.slice(3, -2))).toBe(cache) - expect(evaluate(action.runs.steps.find((step) => step.id === 'pnpm-store-lookup').if)).toBe( - lookup - ) + const publish = action.runs.steps.find((step) => step.id === 'pnpm-store-lookup').if + expect(evaluate(publish)).toBe(false) + context.runner.environment = 'self-hosted' + expect(evaluate(publish)).toBe(lookup) } )