-
Notifications
You must be signed in to change notification settings - Fork 722
388 lines (377 loc) · 14.7 KB
/
build.yml
File metadata and controls
388 lines (377 loc) · 14.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
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-public.sonar.build/
MAVEN_OUTPUT_ARGS: "--errors --show-version"
jobs:
build:
runs-on: github-ubuntu-latest-m # Public repo uses custom GitHub-hosted runner
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- uses: SonarSource/ci-github-actions/build-maven@v1
id: build-maven
env:
MAVEN_OPTS: "-Xmx8g"
with:
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
ruling-qa:
strategy:
fail-fast: false
matrix:
item:
- { runner: github-ubuntu-latest-m, profile: without-sonarqube-project }
- { runner: github-ubuntu-latest-m, profile: only-sonarqube-project }
- { runner: github-windows-latest-m, profile: without-sonarqube-project }
- { runner: github-windows-latest-m, profile: only-sonarqube-project }
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:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- name: Select Java Version
run: mise use java@21
- name: Configure Maven
uses: SonarSource/ci-github-actions/config-maven@v1
with:
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
- name: Getting Vault Secrets
id: secrets
uses: SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # v3.1.0
with:
secrets: |
development/github/token/licenses-ro token | GITHUB_TOKEN;
- name: Run ruling tests
shell: bash # Set explicitly so Bash is used on Windows runners too.
env:
MAVEN_OPTS: "-Xmx3g"
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
run: |
cd its/ruling
mvn package ${MAVEN_OUTPUT_ARGS} "-Pit-ruling,${{ matrix.item.profile }}" -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -Dparallel=methods -DuseUnlimitedThreads=true
- 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
actual-dir: target/actual
plugin-qa:
strategy:
fail-fast: false
matrix:
item:
- sq_version: LATEST_RELEASE
java_version: 21
- sq_version: DEV
java_version: 21
name: Plugin QA
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: github-ubuntu-latest-m
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- name: Select Java Version
run: mise use java@${{ matrix.item.java_version}}
- name: Configure Maven
uses: SonarSource/ci-github-actions/config-maven@v1
with:
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
- name: Getting Vault Secrets
id: secrets
uses: SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # v3.1.0
with:
secrets: |
development/github/token/licenses-ro token | GITHUB_TOKEN;
- name: Plugin QA
env:
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
run: |
cd its/plugin
mvn package ${MAVEN_OUTPUT_ARGS} -Pit-plugin -Dsonar.runtimeVersion=${{ matrix.item.sq_version }} -Dmaven.test.redirectTestOutputToFile=false -Dparallel=classes -DuseUnlimitedThreads=true
sanity:
name: Sanity Test
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: github-ubuntu-latest-m
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- 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/config-maven@v1
with:
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
- 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: github-ubuntu-latest-l
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- 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@v1
with:
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 }}
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: github-ubuntu-latest-m
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- 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/config-maven@v1
with:
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
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 \
"-Dlicense.overrideUrl=file://${PWD}/override-dep-licenses.properties"
autoscan:
name: Autoscan Tests
needs:
- build
if: ${{ needs.build.outputs.deployed }}
runs-on: github-ubuntu-latest-m
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# For now, the autoscan job need to execute two mvn commands:
# * The build of java-checks-test-sources module which requires Java 24.
# * The tests using Orchestrator and SonarQube that, for now, fail to work using Java 24
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- 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;
development/github/token/licenses-ro token | GITHUB_TOKEN;
- uses: SonarSource/ci-github-actions/config-maven@v1
with:
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
- 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 test-compile --batch-mode
- name: Select Java 21
run: mise use java@21
- name: Run autoscan tests
env:
SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_HOST_URL }}
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SONAR_TOKEN }}
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
working-directory: its/autoscan
run: >
mvn clean package --batch-mode --errors --show-version
--activate-profiles it-autoscan
-Dsonar.runtimeVersion=LATEST_RELEASE
-Dmaven.test.redirectTestOutputToFile=false
-Dparallel=methods
-DuseUnlimitedThreads=true
- name: Upload Actual Results On Failure
if: failure()
uses: ./.github/actions/upload-actual
with:
name: autoscan
it-dir: its/autoscan
expected-dir: src/test/resources/autoscan/diffs
actual-dir: target/actual/autoscan-diffs
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: github-windows-latest-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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
with:
version: 2025.7.12
- name: Configure Maven
uses: SonarSource/ci-github-actions/config-maven@v1
with:
artifactory-reader-role: private-reader
use-develocity: ${{ env.USE_DEVELOCITY }}
develocity-url: ${{ env.DEVELOCITY_URL }}
- name: Run Maven
run: mvn clean verify --batch-mode
promote:
needs:
- build
- ruling-qa
- plugin-qa
- sanity
- test-analyze
- custom-rules-license-check
- autoscan
- qa-os-win
if: ${{ needs.build.outputs.deployed }}
runs-on: github-ubuntu-latest-s # Public repo uses custom GitHub-hosted runners
name: Promote
permissions:
id-token: write
contents: write
env:
BUILD_NUMBER: ${{ needs.build.outputs.build-number }}
steps:
- uses: SonarSource/ci-github-actions/promote@v1
with:
promote-pull-request: true