build-common.yml 15 KB

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