-
Notifications
You must be signed in to change notification settings - Fork 183
/
.cirrus.yml
417 lines (391 loc) · 14.4 KB
/
.cirrus.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
405
406
407
408
409
410
411
412
413
414
415
416
417
env:
CIRRUS_VAULT_URL: https://vault.sonar.build:8200
CIRRUS_VAULT_AUTH_PATH: jwt-cirrusci
CIRRUS_VAULT_ROLE: cirrusci-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}
ARTIFACTORY_URL: https://repox.jfrog.io/artifactory
ARTIFACTORY_PRIVATE_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader
ARTIFACTORY_PRIVATE_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
ARTIFACTORY_DEPLOY_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer
ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa
ARTIFACTORY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
GITHUB_TOKEN: VAULT[development/github/token/licenses-ro token]
# Use bash (instead of sh on linux or cmd.exe on windows)
CIRRUS_SHELL: bash
container_definition: &CONTAINER_DEFINITION
cluster_name: ${CIRRUS_CLUSTER_NAME}
builder_role: cirrus-builder
builder_image: docker-builder-v*
builder_instance_type: t3.small
region: eu-central-1
namespace: default
use_in_memory_disk: true
cpu: 10
memory: 40G
maven_cache_definition: &MAVEN_CACHE
maven_cache:
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
fingerprint_script: cat **/pom.xml
orchestrator_cache_preparation_definition: &ORCHESTRATOR_CACHE
set_orchestrator_home_script: |
export TODAY=$(date '+%Y-%m-%d')
echo "TODAY=${TODAY}" >> $CIRRUS_ENV
echo "ORCHESTRATOR_HOME=${CIRRUS_WORKING_DIR}/orchestrator/${TODAY}" >> $CIRRUS_ENV
mkdir_orchestrator_home_script: |
echo "Create dir ${ORCHESTRATOR_HOME} if needed"
mkdir -p ${ORCHESTRATOR_HOME}
orchestrator_cache:
folder: ${ORCHESTRATOR_HOME}
fingerprint_script: echo ${TODAY}
reupload_on_changes: 'true'
nodejs_runtimes_cache_definition: &RUNTIME_CACHE
runtime_cache:
folder: tools/fetch-node/downloads/
fingerprint_script: cat tools/fetch-node/node-distros.mjs
win_vm_definition: &WINDOWS_VM_DEFINITION
ec2_instance:
experimental: true # see https://github.com/cirruslabs/cirrus-ci-docs/issues/1051
image: base-windows-jdk17-v*
platform: windows
region: eu-central-1
type: c6id.4xlarge
preemptible: false
use_ssd: true
npmrc_script_definition: &NPMRC_SCRIPT_DEFINITION
npmrc_script:
- cp .cirrus/npmrc $CIRRUS_WORKING_DIR/.npmrc
- cp .cirrus/npmrc $CIRRUS_WORKING_DIR/packages/jsts/src/rules/.npmrc
- cp .cirrus/npmrc $CIRRUS_WORKING_DIR/its/eslint8-plugin-sonarjs/.npmrc
- cp .cirrus/npmrc $CIRRUS_WORKING_DIR/its/eslint9-plugin-sonarjs/.npmrc
win_ssd_and_clone:
&WIN_SSD_AND_CLONE # copy&paste from https://github.com/SonarSource/sonar-cpp/blob/a8c6f1e45a12393508682a013ac7ee35eb92bece/.cirrus.yml#L45
prepare_disk_script:
- ps: |
Get-Disk -Number 2 | Initialize-Disk -PassThru | New-Partition -UseMaximumSize -DriveLetter Z
Format-Volume -DriveLetter Z -FileSystem NTFS -Confirm:$false
- echo "CIRRUS_WORKING_DIR=Z:/cirrus-ci-build" >> $CIRRUS_ENV
# we don't clone submodules because they are not needed for the tests
clone_script: |
git config --system core.longpaths true
if [ -z "$CIRRUS_PR" ]; then
git clone --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi
only_sonarsource_qa: &ONLY_SONARSOURCE_QA
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "dogfood-on-.*")
plugin_qa_body: &PLUGIN_QA_BODY
depends_on:
- build
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
env:
CIRRUS_CLONE_DEPTH: 10
SONARSOURCE_QA: true
<<: *MAVEN_CACHE
<<: *ORCHESTRATOR_CACHE
qa_script:
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- mvn -f its/plugin/pom.xml -Dsonar.runtimeVersion=${SQ_VERSION} ${MVN_TEST} -B -e -V verify surefire-report:report
cleanup_before_cache_script: cleanup_maven_repository
build_task:
eks_container:
<<: *CONTAINER_DEFINITION
dockerfile: .cirrus/nodejs.Dockerfile
docker_arguments:
CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
NODE_VERSION: 22
env:
#allow deployment of pull request artifacts to repox
DEPLOY_PULL_REQUEST: true
#sign artifacts
SIGN_KEY: VAULT[development/kv/data/sign data.key]
PGP_PASSPHRASE: VAULT[development/kv/data/sign data.passphrase]
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
ARTIFACTORY_DEPLOY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
<<: *MAVEN_CACHE
<<: *RUNTIME_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
build_and_deploy_script:
- source cirrus-env BUILD
- node --version
- npm ci
- npm run check-format
- npm run build
- regular_mvn_build_deploy_analyze -Dmaven.test.skip=true -Dmaven.install.skip=true -Dsonar.skip=true
cleanup_before_cache_script: cleanup_maven_repository
analyze_task:
eks_container:
<<: *CONTAINER_DEFINITION
dockerfile: .cirrus/nodejs.Dockerfile
docker_arguments:
CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
NODE_VERSION: 22
depends_on:
- build
env:
# analysis on next
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
ARTIFACTORY_DEPLOY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
<<: *MAVEN_CACHE
<<: *RUNTIME_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
build_and_analyze_script:
- source cirrus-env QA
- npm run build:cov
- PULL_REQUEST_SHA=$GIT_SHA1 regular_mvn_build_deploy_analyze -P-deploy-sonarsource,-release,-sign -Dcommercial -Dmaven.shade.skip=true -Dmaven.install.skip=true -Dmaven.deploy.skip=true -Dsonar.coverage.jacoco.xmlReportPaths=$CIRRUS_WORKING_DIR/report-aggregate/target/site/jacoco-aggregate/jacoco.xml
build_win_task:
depends_on:
- build
<<: *WINDOWS_VM_DEFINITION
<<: *ONLY_SONARSOURCE_QA
<<: *MAVEN_CACHE
<<: *RUNTIME_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
build_script:
- source cirrus-env CI
- npm run build
cleanup_before_cache_script: cleanup_maven_repository
ws_scan_task:
depends_on:
- build
eks_container:
<<: *CONTAINER_DEFINITION
dockerfile: .cirrus/nodejs.Dockerfile
docker_arguments:
CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
cpu: 4
memory: 8G
# run only on master and long-term branches
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && ($CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*")
env:
WS_APIKEY: VAULT[development/kv/data/mend data.apikey]
<<: *MAVEN_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
whitesource_script:
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- npm ci
- source ws_scan.sh
allow_failures: 'true'
always:
ws_artifacts:
path: 'whitesource/**/*'
plugin_qa_with_node_task:
<<: *PLUGIN_QA_BODY
eks_container:
dockerfile: .cirrus/nodejs.Dockerfile
env:
SQ_VERSION: LATEST_RELEASE
MVN_TEST: ''
plugin_qa_no_node_task:
<<: *PLUGIN_QA_BODY
eks_container:
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
env:
SQ_VERSION: LATEST_RELEASE
SONARJS_ARTIFACT: multi
MVN_TEST: '-Dtest=!EslintCustomRulesTest,!SonarJsIntegrationTest --projects !org.sonarsource.javascript:eslint-custom-rules-plugin'
plugin_qa_sq_dev_task:
<<: *PLUGIN_QA_BODY
eks_container:
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
env:
SQ_VERSION: 'DEV[10.8]' # replace this with "DEV" when platform squad is ready
SONARJS_ARTIFACT: multi
MVN_TEST: '-Dtest=!EslintCustomRulesTest,!SonarJsIntegrationTest --projects !org.sonarsource.javascript:eslint-custom-rules-plugin'
# Plugin QA for Windows is split into 3 parts to make it faster
plugin_qa_win_task:
depends_on:
- build
<<: *WINDOWS_VM_DEFINITION
<<: *ONLY_SONARSOURCE_QA
env:
SONARSOURCE_QA: true
SQ_VERSION: LATEST_RELEASE
matrix:
- TEST: '!CoverageTest,!TypeScriptAnalysisTest,!EslintBasedRulesTest,!PRAnalysisTest,!TypeCheckerConfigTest,!VueAnalysisTest'
- TEST: 'CoverageTest,TypeScriptAnalysisTest,EslintBasedRulesTest,PRAnalysisTest,TypeCheckerConfigTest,VueAnalysisTest'
<<: *WIN_SSD_AND_CLONE
<<: *MAVEN_CACHE
<<: *ORCHESTRATOR_CACHE
qa_script:
- source /c/buildTools-docker/bin/cirrus-env QA
- source /c/buildTools-docker/bin/set_maven_build_version $BUILD_NUMBER
# building the custom plugin required for the further tests
- mvn clean package -f its/plugin/plugins/pom.xml
- mvn test -f its/plugin/tests/pom.xml -Dsonar.runtimeVersion=${SQ_VERSION} "-Dtest=${TEST}" -B -e -V surefire-report:report
cleanup_before_cache_script: cleanup_maven_repository
# Plugin QA for Windows is split into 3 parts to make it faster
plugin_qa_win_sonarlint_task:
depends_on:
- build
<<: *WINDOWS_VM_DEFINITION
<<: *ONLY_SONARSOURCE_QA
env:
SONARSOURCE_QA: true
SQ_VERSION: LATEST_RELEASE
<<: *WIN_SSD_AND_CLONE
<<: *MAVEN_CACHE
qa_script:
- source /c/buildTools-docker/bin/cirrus-env QA
- source /c/buildTools-docker/bin/set_maven_build_version $BUILD_NUMBER
- mvn test -f its/plugin/sonarlint-tests/pom.xml -Dsonar.runtimeVersion=${SQ_VERSION} -B -e -V surefire-report:report
cleanup_before_cache_script: cleanup_maven_repository
js_ts_ruling_task:
depends_on:
- build
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
dockerfile: .cirrus/nodejs.Dockerfile
docker_arguments:
CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
NODE_VERSION: 22
env:
CIRRUS_CLONE_DEPTH: 1
SONARSOURCE_QA: true
<<: *MAVEN_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
# needed because we need to build the plugin
<<: *RUNTIME_CACHE
submodules_script:
- git submodule update --init
ruling_script:
- . ~/.profile
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- npm run build:fast
- npm run update-ruling-data
- npm run ruling
on_failure:
debug_script: diff -rq its/ruling/src/test/expected/jsts packages/ruling/tests/actual/jsts
cleanup_before_cache_script: cleanup_maven_repository
eslint_plugin_test_task:
eks_container:
<<: *CONTAINER_DEFINITION
dockerfile: .cirrus/nodejs.Dockerfile
docker_arguments:
CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
env:
CIRRUS_CLONE_DEPTH: 1
SONARSOURCE_QA: true
<<: *MAVEN_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
# needed because we need to build the plugin
<<: *RUNTIME_CACHE
eslint_its_script:
- node --version
- . ~/.profile
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- npm run eslint-plugin:build
- cd its/eslint8-plugin-sonarjs
- npm install
- npx tsc --noEmit # check typings for tseslint.config.ts
- npm run test
- cd ../eslint9-plugin-sonarjs
- npm install
- npx tsc --noEmit # check typings for tseslint.config.ts
- npm run test
eslint8_node16_plugin_test_task:
eks_container:
<<: *CONTAINER_DEFINITION
dockerfile: .cirrus/nodejs16.Dockerfile
docker_arguments:
CIRRUS_AWS_ACCOUNT: ${CIRRUS_AWS_ACCOUNT}
env:
CIRRUS_CLONE_DEPTH: 1
SONARSOURCE_QA: true
<<: *MAVEN_CACHE
<<: *NPMRC_SCRIPT_DEFINITION
# needed because we need to build the plugin
<<: *RUNTIME_CACHE
eslint_its_script:
- node --version
- . ~/.profile
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- npm run eslint-plugin:build
- cd its/eslint8-plugin-sonarjs
- npm install
- npx tsc --noEmit # check typings for tseslint.config.ts
- npm run test
css_ruling_task:
depends_on:
- build
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
env:
CIRRUS_CLONE_DEPTH: 10
SONARSOURCE_QA: true
<<: *MAVEN_CACHE
<<: *ORCHESTRATOR_CACHE
submodules_script:
- git submodule update --init
ruling_script:
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- cd its/ruling
- mvn test -Dtest=CssRulingTest -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -Djunit.jupiter.execution.parallel.config.dynamic.factor=1 -B -e -V
cleanup_before_cache_script: cleanup_maven_repository
on_failure:
diff_artifacts:
path: '**/target/actual/**/*'
perf_task:
timeout_in: 240m
depends_on:
- build
trigger_type: manual
eks_container:
<<: *CONTAINER_DEFINITION
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
env:
CIRRUS_CLONE_DEPTH: 10
SONARSOURCE_QA: true
<<: *MAVEN_CACHE
<<: *ORCHESTRATOR_CACHE
submodules_script:
- git submodule update --init
perf_script:
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- cd its/perf
- mvn -B -e -V package
- mvn exec:exec -Dexec.args="-classpath %classpath org.sonar.javascript.it.perf.SonarJsPerfBenchmark LATEST_RELEASE $BUILD_NUMBER"
perf_result_artifacts:
path: 'its/perf/target/perf.txt'
cleanup_before_cache_script: cleanup_maven_repository
promote_task:
depends_on:
- ws_scan
- build_win
- plugin_qa_with_node
- plugin_qa_no_node
- plugin_qa_sq_dev
- plugin_qa_win
- plugin_qa_win_sonarlint
- css_ruling
- js_ts_ruling
- analyze
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *CONTAINER_DEFINITION
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
cpu: 2
memory: 4G
env:
ARTIFACTORY_PROMOTE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token]
GITHUB_TOKEN: VAULT[development/github/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promotion token]
<<: *MAVEN_CACHE
script: cirrus_promote_maven
cleanup_before_cache_script: cleanup_maven_repository