-
Notifications
You must be signed in to change notification settings - Fork 919
526 lines (448 loc) · 18.4 KB
/
build-common.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
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
name: Reusable - Common
on:
workflow_call:
inputs:
cache-read-only:
type: boolean
required: false
no-build-cache:
type: boolean
required: false
max-test-retries:
type: string
required: false
skip-openj9-tests:
type: boolean
required: false
skip-windows-smoke-tests:
type: boolean
required: false
secrets:
FLAKY_TEST_REPORTER_ACCESS_KEY:
required: false
permissions:
contents: read
jobs:
spotless:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Spotless
run: ./gradlew spotlessCheck ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Generate license report
# with the build cache enabled occasionally produces outdated results
run: ./gradlew generateLicenseReport --no-build-cache
- name: Check licenses
run: |
# add any untracked folders that may have been added by generateLicenseReport
git add licenses
if [[ $(git diff --cached --shortstat licenses) == "" ]]
then
echo "Licenses are up-to-date."
else
echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport --no-build-cache' locally and commit."
echo
git diff --cached --stat licenses
echo
git diff --cached licenses
exit 1
fi
fossa-configuration-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Generate FOSSA configuration
run: ./gradlew generateFossaConfiguration
- name: Check configuration
run: |
git add .fossa.yml
if [[ $(git diff --cached --shortstat .fossa.yml) == "" ]]
then
echo "FOSSA configuration is up-to-date."
else
echo "FOSSA configuration is not up-to-date, please run './gradlew generateFossaConfiguration' locally and commit."
echo
git diff --cached --stat .fossa.yml
echo
git diff --cached .fossa.yml
exit 1
fi
# this is needed because we don't auto-update dependencies in instrumentation/**
# and so we want to enforce that all "real" dependencies are dependency managed
extra-dependency-management-enforcement:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Dependency check
run: |
set +e
grep '^ implementation(".*:.*:[0-9].*")\|^ api(".*:.*:[0-9].*")' \
--include=\*.kts \
-r instrumentation \
| grep -v testing/build.gradle.kts \
| grep -v com.azure:azure-core-tracing-opentelemetry \
| grep -v com.couchbase.client:tracing-opentelemetry \
> dependencies.txt
if [ -s dependencies.txt ]; then
echo unmanaged dependencies found
echo
cat dependencies.txt
exit 1
fi
check-javaagent-suppression-keys:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: .github/scripts/check-javaagent-suppression-keys.sh
check-latest-dep-test-overrides:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: .github/scripts/check-latest-dep-test-overrides.sh
check-package-names:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: .github/scripts/check-package-names.sh
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Increase gradle daemon heap size
run: |
sed -i "s/org.gradle.jvmargs=/org.gradle.jvmargs=-Xmx3g /" gradle.properties
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Build
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: ./gradlew check spdxSbom -x javadoc -x spotlessCheck -PskipTests=true ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
- name: Check for jApiCmp diffs
run: |
# need to "git add" in case any generated files did not already exist
git add docs/apidiffs
if git diff --cached --quiet
then
echo "No diff detected."
else
echo "Diff detected - did you run './gradlew jApiCmp'?"
git diff --cached --name-only
git diff --cached
exit 1
fi
- name: Upload agent jar
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: opentelemetry-javaagent.jar
path: javaagent/build/libs/opentelemetry-javaagent-*-SNAPSHOT.jar
if-no-files-found: ignore
- name: Collect SBOMs
run: |
mkdir sboms
cp javaagent/build/spdx/*.spdx.json sboms
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
name: Upload SBOMs
with:
name: opentelemetry-java-instrumentation-SBOM.zip
path: "sboms/*.json"
test:
name: test${{ matrix.test-partition }} (${{ matrix.test-java-version }}, ${{ matrix.vm }}, indy ${{ matrix.test-indy }})
runs-on: ubuntu-latest
strategy:
matrix:
test-java-version:
- 8
- 11
- 17
- 21
- 23
- 24-ea
vm:
- hotspot
- openj9
test-partition:
- 0
- 1
- 2
- 3
test-indy:
- false
- true
exclude:
- vm: ${{ inputs.skip-openj9-tests && 'openj9' || '' }}
- test-java-version: 24-ea
vm: openj9
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- id: setup-test-java
name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
# using zulu because new releases get published quickly
distribution: ${{ matrix.vm == 'hotspot' && 'zulu' || 'adopt-openj9'}}
java-version: ${{ matrix.test-java-version }}
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
# vaadin 14 tests fail with node 18
- name: Set up Node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 16
# vaadin tests use pnpm
- name: Cache pnpm modules
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-test-cache-pnpm-modules
- name: Start deadlock detector
run: .github/scripts/deadlock-detector.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
# only push cache for one matrix option since github action cache space is limited
cache-read-only: ${{ inputs.cache-read-only || matrix.test-java-version != 11 || matrix.vm != 'hotspot' }}
- name: List tests
# "check" is needed to activate all tests for listing purposes
# listTestsInPartition writes test tasks that apply to the given partition to a file named
# "test-tasks.txt" and then disables all tasks (including tests) after it runs
run: >
./gradlew
check -x spotlessCheck
listTestsInPartition
-PtestPartition=${{ matrix.test-partition }}
- name: Set test tasks
run: |
echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
- name: Test
# spotless is checked separately since it's a common source of failure
run: >
./gradlew
${{ env.test-tasks }}
-PtestJavaVersion=${{ matrix.test-java-version }}
-PtestJavaVM=${{ matrix.vm }}
-PtestIndy=${{ matrix.test-indy }}
-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
-Porg.gradle.java.installations.auto-download=false
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
- name: Build scan
if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
run: cat build-scan.txt
- name: Get current job url
id: jobs
if: ${{ !cancelled() }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
matrix: ${{ toJson(matrix) }}
with:
result-encoding: string
script: |
const matrix = JSON.parse(process.env.matrix);
const job_name = `common / test${ matrix['test-partition'] } (${ matrix['test-java-version'] }, ${ matrix.vm }, indy ${ matrix['test-indy'] })`;
const workflow_jobs_nested = await github.paginate(
github.rest.actions.listJobsForWorkflowRun,
{
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
per_page: 100
},
(response) => {
return response.data;
},
);
return workflow_jobs_nested.flat().find((job) => job.name === job_name).html_url;
- name: Flaky test report
if: ${{ !cancelled() }}
env:
FLAKY_TEST_REPORTER_ACCESS_KEY: ${{ secrets.FLAKY_TEST_REPORTER_ACCESS_KEY }}
JOB_URL: ${{ steps.jobs.outputs.result }}
run: |
if [ -s build-scan.txt ]; then
export BUILD_SCAN_URL=$(cat build-scan.txt)
fi
./gradlew :test-report:reportFlakyTests
- name: Upload deadlock detector artifacts if any
if: failure()
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: deadlock-detector-test-${{ matrix.test-java-version }}-${{ matrix.vm }}-${{ matrix.test-partition }}-indy-${{ matrix.test-indy }}
path: /tmp/deadlock-detector-*
if-no-files-found: ignore
- name: Upload jvm crash dump files if any
if: failure()
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: javacore-test-${{ matrix.test-java-version }}-${{ matrix.test-partition }}
path: |
**/hs_err_pid*.log
**/javacore.*.txt
**/Snap.*.trc
**/core.*.dmp
**/jitdump.*.dmp
if-no-files-found: ignore
smoke-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
smoke-test-suite:
- jetty
- liberty
- payara
- tomcat
- tomee
- websphere
- wildfly
- other
exclude:
- os: ${{ inputs.skip-windows-smoke-tests && 'windows-latest' || '' }}
- os: windows-latest
smoke-test-suite: websphere
fail-fast: false
steps:
- name: Support long paths
run: git config --system core.longpaths true
if: matrix.os == 'windows-latest'
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Set up Gradle cache
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
# only push cache for one matrix option per OS since github action cache space is limited
cache-read-only: ${{ inputs.cache-read-only || matrix.smoke-test-suite != 'tomcat' }}
- name: Build
# running suite "none" compiles everything needed by smoke tests without executing any tests
# --no-daemon is used to free up the memory from the build step before running the test step below
run: ./gradlew :smoke-tests:test -PsmokeTestSuite=none --no-daemon ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
- name: Test
run: ./gradlew :smoke-tests:test -PsmokeTestSuite=${{ matrix.smoke-test-suite }} ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
- name: Upload jvm crash dump files if any
if: failure()
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: javacore-smoke-test-${{ matrix.smoke-test-suite }}-${{ matrix.os }}
# we expect crash dumps either in root director or in smoke-tests
# not using **/ here because actions/upload-artifact fails with long paths https://github.com/actions/upload-artifact/issues/309
path: |
hs_err_pid*.log
smoke-tests/hs_err_pid*.log
javacore.*.txt
smoke-tests/javacore.*.txt
Snap.*.trc
smoke-tests/Snap.*.trc
core.*.dmp
smoke-tests/core.*.dmp
jitdump.*.dmp
smoke-tests/jitdump.*.dmp
if-no-files-found: ignore
gradle-plugins:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Build
run: ./gradlew build ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
working-directory: gradle-plugins
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: temurin
java-version-file: .java-version
- name: Set up Gradle cache
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Local publish of artifacts
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: ./gradlew publishToMavenLocal -x javadoc
- name: Local publish of gradle plugins
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: ./gradlew publishToMavenLocal -x javadoc
working-directory: gradle-plugins
- name: Build distro
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
working-directory: examples/distro
- name: Build extension
run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
working-directory: examples/extension
- name: Build benchmark-overhead
run: ./gradlew assemble ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
working-directory: benchmark-overhead
- name: Run muzzle check against extension
run: ./gradlew muzzle --init-script ../../.github/scripts/local.init.gradle.kts
working-directory: examples/extension