From 3980424ce81c8e54f2122e9b409e4cf74e45cfdf Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Fri, 19 Jun 2026 21:38:47 +0200 Subject: [PATCH] Refactor restore-node-modules action for lookup-only functionality (#322140) refactor: update restore-node-modules action to support lookup-only functionality - Replaced 'extract' input with 'lookup-only' to allow cache entry checks without downloading or extracting. - Updated action logic to conditionally extract node_modules based on the new 'lookup-only' input. - Adjusted workflow files to utilize 'lookup-only' for cache-warming jobs on Linux, macOS, and Windows. --- .github/actions/restore-node-modules/action.yml | 11 ++++++----- .github/workflows/pr-node-modules.yml | 8 +++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/actions/restore-node-modules/action.yml b/.github/actions/restore-node-modules/action.yml index 1e4e483f6e9..4d2fefdd01a 100644 --- a/.github/actions/restore-node-modules/action.yml +++ b/.github/actions/restore-node-modules/action.yml @@ -8,9 +8,9 @@ inputs: key-args: description: Arguments passed to build/azure-pipelines/common/computeNodeModulesCacheKey.ts. required: true - extract: - description: When 'true', the restored archive is extracted into node_modules on a cache hit. - default: 'true' + lookup-only: + description: When 'true', only checks whether the cache entry exists (sets cache-hit) without downloading or extracting the archive. Use for cache-warming jobs that only need the cache-hit result. + default: 'false' outputs: cache-hit: @@ -38,6 +38,7 @@ runs: with: path: .build/node_modules_cache key: "${{ inputs.key-prefix }}-${{ hashFiles('.build/packagelockhash') }}" + lookup-only: ${{ inputs.lookup-only }} - name: Export node_modules cache key if: runner.os != 'Windows' @@ -50,11 +51,11 @@ runs: run: Add-Content -Path $env:GITHUB_ENV -Value "NODE_MODULES_CACHE_KEY=${{ steps.restore.outputs.cache-primary-key }}" - name: Extract node_modules cache - if: runner.os != 'Windows' && inputs.extract == 'true' && steps.restore.outputs.cache-hit == 'true' + if: runner.os != 'Windows' && inputs.lookup-only != 'true' && steps.restore.outputs.cache-hit == 'true' shell: bash run: ./.github/workflows/node_modules_cache/cache.sh extract - name: Extract node_modules cache - if: runner.os == 'Windows' && inputs.extract == 'true' && steps.restore.outputs.cache-hit == 'true' + if: runner.os == 'Windows' && inputs.lookup-only != 'true' && steps.restore.outputs.cache-hit == 'true' shell: pwsh run: ./.github/workflows/node_modules_cache/cache.ps1 extract diff --git a/.github/workflows/pr-node-modules.yml b/.github/workflows/pr-node-modules.yml index 000c17b3782..bce8dcacaee 100644 --- a/.github/workflows/pr-node-modules.yml +++ b/.github/workflows/pr-node-modules.yml @@ -94,7 +94,7 @@ jobs: with: key-prefix: node_modules-linux key-args: "linux ${{ env.VSCODE_ARCH }} $(node -p process.arch)" - extract: 'false' + lookup-only: 'true' - name: Install build dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' @@ -160,7 +160,7 @@ jobs: with: key-prefix: node_modules-macos key-args: "darwin ${{ env.VSCODE_ARCH }} $(node -p process.arch)" - extract: 'false' + lookup-only: 'true' - name: Install dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' @@ -215,7 +215,7 @@ jobs: with: key-prefix: node_modules-windows key-args: "win32 ${{ env.VSCODE_ARCH }} $(node -p process.arch)" - extract: 'false' + lookup-only: 'true' - name: Install dependencies if: steps.node-modules-cache.outputs.cache-hit != 'true' @@ -267,6 +267,7 @@ jobs: with: key-prefix: copilot-node_modules-linux key-args: "$(node -p process.platform) $(node -p process.arch)" + lookup-only: 'true' - name: Install root dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' @@ -299,6 +300,7 @@ jobs: with: key-prefix: copilot-node_modules-windows key-args: "$(node -p process.platform) $(node -p process.arch)" + lookup-only: 'true' - name: Install root dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true'