build-common.yml 16 KB

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