Skip to content

Commit

Permalink
Always patch the npm registry in yarn.lock files and compute the no…
Browse files Browse the repository at this point in the history
…de modules cache key after having patched them (microsoft#164795)
  • Loading branch information
alexdima authored and formigoni committed Oct 27, 2022
1 parent dd87627 commit 5877523
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 49 deletions.
10 changes: 5 additions & 5 deletions build/azure-pipelines/darwin/product-build-darwin-sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ steps:
git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
displayName: Merge distro
- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 $NPM_REGISTRY > .build/yarnlockhash
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 > .build/yarnlockhash
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
displayName: Prepare yarn cache flags
Expand Down Expand Up @@ -81,10 +85,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
export npm_config_arch=$(VSCODE_ARCH)
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/darwin/product-build-darwin-universal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ steps:
git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
displayName: Merge distro
- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 $NPM_REGISTRY > .build/yarnlockhash
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 > .build/yarnlockhash
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
displayName: Prepare yarn cache flags
Expand Down Expand Up @@ -81,10 +85,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
export npm_config_arch=$(VSCODE_ARCH)
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/darwin/product-build-darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ steps:
git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
displayName: Merge distro
- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
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
Expand Down Expand Up @@ -110,10 +114,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
export npm_config_arch=$(VSCODE_ARCH)
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/linux/product-build-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ steps:
git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
displayName: Merge distro
- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js "alpine" $NPM_REGISTRY > .build/yarnlockhash
node build/azure-pipelines/common/computeNodeModulesCacheKey.js "alpine" > .build/yarnlockhash
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
displayName: Prepare yarn cache flags
Expand Down Expand Up @@ -94,10 +98,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
for i in {1..3}; do # try 3 times
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/linux/product-build-linux-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ steps:
git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
displayName: Merge distro
- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
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
Expand Down Expand Up @@ -138,10 +142,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
node build/npm/setupBuildYarnrc
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/product-build-pr-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ steps:
inputs:
versionSpec: "16.x"

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
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
Expand Down Expand Up @@ -46,10 +50,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
for i in {1..3}; do # try 3 times
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/product-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ steps:
parameters:
VSCODE_QUALITY: ${{ parameters.VSCODE_QUALITY }}

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
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
Expand Down Expand Up @@ -52,10 +56,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
sudo apt update -y
Expand Down
10 changes: 5 additions & 5 deletions build/azure-pipelines/web/product-build-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ steps:
git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro")
displayName: Merge distro
- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
mkdir -p .build
node build/azure-pipelines/common/computeNodeModulesCacheKey.js "web" $NPM_REGISTRY > .build/yarnlockhash
node build/azure-pipelines/common/computeNodeModulesCacheKey.js "web" > .build/yarnlockhash
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
displayName: Prepare yarn cache flags
Expand Down Expand Up @@ -85,10 +89,6 @@ steps:
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Authentication

- script: node build/setup-npm-registry.js $NPM_REGISTRY
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry

- script: |
set -e
for i in {1..3}; do # try 3 times
Expand Down
17 changes: 8 additions & 9 deletions build/azure-pipelines/win32/product-build-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,23 @@ steps:
exec { git pull --no-rebase https://github.com/$(VSCODE_MIXIN_REPO).git $(node -p "require('./package.json').distro") }
displayName: Merge distro
- 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 }
"$(VSCODE_ARCH)" | Out-File -Encoding ascii -NoNewLine .build\arch
"$env:NPM_REGISTRY" | Out-File -Encoding ascii -NoNewLine .build\npm_registry
node build/azure-pipelines/common/computeNodeModulesCacheKey.js > .build/yarnlockhash
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
displayName: Prepare yarn cache flags
- task: Cache@2
inputs:
key: "nodeModules | $(Agent.OS) | .build/arch, .build/npm_registry, .build/yarnlockhash"
key: "nodeModules | $(Agent.OS) | .build/arch, .build/yarnlockhash"
path: .build/node_modules_cache
cacheHitVar: NODE_MODULES_RESTORED
displayName: Restore node_modules cache
Expand Down Expand Up @@ -120,13 +126,6 @@ steps:
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
$ErrorActionPreference = "Stop"
exec { node build/setup-npm-registry.js $env:NPM_REGISTRY }
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Setup NPM Registry
- powershell: |
. build/azure-pipelines/win32/exec.ps1
. build/azure-pipelines/win32/retry.ps1
Expand Down

0 comments on commit 5877523

Please sign in to comment.