forked from SonarSource/sonarlint-intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
307 lines (287 loc) · 11.6 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
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:
GRADLE_USER_HOME: $(Pipeline.Workspace)/.gradle
fixedBranch: $[replace(variables['Build.SourceBranch'], 'refs/heads/', '')]
steps:
- checkout: self
fetchDepth: 1
- template: update-gradle-version-steps.yml
- task: DownloadSecureFile@1
displayName: 'Download the sign key'
name: pgpSignKey
inputs:
secureFile: 'sign-key.asc'
- bash: gpg --dearmor < $(pgpSignKey.secureFilePath) > sign-key.pgp
- task: Gradle@2
inputs:
options: --stacktrace -i -Psigning.secretKeyRingFile=sign-key.pgp -Psigning.password=$(PGP_PASSPHRASE) -Psigning.keyId=$(PGP_KEYID)
tasks: :buildPlugin :cyclonedxBom :artifactoryPublish
publishJUnitResults: false
jdkVersionOption: '1.11'
env:
CI: true # needed for gradle-intellij-plugin to skip downloading sources
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
ARTIFACTORY_DEPLOY_USERNAME: $(ARTIFACTORY_DEPLOY_USERNAME)
ARTIFACTORY_DEPLOY_PASSWORD: $(ARTIFACTORY_DEPLOY_PASSWORD)
GIT_SHA1: $(Build.SourceVersion)
GITHUB_BRANCH: $(fixedBranch)
displayName: 'Run Gradle build and deploy'
- task: Gradle@2
inputs:
options: --stop
tasks: c
publishJUnitResults: false
jdkVersionOption: '1.11'
displayName: 'Stop Gradle daemon'
- template: stage-with-burgr-notifications.yml@commonTemplates
parameters:
burgrName: 'validate'
burgrType: 'validate'
stageName: 'validate'
stageDisplayName: Run UTs and trigger SonarQube and Mend analysis
jobs:
- job: test_windows
displayName: Run unit tests on Windows
# FIXME tests on Windows are disabled because there is not enough disk space on Azure hosted agents
# pool:
# vmImage: 'windows-latest'
variables:
GRADLE_USER_HOME: $(Pipeline.Workspace)/.gradle
steps:
- checkout: self
fetchDepth: 1
- task: Gradle@2
inputs:
options: --stacktrace -i
tasks: check -x :its:check
publishJUnitResults: true
testRunTitle: 'UTs on Windows'
jdkVersionOption: '1.11'
env:
CI: true # needed for gradle-intellij-plugin to skip downloading sources
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
displayName: 'Run UTs'
- task: Gradle@2
inputs:
options: --stacktrace -i
tasks: :runPluginVerifier
jdkVersionOption: '1.11'
env:
CI: true # needed for gradle-intellij-plugin to skip downloading sources
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
displayName: 'Run plugin verifier'
- task: Gradle@2
inputs:
options: --stop
tasks: c
publishJUnitResults: false
jdkVersionOption: '1.11'
displayName: 'Stop Gradle daemon'
- job: sonarqubeAndMend
displayName: SonarQube analysis on Next and Mend analysis
variables:
GRADLE_USER_HOME: $(Pipeline.Workspace)/.gradle
steps:
- template: prepare-sq-analysis-steps.yml
- task: Gradle@2
inputs:
options: --stacktrace -i
tasks: jacocoTestReport -x :its:check
publishJUnitResults: false
jdkVersionOption: '1.11'
sonarQubeRunAnalysis: true
sqGradlePluginVersionChoice: 'build'
env:
ARTIFACTORY_PRIVATE_READER_USERNAME: $(ARTIFACTORY_PRIVATE_READER_USERNAME)
ARTIFACTORY_PRIVATE_READER_PASSWORD: $(ARTIFACTORY_PRIVATE_READER_PASSWORD)
- task: Gradle@2
inputs:
options: --stop
tasks: c
publishJUnitResults: false
jdkVersionOption: '1.11'
displayName: 'Stop Gradle daemon'
- bash: |
set -euo pipefail
VERSION=$(cat gradle.properties | grep version | awk -F= '{print $2}')
echo "Current project version is $VERSION"
# Remove -SNAPSHOT suffix
VERSION=`echo $VERSION | sed "s/-.*//g"`
echo "Mend project version is $VERSION"
echo "##vso[task.setvariable variable=MEND_PROJECT_VERSION]$VERSION"
name: getMendProjectVersion
displayName: Get Mend project version
- template: mend.yml@commonTemplates
parameters:
productName : 'SonarLint/IntelliJ'
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:
Idea2021:
IDEA_VERSION: 'IC-2021.3.3'
CLion2021:
IDEA_VERSION: 'CL-2021.3.3'
Idea2022:
IDEA_VERSION: 'IC-2022.3.2'
CLion2022:
IDEA_VERSION: 'CL-2022.3.2'
steps:
- checkout: self
fetchDepth: 1
- task: JavaToolInstaller@0
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- template: update-gradle-version-steps.yml
- 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:unpack -B --settings "$(mavenSettings.secureFilePath)" -Denable-repo=qa -Dartifact=org.sonarsource.sonarlint.intellij:sonarlint-intellij:$(PROJECT_VERSION):zip "-DoutputDirectory=$(Agent.BuildDirectory)/staged-plugin"
displayName: 'Download staged plugin'
env:
ARTIFACTORY_QA_READER_USERNAME: $(ARTIFACTORY_QA_READER_USERNAME)
ARTIFACTORY_QA_READER_PASSWORD: $(ARTIFACTORY_QA_READER_PASSWORD)
- task: DownloadSecureFile@1
name: clionKey
displayName: 'Download CLion key'
inputs:
secureFile: 'clion.key'
- bash: |
set -e -o pipefail -u
sudo apt-get update
sudo apt-get install -y metacity xvfb xauth ffmpeg
# init xvfb and metacity
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
sleep 10 # give xvfb some time to start
export DISPLAY=:10
metacity --sm-disable --replace &
sleep 10 # give metacity some time to start
mkdir -p its/build/idea-sandbox/config-uiTest/
cp $(clionKey.secureFilePath) its/build/idea-sandbox/config-uiTest/clion.key
./gradlew :its:runIdeForUiTests --stacktrace -i -PijVersion=$(IDEA_VERSION) -PslPluginDirectory=$(Agent.BuildDirectory)/staged-plugin > /tmp/runIdeGradle.log &
displayName: 'Prepare env and start IDE $(IDEA_VERSION)'
- bash: |
set -e -o pipefail -u
.azure-pipelines/wait-for-endpoint.sh http://127.0.0.1:8082 -t 500
displayName: 'Wait for IDE to start'
- bash: |
set -e -o pipefail -u
echo 'Recording tests on video'
ffmpeg -loglevel warning -f x11grab -video_size 1280x960 -framerate 10 -i :10 -q:v 0 /tmp/recording_$(IDEA_VERSION).mp4 &
echo "##vso[task.setvariable variable=recordingPid;isOutput=true]$!"
name: 'startRecording'
displayName: 'Start video recording'
- task: Gradle@2
displayName: 'Run ITs on $(IDEA_VERSION)'
inputs:
options: --stacktrace -i -PijVersion=$(IDEA_VERSION) -PslPluginDirectory=$(Agent.BuildDirectory)/staged-plugin
tasks: :its:check
publishJUnitResults: true
testRunTitle: 'Run ITs on $(IDEA_VERSION)'
jdkVersionOption: '17'
env:
CI: true # needed for gradle-intellij-plugin to skip downloading sources
ARTIFACTORY_API_KEY: $(ARTIFACTORY_API_KEY)
GITHUB_TOKEN: $(GITHUB_TOKEN)
DISPLAY: :10
- bash: |
kill -2 $(startRecording.recordingPid)
displayName: 'Stop video recording'
condition: always()
- publish: /tmp/recording_$(IDEA_VERSION).mp4
artifact: ITCaptureScreen_$(IDEA_VERSION)_$(System.JobAttempt)
condition: always()
- bash: |
cat /tmp/runIdeGradle.log
cat its/build/idea-sandbox/system/log/idea.log
displayName: 'Log'
condition: always()
- 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 dogfooding plugin repo
stageCondition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
stageDependencies: promote
jobs:
- job: updateInternalSite
displayName: Update internal plugin repo 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 os
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')
xml = f"""<plugins>
<plugin id="org.sonarlint.idea" url="$(ARTIFACTORY_URL)/sonarsource/org/sonarsource/sonarlint/intellij/sonarlint-intellij/{version}/sonarlint-intellij-{version}.zip" version="{version}"/>
</plugins>"""
updatePluginsXmlUrl = "$(ARTIFACTORY_URL)/sonarsource-public-builds/org/sonarsource/sonarlint/intellij/sonarlint-intellij/updatePlugins.xml"
response = requests.put(url=updatePluginsXmlUrl, data=xml, auth=('$(ARTIFACTORY_API_USER)', '$(ARTIFACTORY_API_KEY)'))
if not response.status_code == 201:
sys.exit('[!] [{0}] Server Error'.format(response.status_code))