Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/alpine/product-build-alpine-node-modules.yml
4772 views
1
parameters:
2
- name: VSCODE_ARCH
3
type: string
4
5
jobs:
6
- job: LinuxAlpine_${{ parameters.VSCODE_ARCH }}
7
displayName: Linux Alpine (${{ upper(parameters.VSCODE_ARCH) }})
8
pool:
9
name: 1es-ubuntu-22.04-x64
10
os: linux
11
timeoutInMinutes: 60
12
variables:
13
NPM_ARCH: ${{ parameters.VSCODE_ARCH }}
14
VSCODE_ARCH: ${{ parameters.VSCODE_ARCH }}
15
steps:
16
- template: ../common/checkout.yml@self
17
18
- task: NodeTool@0
19
inputs:
20
versionSource: fromFile
21
versionFilePath: .nvmrc
22
23
- template: ../distro/download-distro.yml@self
24
25
- task: AzureKeyVault@2
26
displayName: "Azure Key Vault: Get Secrets"
27
inputs:
28
azureSubscription: vscode
29
KeyVaultName: vscode-build-secrets
30
SecretsFilter: "github-distro-mixin-password"
31
32
- script: node build/setup-npm-registry.ts $NPM_REGISTRY
33
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
34
displayName: Setup NPM Registry
35
36
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash
37
displayName: Prepare node_modules cache key
38
39
- task: Cache@2
40
inputs:
41
key: '"node_modules" | .build/packagelockhash'
42
path: .build/node_modules_cache
43
cacheHitVar: NODE_MODULES_RESTORED
44
displayName: Restore node_modules cache
45
46
- script: |
47
set -e
48
# Set the private NPM registry to the global npmrc file
49
# so that authentication works for subfolders like build/, remote/, extensions/ etc
50
# which does not have their own .npmrc file
51
npm config set registry "$NPM_REGISTRY"
52
echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"
53
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
54
displayName: Setup NPM
55
56
- task: npmAuthenticate@0
57
inputs:
58
workingFile: $(NPMRC_PATH)
59
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
60
displayName: Setup NPM Authentication
61
62
- task: Docker@1
63
inputs:
64
azureSubscriptionEndpoint: vscode
65
azureContainerRegistry: vscodehub.azurecr.io
66
command: "Run an image"
67
imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"
68
containerCommand: uname
69
displayName: "Pull image"
70
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
71
72
- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev
73
displayName: Install build dependencies
74
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
75
76
- script: |
77
set -e
78
mkdir -p .build/nodejs-musl
79
NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)
80
BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)
81
gh 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 --clobber
82
tar -xzf ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" -C ".build/nodejs-musl" --strip-components=1
83
rm ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz"
84
env:
85
GITHUB_TOKEN: "$(github-distro-mixin-password)"
86
displayName: Download NodeJS MUSL
87
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
88
89
- script: |
90
set -e
91
92
for i in {1..5}; do # try 5 times
93
npm ci && break
94
if [ $i -eq 5 ]; then
95
echo "Npm install failed too many times" >&2
96
exit 1
97
fi
98
echo "Npm install failed $i, trying again..."
99
done
100
env:
101
npm_config_arch: $(NPM_ARCH)
102
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
103
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
104
GITHUB_TOKEN: "$(github-distro-mixin-password)"
105
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME: vscodehub.azurecr.io/vscode-linux-build-agent:alpine-$(VSCODE_ARCH)
106
VSCODE_HOST_MOUNT: "/mnt/vss/_work/1/s"
107
VSCODE_NPMRC_PATH: $(NPMRC_PATH)
108
displayName: Install dependencies
109
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
110
111
- script: node build/azure-pipelines/distro/mixin-npm.ts
112
displayName: Mixin distro node modules
113
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
114
115
- script: |
116
set -e
117
node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt
118
mkdir -p .build/node_modules_cache
119
tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
120
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
121
displayName: Create node_modules archive
122
123