build-common.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. name: Reusable - Common
  2. on:
  3. workflow_call:
  4. inputs:
  5. cache-read-only:
  6. type: boolean
  7. required: false
  8. no-build-cache:
  9. type: boolean
  10. required: false
  11. skip-openj9-tests:
  12. type: boolean
  13. required: false
  14. skip-windows-smoke-tests:
  15. type: boolean
  16. required: false
  17. secrets:
  18. GRADLE_ENTERPRISE_ACCESS_KEY:
  19. required: false
  20. permissions:
  21. contents: read
  22. jobs:
  23. spotless:
  24. runs-on: ubuntu-latest
  25. steps:
  26. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  27. - name: Free disk space
  28. run: .github/scripts/gha-free-disk-space.sh
  29. - name: Set up JDK for running Gradle
  30. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  31. with:
  32. distribution: temurin
  33. java-version: 17.0.6
  34. - name: Spotless
  35. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  36. env:
  37. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  38. with:
  39. arguments: spotlessCheck ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
  40. cache-read-only: ${{ inputs.cache-read-only }}
  41. # gradle enterprise is used for the build cache
  42. gradle-home-cache-excludes: caches/build-cache-1
  43. gradle-wrapper-validation:
  44. runs-on: ubuntu-latest
  45. steps:
  46. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  47. - uses: gradle/wrapper-validation-action@b5418f5a58f5fd2eb486dd7efb368fe7be7eae45 # v2.1.3
  48. license-check:
  49. runs-on: ubuntu-latest
  50. steps:
  51. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  52. - name: Free disk space
  53. run: .github/scripts/gha-free-disk-space.sh
  54. - name: Set up JDK for running Gradle
  55. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  56. with:
  57. distribution: temurin
  58. java-version: 17.0.6
  59. - name: Generate license report
  60. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  61. env:
  62. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  63. with:
  64. # currently ignoring inputs.no-build-cache and always running with --no-build-cache
  65. # see https://github.com/jk1/Gradle-License-Report/issues/231
  66. arguments: generateLicenseReport --no-build-cache
  67. cache-read-only: ${{ inputs.cache-read-only }}
  68. # gradle enterprise is used for the build cache
  69. gradle-home-cache-excludes: caches/build-cache-1
  70. - name: Check licenses
  71. run: |
  72. # add any untracked folders that may have been added by generateLicenseReport
  73. git add licenses
  74. # there's always going to one line difference due to the timestamp included in the report
  75. if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]]
  76. then
  77. echo "Licenses are up-to-date."
  78. else
  79. echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport' locally and commit."
  80. echo
  81. echo "$(git diff --cached --stat licenses)"
  82. echo
  83. echo "$(git diff --cached licenses)"
  84. exit 1
  85. fi
  86. # this is needed because we don't auto-update dependencies in instrumentation/**
  87. # and so we want to enforce that all "real" dependencies are dependency managed
  88. extra-dependency-management-enforcement:
  89. runs-on: ubuntu-latest
  90. steps:
  91. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  92. - name: Dependency check
  93. run: |
  94. set +e
  95. grep '^ implementation(".*:.*:[0-9].*")\|^ api(".*:.*:[0-9].*")' \
  96. --include=\*.kts \
  97. -r instrumentation \
  98. | grep -v testing/build.gradle.kts \
  99. | grep -v com.azure:azure-core-tracing-opentelemetry \
  100. | grep -v com.couchbase.client:tracing-opentelemetry \
  101. > dependencies.txt
  102. if [ -s dependencies.txt ]; then
  103. echo unmanaged dependencies found
  104. echo
  105. cat dependencies.txt
  106. exit 1
  107. fi
  108. build:
  109. runs-on: ubuntu-latest
  110. steps:
  111. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  112. - name: Free disk space
  113. run: .github/scripts/gha-free-disk-space.sh
  114. - name: Set up JDK for running Gradle
  115. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  116. with:
  117. distribution: temurin
  118. java-version: 17.0.6
  119. - name: Increase gradle daemon heap size
  120. run: |
  121. sed -i "s/org.gradle.jvmargs=/org.gradle.jvmargs=-Xmx3g /" gradle.properties
  122. - name: Build
  123. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  124. env:
  125. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  126. with:
  127. # javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
  128. arguments: check -x javadoc -x spotlessCheck -PskipTests=true ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
  129. cache-read-only: ${{ inputs.cache-read-only }}
  130. # gradle enterprise is used for the build cache
  131. gradle-home-cache-excludes: caches/build-cache-1
  132. - name: Check for jApiCmp diffs
  133. run: |
  134. # need to "git add" in case any generated files did not already exist
  135. git add docs/apidiffs
  136. if git diff --cached --quiet
  137. then
  138. echo "No diff detected."
  139. else
  140. echo "Diff detected - did you run './gradlew jApiCmp'?"
  141. echo $(git diff --cached --name-only)
  142. echo $(git diff --cached)
  143. exit 1
  144. fi
  145. - name: Upload agent jar
  146. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  147. with:
  148. name: opentelemetry-javaagent
  149. path: javaagent/build/libs/opentelemetry-javaagent-*-SNAPSHOT.jar
  150. if-no-files-found: ignore
  151. test:
  152. name: test${{ matrix.test-partition }} (${{ matrix.test-java-version }}, ${{ matrix.vm }})
  153. runs-on: ubuntu-latest
  154. strategy:
  155. matrix:
  156. test-java-version:
  157. - 8
  158. - 11
  159. - 17
  160. - 21
  161. vm:
  162. - hotspot
  163. - openj9
  164. test-partition:
  165. - 0
  166. - 1
  167. - 2
  168. - 3
  169. exclude:
  170. - vm: ${{ inputs.skip-openj9-tests && 'openj9' || '' }}
  171. - test-java-version: 21
  172. vm: openj9
  173. fail-fast: false
  174. steps:
  175. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  176. - name: Free disk space
  177. run: .github/scripts/gha-free-disk-space.sh
  178. - id: setup-test-java
  179. name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
  180. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  181. with:
  182. # using zulu because new releases get published quickly
  183. distribution: ${{ matrix.vm == 'hotspot' && 'zulu' || 'adopt-openj9'}}
  184. java-version: ${{ matrix.test-java-version }}
  185. - name: Set up JDK for running Gradle
  186. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  187. with:
  188. distribution: temurin
  189. java-version: 17.0.6
  190. # vaadin 14 tests fail with node 18
  191. - name: Set up Node
  192. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
  193. with:
  194. node-version: 16
  195. # vaadin tests use pnpm
  196. - name: Cache pnpm modules
  197. uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
  198. with:
  199. path: ~/.pnpm-store
  200. key: ${{ runner.os }}-test-cache-pnpm-modules
  201. - name: Start deadlock detector
  202. run: .github/scripts/deadlock-detector.sh
  203. - name: List tests
  204. env:
  205. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  206. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  207. with:
  208. # "check" is needed to activate all tests for listing purposes
  209. # listTestsInPartition writes test tasks that apply to the given partition to a file named
  210. # "test-tasks.txt" and then disables all tasks (including tests) after it runs
  211. arguments: >
  212. check -x spotlessCheck
  213. listTestsInPartition
  214. -PtestPartition=${{ matrix.test-partition }}
  215. cache-read-only: true
  216. - name: Set test tasks
  217. run: |
  218. echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
  219. - name: Test
  220. env:
  221. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  222. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  223. with:
  224. # spotless is checked separately since it's a common source of failure
  225. arguments: >
  226. ${{ env.test-tasks }}
  227. -PtestJavaVersion=${{ matrix.test-java-version }}
  228. -PtestJavaVM=${{ matrix.vm }}
  229. -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
  230. -Porg.gradle.java.installations.auto-download=false
  231. ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  232. # only push cache for one matrix option since github action cache space is limited
  233. cache-read-only: ${{ inputs.cache-read-only || matrix.test-java-version != 11 || matrix.vm != 'hotspot' }}
  234. # gradle enterprise is used for the build cache
  235. gradle-home-cache-excludes: caches/build-cache-1
  236. - name: Build scan
  237. if: ${{ !cancelled() && hashFiles('build-scan.txt') != '' }}
  238. run: cat build-scan.txt
  239. - name: Upload deadlock detector artifacts if any
  240. if: failure()
  241. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  242. with:
  243. name: deadlock-detector-test-${{ matrix.test-java-version }}-${{ matrix.vm }}-${{ matrix.test-partition }}
  244. path: /tmp/deadlock-detector-*
  245. if-no-files-found: ignore
  246. - name: Upload jvm crash dump files if any
  247. if: failure()
  248. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  249. with:
  250. name: javacore-test-${{ matrix.test-java-version }}-${{ matrix.test-partition }}
  251. path: |
  252. **/hs_err_pid*.log
  253. **/javacore.*.txt
  254. **/Snap.*.trc
  255. **/core.*.dmp
  256. **/jitdump.*.dmp
  257. if-no-files-found: ignore
  258. smoke-test:
  259. runs-on: ${{ matrix.os }}
  260. strategy:
  261. matrix:
  262. os:
  263. - windows-latest
  264. - ubuntu-latest
  265. smoke-test-suite:
  266. - jetty
  267. - liberty
  268. - payara
  269. - tomcat
  270. - tomee
  271. - websphere
  272. - wildfly
  273. - other
  274. exclude:
  275. - os: ${{ inputs.skip-windows-smoke-tests && 'windows-latest' || '' }}
  276. - os: windows-latest
  277. smoke-test-suite: websphere
  278. fail-fast: false
  279. steps:
  280. - name: Support long paths
  281. run: git config --system core.longpaths true
  282. if: matrix.os == 'windows-latest'
  283. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  284. - name: Free disk space
  285. run: .github/scripts/gha-free-disk-space.sh
  286. - name: Set up JDK for running Gradle
  287. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  288. with:
  289. distribution: temurin
  290. java-version: 17.0.6
  291. - name: Set up Gradle cache
  292. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  293. with:
  294. # only push cache for one matrix option per OS since github action cache space is limited
  295. cache-read-only: ${{ inputs.cache-read-only || matrix.smoke-test-suite != 'tomcat' }}
  296. # gradle enterprise is used for the build cache
  297. gradle-home-cache-excludes: caches/build-cache-1
  298. - name: Build
  299. env:
  300. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  301. # running suite "none" compiles everything needed by smoke tests without executing any tests
  302. run: ./gradlew :smoke-tests:test -PsmokeTestSuite=none --no-daemon ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  303. - name: Test
  304. env:
  305. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  306. run: ./gradlew :smoke-tests:test -PsmokeTestSuite=${{ matrix.smoke-test-suite }}${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  307. - name: Upload jvm crash dump files if any
  308. if: failure()
  309. uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  310. with:
  311. name: javacore-smoke-test-${{ matrix.smoke-test-suite }}-${{ matrix.os }}
  312. # we expect crash dumps either in root director or in smoke-tests
  313. # not using **/ here because actions/upload-artifact fails with long paths https://github.com/actions/upload-artifact/issues/309
  314. path: |
  315. hs_err_pid*.log
  316. smoke-tests/hs_err_pid*.log
  317. javacore.*.txt
  318. smoke-tests/javacore.*.txt
  319. Snap.*.trc
  320. smoke-tests/Snap.*.trc
  321. core.*.dmp
  322. smoke-tests/core.*.dmp
  323. jitdump.*.dmp
  324. smoke-tests/jitdump.*.dmp
  325. if-no-files-found: ignore
  326. gradle-plugins:
  327. runs-on: ubuntu-latest
  328. steps:
  329. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  330. - name: Free disk space
  331. run: .github/scripts/gha-free-disk-space.sh
  332. - name: Set up JDK for running Gradle
  333. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  334. with:
  335. distribution: temurin
  336. java-version: 17.0.6
  337. - name: Build
  338. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  339. with:
  340. arguments: build ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
  341. build-root-directory: gradle-plugins
  342. cache-read-only: ${{ inputs.cache-read-only }}
  343. examples:
  344. runs-on: ubuntu-latest
  345. steps:
  346. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  347. - name: Free disk space
  348. run: .github/scripts/gha-free-disk-space.sh
  349. - name: Set up JDK for running Gradle
  350. uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
  351. with:
  352. distribution: temurin
  353. java-version: 17.0.6
  354. - name: Set up Gradle cache
  355. uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0
  356. with:
  357. cache-read-only: ${{ inputs.cache-read-only }}
  358. - name: Local publish of artifacts
  359. # javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
  360. run: ./gradlew publishToMavenLocal -x javadoc
  361. - name: Local publish of gradle plugins
  362. # javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
  363. run: ./gradlew publishToMavenLocal -x javadoc
  364. working-directory: gradle-plugins
  365. - name: Build distro
  366. run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  367. working-directory: examples/distro
  368. - name: Build extension
  369. run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  370. working-directory: examples/extension
  371. - name: Run muzzle check against extension
  372. run: ./gradlew muzzle --init-script ../../.github/scripts/local.init.gradle.kts
  373. working-directory: examples/extension