Repository navigation
495 lines (479 loc) · 19.7 KB
/
Copy pathbuild.yml
File metadata and controls
495 lines (479 loc) · 19.7 KB
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
name: Build
on:
push:
branches:
- master
- branch-*
- dogfood-*
pull_request:
workflow_dispatch:
schedule:
- cron: "30 1 * * 1-5" # Run Mon-Fri at 1:30 AM UTC
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
USE_DEVELOCITY: true
DEVELOCITY_URL: https://develocity.sonar.build/
MAVEN_OUTPUT_ARGS: "--errors --show-version"
jobs:
build:
runs-on: warp-custom-ubuntu-24-04
name: Build
permissions:
id-token: write # Required for Vault OIDC authentication
contents: write # Required for repository access and tagging
outputs:
build-number: ${{ steps.build-maven.outputs.BUILD_NUMBER }}
deployed: ${{ steps.build-maven.outputs.deployed }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- uses: SonarSource/ci-github-actions/build-maven@v2
id: build-maven
env:
MAVEN_OPTS: "-Xmx8g"
with:
repox-url: https://repox-internal.dev.sonar.build
deploy-pull-request: true
sonar-platform: none # Prevent analysis
# Override artifactory roles for public repo using private access
artifactory-reader-role: private-reader
artifactory-deployer-role: qa-deployer
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
maven-args: >
--define maven.test.skip=true
--define sonar.skip=true
--projects !java-checks-test-sources/aws,!java-checks-test-sources/default,!java-checks-test-sources/java-17,!java-checks-test-sources/spring-3.2,!java-checks-test-sources/spring-web-4.0
# PVF: publish the concrete deployed plugin version so pvf-comment.yml can dispatch a performance-validation run into peachee-java-kotlin.
- name: Prepare PVF candidate version
if: ${{ steps.build-maven.outputs.deployed }}
uses: SonarSource/core-languages-tooling-public/prepare-pvf@master
with:
build-version: ${{ steps.build-maven.outputs.project-version }}
ruling-qa:
strategy:
fail-fast: false
matrix:
item:
- { runner: warp-custom-ubuntu-24-04, profile: without-sonarqube-project, sq_version: LATEST_RELEASE }
- { runner: warp-custom-ubuntu-24-04, profile: only-sonarqube-project, sq_version: LATEST_RELEASE }
- { runner: warp-custom-windows-2022-l, profile: without-sonarqube-project, sq_version: LATEST_RELEASE }
- { runner: warp-custom-windows-2022-m, profile: only-sonarqube-project, sq_version: LATEST_RELEASE }
name: Ruling QA
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: ${{ matrix.item.runner }}
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- name: Config Git
if: runner.os == 'Windows'
run: git config --global core.autocrlf input
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- name: Select Java Version
shell: bash # Set explicitly so Bash is used on Windows runners too.
run: |
mise use java@21
JAVA_21_HOME="$(mise where java@21)"
echo "JAVA_HOME=${JAVA_21_HOME}" >> "$GITHUB_ENV"
echo "${JAVA_21_HOME}/bin" >> "$GITHUB_PATH"
- uses: ./.github/actions/maven-cache
with:
namespace: ruling-qa-${{ matrix.item.runner }}-${{ matrix.item.profile }}-${{ matrix.item.sq_version }}
- name: Configure Maven
uses: SonarSource/ci-github-actions/config-maven@v2
with:
repox-url: https://repox-internal.dev.sonar.build
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
disable-caching: 'true'
- name: Getting Vault Secrets
id: secrets
uses: SonarSource/vault-action-wrapper@v3
with:
secrets: |
development/github/token/licenses-ro token | GITHUB_TOKEN;
development/artifactory-edge-prod/token/{REPO_OWNER_NAME_DASH}-private-reader access_token | ORCHESTRATOR_ACCESS_TOKEN;
- name: Configure production Orchestrator
shell: bash
env:
ORCHESTRATOR_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ORCHESTRATOR_ACCESS_TOKEN }}
run: |
umask 077
config_dir="$RUNNER_TEMP/orchestrator-production-config"
mkdir -p "$config_dir"
printf '%s\n' \
'orchestrator.artifactory.url=https://repox-internal.sonar.build/artifactory' \
"orchestrator.artifactory.accessToken=$ORCHESTRATOR_ACCESS_TOKEN" > "$config_dir/orchestrator.properties"
config_path="$config_dir/orchestrator.properties"
if [[ "$RUNNER_OS" == Windows ]]; then
config_path="/$(cygpath -m "$config_path")"
fi
config_path="${config_path// /%20}"
echo "ORCHESTRATOR_CONFIG_URL=file://$config_path" >> "$GITHUB_ENV"
- name: Orchestrator Cache
uses: ./.github/actions/orchestrator-cache
with:
sq-version: ${{ matrix.item.sq_version }}
- name: Run ruling tests
shell: bash # Set explicitly so Bash is used on Windows runners too.
env:
MAVEN_OPTS: "-Xmx3g -Dfile.encoding=UTF-8"
JAVA_TOOL_OPTIONS: ""
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
ORCHESTRATOR_HOME: ${{ github.event_name == 'pull_request' && format('{0}/orchestrator-production', runner.temp) || env.ORCHESTRATOR_HOME }}
run: |
cd its/ruling
extra_args=()
# Nested Maven builds share ~/.m2; Windows denies concurrent writes to *.lastUpdated.
if [[ "${RUNNER_OS}" != "Windows" ]]; then
extra_args+=(-Dparallel=methods -DuseUnlimitedThreads=true)
fi
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" package ${MAVEN_OUTPUT_ARGS} "-Pit-ruling,${{ matrix.item.profile }}" -Dsonar.runtimeVersion=${{ matrix.item.sq_version }} -Dmaven.test.redirectTestOutputToFile=false "${extra_args[@]}"
- name: Upload Actual Results On Failure
if: failure()
uses: ./.github/actions/upload-actual
with:
name: ${{ matrix.item.runner }}_${{ matrix.item.profile }}
it-dir: its/ruling
expected-dir: src/test/resources/expected
actual-dir: target/actual
ruling-update-notify:
name: Ruling Update and Notify
needs: ruling-qa
if: always() && github.event_name == 'pull_request'
runs-on: warp-custom-ubuntu-24-04
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
enable-cache: true
- name: Check ruling-qa results
id: check-ruling
run: |
# Check if any ruling-qa job failed
# For matrix jobs, needs.ruling-qa.result can be 'success' only if ALL jobs succeeded
RULING_FAILED=false
if [[ "${{ needs.ruling-qa.result }}" != "success" ]]; then
RULING_FAILED=true
fi
echo "ruling-failed=$RULING_FAILED" >> "$GITHUB_OUTPUT"
echo "Ruling QA result: ${{ needs.ruling-qa.result }}, failed=$RULING_FAILED"
- name: Update ruling and notify
uses: SonarSource/core-languages-tooling-public/ruling-update-and-notify@master
with:
ruling-failed: ${{ steps.check-ruling.outputs.ruling-failed }}
env:
GH_TOKEN: ${{ github.token }}
plugin-qa:
strategy:
fail-fast: false
matrix:
sq_version: ['LATEST_RELEASE', 'DEV']
is_nightly:
- ${{ github.event_name == 'schedule' }}
exclude:
- sq_version: DEV
is_nightly: false
name: Plugin QA
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: warp-custom-ubuntu-24-04
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- name: Select Java Version
shell: bash # Set explicitly so Bash is used on Windows runners too.
run: |
mise use java@21
JAVA_21_HOME="$(mise where java@21)"
echo "JAVA_HOME=${JAVA_21_HOME}" >> "$GITHUB_ENV"
echo "${JAVA_21_HOME}/bin" >> "$GITHUB_PATH"
- uses: ./.github/actions/maven-cache
with:
namespace: plugin-qa-${{ matrix.sq_version }}
- name: Configure Maven
uses: SonarSource/ci-github-actions/config-maven@v2
with:
repox-url: https://repox-internal.dev.sonar.build
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
disable-caching: 'true'
- name: Getting Vault Secrets
id: secrets
uses: SonarSource/vault-action-wrapper@v3
with:
secrets: |
development/github/token/licenses-ro token | GITHUB_TOKEN;
development/artifactory-edge-prod/token/{REPO_OWNER_NAME_DASH}-private-reader access_token | ORCHESTRATOR_ACCESS_TOKEN;
- name: Configure production Orchestrator
shell: bash
env:
ORCHESTRATOR_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ORCHESTRATOR_ACCESS_TOKEN }}
run: |
umask 077
config_dir="$RUNNER_TEMP/orchestrator-production-config"
mkdir -p "$config_dir"
printf '%s\n' \
'orchestrator.artifactory.url=https://repox-internal.sonar.build/artifactory' \
"orchestrator.artifactory.accessToken=$ORCHESTRATOR_ACCESS_TOKEN" > "$config_dir/orchestrator.properties"
config_path="$config_dir/orchestrator.properties"
if [[ "$RUNNER_OS" == Windows ]]; then
config_path="/$(cygpath -m "$config_path")"
fi
config_path="${config_path// /%20}"
echo "ORCHESTRATOR_CONFIG_URL=file://$config_path" >> "$GITHUB_ENV"
- name: Orchestrator Cache
uses: ./.github/actions/orchestrator-cache
with:
sq-version: ${{ matrix.sq_version }}
- name: Plugin QA
env:
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
ORCHESTRATOR_HOME: ${{ github.event_name == 'pull_request' && format('{0}/orchestrator-production', runner.temp) || env.ORCHESTRATOR_HOME }}
run: |
cd its/plugin
mvn "-Dorchestrator.configUrl=$ORCHESTRATOR_CONFIG_URL" "-Dorchestrator.home=$ORCHESTRATOR_HOME" package ${MAVEN_OUTPUT_ARGS} -Pit-plugin -Dsonar.runtimeVersion=${{ matrix.sq_version }} -Dmaven.test.redirectTestOutputToFile=false -Dparallel=classes -DuseUnlimitedThreads=true
sanity:
name: Sanity Test
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: warp-custom-ubuntu-24-04
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- uses: SonarSource/vault-action-wrapper@v3
id: secrets
with:
secrets: |
development/kv/data/next url | SONAR_HOST_URL;
development/kv/data/next token | SONAR_TOKEN;
- uses: ./.github/actions/maven-cache
with:
namespace: sanity
- uses: SonarSource/ci-github-actions/config-maven@v2
with:
repox-url: https://repox-internal.dev.sonar.build
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
disable-caching: 'true'
- name: Compile Test Sources
env:
SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_HOST_URL }}
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_TOKEN }}
working-directory: java-checks-test-sources
run: |
mvn clean compile --batch-mode
- name: Sanity Test
env:
SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_HOST_URL }}
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_TOKEN }}
MAVEN_OPTS: "-Xmx8g"
run: |
mvn verify ${MAVEN_OUTPUT_ARGS} -f sonar-java-plugin/pom.xml -Psanity -Dtest=SanityTest
test-analyze:
name: Test Analyze
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: warp-custom-ubuntu-24-04-l
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- uses: SonarSource/vault-action-wrapper@v3
id: secrets
with:
secrets: |
development/kv/data/next url | SONAR_HOST_URL;
development/kv/data/next token | SONAR_TOKEN;
- uses: SonarSource/ci-github-actions/build-maven@v2
with:
repox-url: https://repox-internal.dev.sonar.build
deploy: false
artifactory-reader-role: private-reader # Override default public-reader
artifactory-deployer-role: qa-deployer # Override default public-deployer
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
scanner-java-opts: '-Xmx2g'
env:
SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_HOST_URL }}
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_TOKEN }}
MAVEN_OPTS: "-Xmx8g"
JAVA_TOOL_OPTIONS: "" # Set an empty value to avoid issues with runners hanging and significantly slowing down builds
custom-rules-license-check:
name: Custom Rules and License Check
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: warp-custom-ubuntu-24-04
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- uses: SonarSource/vault-action-wrapper@v3
id: secrets
with:
secrets: |
development/kv/data/next url | SONAR_HOST_URL;
development/kv/data/next token | SONAR_TOKEN;
- uses: ./.github/actions/maven-cache
with:
namespace: custom-rules-license-check
- uses: SonarSource/ci-github-actions/config-maven@v2
with:
repox-url: https://repox-internal.dev.sonar.build
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
disable-caching: 'true'
env:
SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_HOST_URL }}
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_TOKEN }}
JAVA_TOOL_OPTIONS: "" # Set an empty value to avoid issues with runners hanging and significantly slowing down builds
- name: Build Java Custom Rules Example
env:
SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_HOST_URL }}
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_TOKEN }}
working-directory: docs/java-custom-rules-example
run: |
mvn clean package -f pom_SQ_10_6_LATEST.xml --batch-mode
- name: Check License Compliance
run: |
# See https://xtranet.sonarsource.com/display/DEV/Open+Source+Licenses
mvn org.codehaus.mojo:license-maven-plugin:aggregate-add-third-party \
--batch-mode \
"-Dlicense.missingFile=${PWD}/missing-dep-licenses.properties" \
-DuseMissingFile
qa-os-win:
name: Build and Unit Test on Windows
# No dependency on build step, because we do not need the build number.
runs-on: warp-custom-windows-2022-m
permissions:
id-token: write # Required for Vault OIDC authentication
contents: write # Required for repository access and tagging
steps:
- name: Config Git
run: git config --global core.autocrlf input
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
with:
version: 2026.10.0
- uses: ./.github/actions/maven-cache
with:
namespace: qa-os-win
- name: Configure Maven
uses: SonarSource/ci-github-actions/config-maven@v2
with:
repox-url: https://repox-internal.dev.sonar.build
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
disable-caching: 'true'
- name: Run Maven
env:
JAVA_TOOL_OPTIONS: ""
MAVEN_OPTS: "-Xmx8g"
run: mvn clean verify --batch-mode
promote:
needs:
- build
- ruling-qa
- plugin-qa
- sanity
- test-analyze
- custom-rules-license-check
- qa-os-win
if: ${{ needs.build.outputs.deployed }}
runs-on: warp-custom-ubuntu-24-04
name: Promote
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: SonarSource/ci-github-actions/promote@v2
with:
promote-pull-request: true
notify-build-failure:
name: Notify Build Failure
needs:
- build
- ruling-qa
- plugin-qa
- sanity
- test-analyze
- custom-rules-license-check
- qa-os-win
- promote
if: >-
always()
&& (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/branch-') || startsWith(github.ref, 'refs/heads/dogfood-'))
&& contains(needs.*.result, 'failure')
runs-on: sonar-xs-public
permissions:
actions: read # lets the action list this run's own jobs via the GitHub API
id-token: write # required for vault-action-wrapper in the shared slack-notify action
steps:
- name: Slack Notification
uses: SonarSource/core-languages-tooling-public/common-actions/slack-notify@v1
with:
slack-channel: squad-corelang-notifs
branch-patterns: ${{ format('{0},branch-*,dogfood-*', github.event.repository.default_branch) }}
github-token: ${{ github.token }}
branch: ${{ github.ref_name }}