build-common.yml 17 KB

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