forked from SonarSource/sonarlint-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
404 lines (391 loc) · 15.1 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
- group: sonarsource-build-variables
resources:
repositories:
- repository: commonTemplates
type: git
name: pipelines-yaml-templates
ref: refs/tags/v2.0.0
stages:
- template: stage-with-burgr-notifications.yml@commonTemplates
parameters:
burgrName: 'build'
burgrType: 'build'
stageName: 'build'
stageDisplayName: Build and stage to repox
jobs:
- job: build
displayName: Build and stage to repox
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- checkout: self
fetchDepth: 1
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
npm
path: $(npm_config_cache)
displayName: Cache npm
- task: Npm@1
displayName: 'Install NPM dependencies'
env:
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
inputs:
command: install
- task: DownloadSecureFile@1
displayName: 'Download the sign key'
name: signKey
inputs:
secureFile: 'sign-key.asc'
- task: gulp@1
displayName: 'Build and deploy universal VSIX'
env:
SIGN_KEY: $(signKey.secureFilePath)
PGP_PASSPHRASE: $(PGP_PASSPHRASE)
ARTIFACTORY_DEPLOY_USERNAME: $(ARTIFACTORY_DEPLOY_USERNAME)
ARTIFACTORY_DEPLOY_PASSWORD: $(ARTIFACTORY_DEPLOY_PASSWORD)
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
inputs:
gulpjs: node_modules/.bin/gulp
targets: deploy
condition: and(succeeded(), and(ne(variables['Build.SourceBranch'], 'refs/heads/master'), not(endsWith(variables['System.PullRequest.SourceBranch'], 'allvsix'))))
- task: gulp@1
displayName: 'Build and deploy all VSIX files'
env:
SIGN_KEY: $(signKey.secureFilePath)
PGP_PASSPHRASE: $(PGP_PASSPHRASE)
ARTIFACTORY_DEPLOY_USERNAME: $(ARTIFACTORY_DEPLOY_USERNAME)
ARTIFACTORY_DEPLOY_PASSWORD: $(ARTIFACTORY_DEPLOY_PASSWORD)
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
inputs:
gulpjs: node_modules/.bin/gulp
targets: deploy-all
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), endsWith(variables['System.PullRequest.SourceBranch'], 'allvsix')))
- bash: git checkout .
name: revertPackageJsonChanges
displayName: Revert changes made to package.json to not break cache feature
- template: stage-with-burgr-notifications.yml@commonTemplates
parameters:
burgrName: 'validate'
burgrType: 'validate'
stageName: 'validate'
stageDisplayName: Run tests, SonarQube analysis and Mend scan
jobs:
- job: test_windows
displayName: Run tests on Windows
pool:
vmImage: 'windows-latest'
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: PythonScript@0
name: extractPackageVersion
displayName: Extract version from package.json
inputs:
scriptSource: 'inline'
script: |
import json
with open('package.json') as packageJsonFile:
packageJson = json.load(packageJsonFile)
print("##vso[task.setvariable variable=packageVersion]" + packageJson['version'])
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
npm
path: $(npm_config_cache)
displayName: Cache npm
- task: Npm@1
displayName: 'Install NPM dependencies'
env:
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
inputs:
command: ci
- task: Npm@1
displayName: 'Compile TypeScript'
inputs:
command: custom
customCommand: run compile
- task: Npm@1
displayName: 'Fetch language server and its dependencies'
continueOnError: true
inputs:
command: custom
customCommand: run prepare
env:
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
- task: Npm@1
displayName: 'Run tests with coverage on Windows'
inputs:
command: custom
customCommand: run test-cov
env:
NODE_ENV : 'continuous-integration'
JAVA_HOME : $(JAVA_HOME_17_X64)
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/alltests.xml'
failTaskOnFailedTests: true
testRunTitle: 'UTs on Windows'
- bash: git checkout .
name: revertPackageJsonChanges
displayName: Revert changes made to package.json to not break cache feature
- job: test_linux
displayName: Run tests, SonarQube analysis and Mend analysis on Linux
pool:
vmImage: 'ubuntu-latest'
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: PythonScript@0
name: extractPackageVersion
displayName: Extract version from package.json
inputs:
scriptSource: 'inline'
script: |
import json
with open('package.json') as packageJsonFile:
packageJson = json.load(packageJsonFile)
print("##vso[task.setvariable variable=packageVersion]" + packageJson['version'])
print("##vso[task.setvariable variable=MEND_PROJECT_VERSION]" + packageJson['version'].replace('-SNAPSHOT', ''))
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
npm
path: $(npm_config_cache)
displayName: Cache npm
- bash: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y xvfb
sudo cp .azure-pipelines/xvfb.init /etc/init.d/xvfb
sudo chmod +x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
sudo service xvfb start
export DISPLAY=':10'
displayName: 'Install and start xvfb'
- template: prepare-sq-analysis-steps.yml
parameters:
scannerMode: CLI
configMode: manual
projectKey: 'org.sonarsource.sonarlint.vscode:sonarlint-vscode'
projectName: 'SonarLint for VSCode'
projectVersion: $(packageVersion)
extraProperties: |
sonar.tests=test,its/src
sonar.exclusions=test/**, build/**, out/**, out-cov/**, coverage/**, node_modules/**, **/node_modules/**, **/its/**, **/dogfood/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.coverage.exclusions=gulpfile.js, webpack.config.js, scripts/**
- task: Npm@1
displayName: 'Install NPM dependencies'
env:
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
inputs:
command: ci
- task: Npm@1
displayName: 'Compile TypeScript'
inputs:
command: custom
customCommand: run compile
- task: Npm@1
displayName: 'Fetch language server and its dependencies'
continueOnError: true
inputs:
command: custom
customCommand: run prepare
env:
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
- task: Npm@1
displayName: 'Run tests with coverage on Linux'
inputs:
command: custom
customCommand: run test-cov
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/alltests.xml'
failTaskOnFailedTests: true
testRunTitle: 'UTs on Linux'
- bash: git checkout .
name: revertPackageJsonChanges
displayName: Revert changes made to package.json to not break cache feature
- task: SonarQubeAnalyze@4
displayName: 'Run SonarQube analysis on Next'
- template: mend.yml@commonTemplates
parameters:
productName : 'SonarLint/VSCode'
releaseVersion: '$(MEND_PROJECT_VERSION)'
- template: stage-with-burgr-notifications.yml@commonTemplates
parameters:
burgrName: 'qa'
burgrType: 'qa'
stageName: 'qa'
stageDisplayName: Run ITs
stageDependencies: build
jobs:
- job: its
displayName: Run ITs
strategy:
matrix:
oldest_supported:
VSCODE_VERSION: '1.73.0'
stable:
VSCODE_VERSION: 'stable'
insiders:
VSCODE_VERSION: 'insiders'
variables:
MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
MAVEN_OPTS: '-Xmx3072m -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- checkout: self
fetchDepth: 1
- task: PythonScript@0
name: computeVersion
displayName: Extract version from package.json and compute build version
inputs:
scriptSource: 'inline'
script: |
import json
with open('package.json') as packageJsonFile:
packageJson = json.load(packageJsonFile)
print("##vso[task.setvariable variable=PROJECT_VERSION]" + packageJson['version'].replace('-SNAPSHOT', '+$(Build.BuildId)'))
- task: Cache@2
displayName: Cache Maven local repo
inputs:
key: 'maven | "$(Agent.OS)" | azure-pipelines.yml'
restoreKeys: |
maven | "$(Agent.OS)"
maven
path: $(MAVEN_CACHE_FOLDER)
- task: DownloadSecureFile@1
displayName: 'Download Maven settings'
name: mavenSettings
inputs:
secureFile: 'maven-settings.xml'
- bash: >-
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -B --settings $(mavenSettings.secureFilePath) -Denable-repo=qa
-Dartifact=org.sonarsource.sonarlint.vscode:sonarlint-vscode:$(PROJECT_VERSION):vsix -DoutputDirectory=$(Build.SourcesDirectory)
displayName: ' Download staged vsix'
env:
ARTIFACTORY_QA_READER_USERNAME: $(ARTIFACTORY_QA_READER_USERNAME)
ARTIFACTORY_QA_READER_PASSWORD: $(ARTIFACTORY_QA_READER_PASSWORD)
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | its/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
npm
path: $(npm_config_cache)
displayName: Cache npm
- bash: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y xvfb
sudo cp .azure-pipelines/xvfb.init /etc/init.d/xvfb
sudo chmod +x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
sudo service xvfb start
export DISPLAY=':10'
displayName: 'Install and start xvfb'
- task: JavaToolInstaller@0
displayName: 'Switch to Java 11'
inputs:
versionSpec: '11'
jdkSourceOption: PreInstalled
jdkArchitectureOption: x64
cleanDestinationDirectory: false
- task: Npm@1
displayName: 'Install NPM dependencies'
inputs:
workingDir: its
command: ci
- task: Npm@1
displayName: 'Run ITs'
inputs:
workingDir: its
command: custom
customCommand: test
- bash: |
echo " "
echo " >>>>> SonarLint console"
echo " "
find its/userdir -name '*SonarLint.log' -exec cat {} \;
echo " "
echo " >>>>> Extension host log"
echo " "
find its/userdir -name 'exthost.log' -exec cat {} \;
condition: succeededOrFailed()
displayName: 'Dump Code logs'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/*tests.xml'
failTaskOnFailedTests: true
testRunTitle: 'ITs $(VSCODE_VERSION)'
- template: promote-stage.yml@commonTemplates
parameters:
stageDependencies:
- validate
- qa
- template: stage-with-burgr-notifications.yml@commonTemplates
parameters:
burgrName: 'dogfood'
burgrType: 'dogfood'
stageName: 'update_dogfood_repo'
stageDisplayName: Update internal extension dogfooding file
stageCondition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
stageDependencies: promote
jobs:
- job: updateInternalSite
displayName: Update internal dogfooding file on repox
steps:
- checkout: none
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
- bash: pip3 install requests
- task: PythonScript@0
name: updateInternalSiteOnRepox
inputs:
scriptSource: 'inline'
script: |
import requests
import sys
import json
githubSlug = '$(Build.Repository.ID)'
githubProject = githubSlug.split("/", 1)[1]
buildNumber = '$(Build.BuildId)'
buildInfoUrl = f'$(ARTIFACTORY_URL)/api/build/{githubProject}/{buildNumber}'
buildInfoResp = requests.get(url=buildInfoUrl, auth=('$(ARTIFACTORY_API_USER)', '$(ARTIFACTORY_API_KEY)'))
buildInfoJson = buildInfoResp.json()
buildInfo = buildInfoJson.get('buildInfo', {})
buildInfoProperties = buildInfo.get('properties', {})
# PROJECT_VERSION is set by the compute-build-version-step.yml
version = buildInfoProperties.get('buildInfo.env.PROJECT_VERSION', 'NOT_FOUND')
dogfoodJson = json.dumps({
'version': version,
'url': f"$(ARTIFACTORY_URL)/sonarsource/org/sonarsource/sonarlint/vscode/sonarlint-vscode/{version}/sonarlint-vscode-{version}.vsix"
})
updateDogfoodJsonUrl = "$(ARTIFACTORY_URL)/sonarsource-public-builds/org/sonarsource/sonarlint/vscode/sonarlint-vscode/dogfood.json"
response = requests.put(url=updateDogfoodJsonUrl, data=dogfoodJson, auth=('$(ARTIFACTORY_API_USER)', '$(ARTIFACTORY_API_KEY)'))
if not response.status_code == 201:
sys.exit('[!] [{0}] Server Error'.format(response.status_code))