Path: blob/main/build/azure-pipelines/alpine/product-build-alpine-node-modules.yml
4772 views
parameters:1- name: VSCODE_ARCH2type: string34jobs:5- job: LinuxAlpine_${{ parameters.VSCODE_ARCH }}6displayName: Linux Alpine (${{ upper(parameters.VSCODE_ARCH) }})7pool:8name: 1es-ubuntu-22.04-x649os: linux10timeoutInMinutes: 6011variables:12NPM_ARCH: ${{ parameters.VSCODE_ARCH }}13VSCODE_ARCH: ${{ parameters.VSCODE_ARCH }}14steps:15- template: ../common/checkout.yml@self1617- task: NodeTool@018inputs:19versionSource: fromFile20versionFilePath: .nvmrc2122- template: ../distro/download-distro.yml@self2324- task: AzureKeyVault@225displayName: "Azure Key Vault: Get Secrets"26inputs:27azureSubscription: vscode28KeyVaultName: vscode-build-secrets29SecretsFilter: "github-distro-mixin-password"3031- script: node build/setup-npm-registry.ts $NPM_REGISTRY32condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))33displayName: Setup NPM Registry3435- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash36displayName: Prepare node_modules cache key3738- task: Cache@239inputs:40key: '"node_modules" | .build/packagelockhash'41path: .build/node_modules_cache42cacheHitVar: NODE_MODULES_RESTORED43displayName: Restore node_modules cache4445- script: |46set -e47# Set the private NPM registry to the global npmrc file48# so that authentication works for subfolders like build/, remote/, extensions/ etc49# which does not have their own .npmrc file50npm config set registry "$NPM_REGISTRY"51echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"52condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))53displayName: Setup NPM5455- task: npmAuthenticate@056inputs:57workingFile: $(NPMRC_PATH)58condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))59displayName: Setup NPM Authentication6061- task: Docker@162inputs:63azureSubscriptionEndpoint: vscode64azureContainerRegistry: vscodehub.azurecr.io65command: "Run an image"66imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"67containerCommand: uname68displayName: "Pull image"69condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))7071- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev72displayName: Install build dependencies73condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))7475- script: |76set -e77mkdir -p .build/nodejs-musl78NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)79BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)80gh release download "v${NODE_VERSION}-${BUILD_ID}" -R microsoft/vscode-node -p "node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" --dir .build/nodejs-musl --clobber81tar -xzf ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" -C ".build/nodejs-musl" --strip-components=182rm ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz"83env:84GITHUB_TOKEN: "$(github-distro-mixin-password)"85displayName: Download NodeJS MUSL86condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))8788- script: |89set -e9091for i in {1..5}; do # try 5 times92npm ci && break93if [ $i -eq 5 ]; then94echo "Npm install failed too many times" >&295exit 196fi97echo "Npm install failed $i, trying again..."98done99env:100npm_config_arch: $(NPM_ARCH)101ELECTRON_SKIP_BINARY_DOWNLOAD: 1102PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1103GITHUB_TOKEN: "$(github-distro-mixin-password)"104VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME: vscodehub.azurecr.io/vscode-linux-build-agent:alpine-$(VSCODE_ARCH)105VSCODE_HOST_MOUNT: "/mnt/vss/_work/1/s"106VSCODE_NPMRC_PATH: $(NPMRC_PATH)107displayName: Install dependencies108condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))109110- script: node build/azure-pipelines/distro/mixin-npm.ts111displayName: Mixin distro node modules112condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))113114- script: |115set -e116node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt117mkdir -p .build/node_modules_cache118tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt119condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))120displayName: Create node_modules archive121122123