From 9d5de75930d781583824b783d8689f825657fa9f Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Tue, 20 Dec 2022 21:18:53 +0100 Subject: [PATCH] Engineering - Create Windows job to maintain cache (#169675) Create Windows job to maintain cache --- .../product-build-pr-cache-win32.yml | 87 +++++++++++++++++++ build/azure-pipelines/product-build-pr.yml | 2 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 build/azure-pipelines/product-build-pr-cache-win32.yml diff --git a/build/azure-pipelines/product-build-pr-cache-win32.yml b/build/azure-pipelines/product-build-pr-cache-win32.yml new file mode 100644 index 00000000000..98e999813f0 --- /dev/null +++ b/build/azure-pipelines/product-build-pr-cache-win32.yml @@ -0,0 +1,87 @@ +steps: + - checkout: self + fetchDepth: 1 + retryCountOnTaskFailure: 3 + + - task: NodeTool@0 + inputs: + versionSpec: "16.x" + + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { node build/setup-npm-registry.js $env:NPM_REGISTRY } + condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none')) + displayName: Setup NPM Registry + + - powershell: | + if (!(Test-Path ".build")) { New-Item -Path ".build" -ItemType Directory } + node build/azure-pipelines/common/computeNodeModulesCacheKey.js $(VSCODE_ARCH) > .build/yarnlockhash + node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash + displayName: Prepare yarn cache flags + + - task: Cache@2 + inputs: + key: "genericNodeModules | $(Agent.OS) | .build/yarnlockhash" + path: .build/node_modules_cache + cacheHitVar: NODE_MODULES_RESTORED + displayName: Restore node_modules cache + + - task: Cache@2 + inputs: + key: '"builtInDeps" | .build/builtindepshash' + path: .build/builtInExtensions + displayName: Restore built-in extensions + + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { 7z.exe x .build/node_modules_cache/cache.7z -aos } + condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true')) + displayName: Extract node_modules cache + + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { npm config set registry "$env:NPM_REGISTRY" --location=project } + exec { npm config set always-auth=true --location=project } + exec { yarn config set registry "$env:NPM_REGISTRY" } + condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none')) + displayName: Setup NPM & Yarn + + - task: npmAuthenticate@0 + inputs: + workingFile: .npmrc + condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none')) + displayName: Setup NPM Authentication + + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + . build/azure-pipelines/win32/retry.ps1 + $ErrorActionPreference = "Stop" + $env:npm_config_arch="$(VSCODE_ARCH)" + $env:CHILD_CONCURRENCY="1" + retry { exec { yarn --frozen-lockfile --check-files } } + env: + ELECTRON_SKIP_BINARY_DOWNLOAD: 1 + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 + GITHUB_TOKEN: "$(github-distro-mixin-password)" + displayName: Install dependencies + condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true')) + + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { node build/lib/builtInExtensions.js } + env: + GITHUB_TOKEN: "$(github-distro-mixin-password)" + displayName: Download missing built-in extensions + + - powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt } + exec { mkdir -Force .build/node_modules_cache } + exec { 7z.exe a .build/node_modules_cache/cache.7z -mx3 `@.build/node_modules_list.txt } + condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true')) + displayName: Create node_modules archive diff --git a/build/azure-pipelines/product-build-pr.yml b/build/azure-pipelines/product-build-pr.yml index bd168396b37..94daf187e9c 100644 --- a/build/azure-pipelines/product-build-pr.yml +++ b/build/azure-pipelines/product-build-pr.yml @@ -164,7 +164,7 @@ jobs: variables: VSCODE_ARCH: x64 steps: - - template: product-build-pr-cache.yml + - template: product-build-pr-cache-win32.yml # - job: macOSUnitTest # displayName: macOS (Unit Tests)