Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/alpine/product-build-alpine.yml
3520 views
1
steps:
2
- template: ../common/checkout.yml@self
3
4
- task: NodeTool@0
5
inputs:
6
versionSource: fromFile
7
versionFilePath: .nvmrc
8
9
- template: ../distro/download-distro.yml@self
10
11
- task: AzureKeyVault@2
12
displayName: "Azure Key Vault: Get Secrets"
13
inputs:
14
azureSubscription: vscode
15
KeyVaultName: vscode-build-secrets
16
SecretsFilter: "github-distro-mixin-password"
17
18
- task: DownloadPipelineArtifact@2
19
inputs:
20
artifact: Compilation
21
path: $(Build.ArtifactStagingDirectory)
22
displayName: Download compilation output
23
24
- script: tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz
25
displayName: Extract compilation output
26
27
- script: node build/setup-npm-registry.js $NPM_REGISTRY
28
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
29
displayName: Setup NPM Registry
30
31
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.js alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash
32
displayName: Prepare node_modules cache key
33
34
- task: Cache@2
35
inputs:
36
key: '"node_modules" | .build/packagelockhash'
37
path: .build/node_modules_cache
38
cacheHitVar: NODE_MODULES_RESTORED
39
displayName: Restore node_modules cache
40
41
- script: tar -xzf .build/node_modules_cache/cache.tgz
42
condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))
43
displayName: Extract node_modules cache
44
45
- script: |
46
set -e
47
# Set the private NPM registry to the global npmrc file
48
# so that authentication works for subfolders like build/, remote/, extensions/ etc
49
# which does not have their own .npmrc file
50
npm config set registry "$NPM_REGISTRY"
51
echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"
52
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
53
displayName: Setup NPM
54
55
- task: npmAuthenticate@0
56
inputs:
57
workingFile: $(NPMRC_PATH)
58
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
59
displayName: Setup NPM Authentication
60
61
- task: Docker@1
62
inputs:
63
azureSubscriptionEndpoint: vscode
64
azureContainerRegistry: vscodehub.azurecr.io
65
command: "Run an image"
66
imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"
67
containerCommand: uname
68
displayName: "Pull image"
69
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
70
71
- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev
72
displayName: Install build dependencies
73
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
74
75
- script: |
76
set -e
77
mkdir -p .build/nodejs-musl
78
NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)
79
BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)
80
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
81
tar -xzf ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" -C ".build/nodejs-musl" --strip-components=1
82
rm ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz"
83
env:
84
GITHUB_TOKEN: "$(github-distro-mixin-password)"
85
displayName: Download NodeJS MUSL
86
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
87
88
- script: |
89
set -e
90
91
for i in {1..5}; do # try 5 times
92
npm ci && break
93
if [ $i -eq 5 ]; then
94
echo "Npm install failed too many times" >&2
95
exit 1
96
fi
97
echo "Npm install failed $i, trying again..."
98
done
99
env:
100
npm_config_arch: $(NPM_ARCH)
101
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
102
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
103
GITHUB_TOKEN: "$(github-distro-mixin-password)"
104
VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME: vscodehub.azurecr.io/vscode-linux-build-agent:alpine-$(VSCODE_ARCH)
105
VSCODE_HOST_MOUNT: "/mnt/vss/_work/1/s"
106
VSCODE_NPMRC_PATH: $(NPMRC_PATH)
107
displayName: Install dependencies
108
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
109
110
- script: node build/azure-pipelines/distro/mixin-npm
111
displayName: Mixin distro node modules
112
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
113
114
- script: |
115
set -e
116
node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt
117
mkdir -p .build/node_modules_cache
118
tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
119
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
120
displayName: Create node_modules archive
121
122
- script: node build/azure-pipelines/distro/mixin-quality
123
displayName: Mixin distro quality
124
125
- template: ../common/install-builtin-extensions.yml@self
126
127
- script: |
128
set -e
129
TARGET=$([ "$VSCODE_ARCH" == "x64" ] && echo "linux-alpine" || echo "alpine-arm64") # TODO@joaomoreno
130
npm run gulp vscode-reh-$TARGET-min-ci
131
(cd .. && mv vscode-reh-$TARGET vscode-server-$TARGET) # TODO@joaomoreno
132
ARCHIVE_PATH=".build/linux/server/vscode-server-$TARGET.tar.gz"
133
DIR_PATH="$(realpath ../vscode-server-$TARGET)"
134
mkdir -p $(dirname $ARCHIVE_PATH)
135
tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-$TARGET
136
echo "##vso[task.setvariable variable=SERVER_DIR_PATH]$DIR_PATH"
137
echo "##vso[task.setvariable variable=SERVER_PATH]$ARCHIVE_PATH"
138
env:
139
GITHUB_TOKEN: "$(github-distro-mixin-password)"
140
displayName: Build server
141
142
- script: |
143
set -e
144
TARGET=$([ "$VSCODE_ARCH" == "x64" ] && echo "linux-alpine" || echo "alpine-arm64")
145
npm run gulp vscode-reh-web-$TARGET-min-ci
146
(cd .. && mv vscode-reh-web-$TARGET vscode-server-$TARGET-web) # TODO@joaomoreno
147
ARCHIVE_PATH=".build/linux/web/vscode-server-$TARGET-web.tar.gz"
148
DIR_PATH="$(realpath ../vscode-server-$TARGET-web)"
149
mkdir -p $(dirname $ARCHIVE_PATH)
150
tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-$TARGET-web
151
echo "##vso[task.setvariable variable=WEB_DIR_PATH]$DIR_PATH"
152
echo "##vso[task.setvariable variable=WEB_PATH]$ARCHIVE_PATH"
153
env:
154
GITHUB_TOKEN: "$(github-distro-mixin-password)"
155
displayName: Build server (web)
156
157
- script: echo "##vso[task.setvariable variable=ARTIFACT_PREFIX]attempt$(System.JobAttempt)_"
158
condition: and(succeededOrFailed(), notIn(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues'))
159
displayName: Generate artifact prefix
160
161
- template: ../common/publish-artifact.yml@self
162
parameters:
163
targetPath: $(SERVER_PATH)
164
artifactName: $(ARTIFACT_PREFIX)vscode_server_alpine_$(VSCODE_ARCH)_archive-unsigned
165
displayName: Publish server archive
166
sbomBuildDropPath: $(SERVER_DIR_PATH)
167
sbomPackageName: "VS Code Alpine $(VSCODE_ARCH) Server"
168
sbomPackageVersion: $(Build.SourceVersion)
169
condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''), ne(variables['VSCODE_ARCH'], 'x64'))
170
171
- template: ../common/publish-artifact.yml@self
172
parameters:
173
targetPath: $(WEB_PATH)
174
artifactName: $(ARTIFACT_PREFIX)vscode_web_alpine_$(VSCODE_ARCH)_archive-unsigned
175
displayName: Publish web server archive
176
sbomBuildDropPath: $(WEB_DIR_PATH)
177
sbomPackageName: "VS Code Alpine $(VSCODE_ARCH) Web"
178
sbomPackageVersion: $(Build.SourceVersion)
179
condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''), ne(variables['VSCODE_ARCH'], 'x64'))
180
181
# same as above, keep legacy name
182
- template: ../common/publish-artifact.yml@self
183
parameters:
184
targetPath: $(SERVER_PATH)
185
artifactName: $(ARTIFACT_PREFIX)vscode_server_linux_alpine_archive-unsigned
186
displayName: Publish x64 server archive
187
sbomEnabled: false
188
condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''), eq(variables['VSCODE_ARCH'], 'x64'))
189
190
# same as above, keep legacy name
191
- template: ../common/publish-artifact.yml@self
192
parameters:
193
targetPath: $(WEB_PATH)
194
artifactName: $(ARTIFACT_PREFIX)vscode_web_linux_alpine_archive-unsigned
195
displayName: Publish x64 web server archive
196
sbomEnabled: false
197
condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''), eq(variables['VSCODE_ARCH'], 'x64'))
198
199