build-common.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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@v3
  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@v3
  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@v3
  51. - uses: gradle/wrapper-validation-action@v1.1.0
  52. license-check:
  53. runs-on: ubuntu-latest
  54. steps:
  55. - uses: actions/checkout@v3
  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@v3
  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@v3
  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@v3
  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@v3
  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. test:
  154. name: test${{ matrix.test-partition }} (${{ matrix.test-java-version }}, ${{ matrix.vm }})
  155. runs-on: ubuntu-latest
  156. strategy:
  157. matrix:
  158. test-java-version:
  159. - 8
  160. - 11
  161. - 17
  162. - 20
  163. vm:
  164. - hotspot
  165. - openj9
  166. test-partition:
  167. - 0
  168. - 1
  169. - 2
  170. - 3
  171. exclude:
  172. - vm: ${{ inputs.skip-openj9-tests && 'openj9' || '' }}
  173. - test-java-version: 20
  174. vm: openj9
  175. fail-fast: false
  176. steps:
  177. - uses: actions/checkout@v3
  178. - name: Free disk space
  179. run: .github/scripts/gha-free-disk-space.sh
  180. - id: setup-test-java
  181. name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
  182. uses: actions/setup-java@v3
  183. with:
  184. # using zulu because new releases get published quickly
  185. distribution: ${{ matrix.vm == 'hotspot' && 'zulu' || 'adopt-openj9'}}
  186. java-version: ${{ matrix.test-java-version }}
  187. - name: Set up JDK for running Gradle
  188. uses: actions/setup-java@v3
  189. with:
  190. distribution: temurin
  191. java-version: 17.0.6
  192. # vaadin 14 tests fail with node 18
  193. - name: Set up Node
  194. uses: actions/setup-node@v3
  195. with:
  196. node-version: 16
  197. # vaadin tests use pnpm
  198. - name: Cache pnpm modules
  199. uses: actions/cache@v3
  200. with:
  201. path: ~/.pnpm-store
  202. key: ${{ runner.os }}-test-cache-pnpm-modules
  203. - name: Increase gradle daemon heap size
  204. run: |
  205. sed -i "s/org.gradle.jvmargs=/org.gradle.jvmargs=-Xmx3g /" gradle.properties
  206. - name: Start deadlock detector
  207. run: .github/scripts/deadlock-detector.sh
  208. - name: List tests
  209. env:
  210. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  211. GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
  212. GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
  213. uses: gradle/gradle-build-action@v2
  214. with:
  215. # "check" is needed to activate all tests for listing purposes
  216. # listTestsInPartition writes test tasks that apply to the given partition to a file named
  217. # "test-tasks.txt" and then disables all tasks (including tests) after it runs
  218. arguments: >
  219. check -x spotlessCheck
  220. listTestsInPartition
  221. -PtestPartition=${{ matrix.test-partition }}
  222. cache-read-only: true
  223. - name: Set test tasks
  224. run: |
  225. echo "test-tasks=$(cat test-tasks.txt | xargs echo | sed 's/\n/ /g')" >> $GITHUB_ENV
  226. - name: Test
  227. env:
  228. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  229. GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
  230. GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
  231. uses: gradle/gradle-build-action@v2
  232. with:
  233. # spotless is checked separately since it's a common source of failure
  234. arguments: >
  235. ${{ env.test-tasks }}
  236. -PtestJavaVersion=${{ matrix.test-java-version }}
  237. -PtestJavaVM=${{ matrix.vm }}
  238. -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
  239. -Porg.gradle.java.installations.auto-download=false
  240. ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  241. # only push cache for one matrix option since github action cache space is limited
  242. cache-read-only: ${{ inputs.cache-read-only || matrix.test-java-version != 11 || matrix.vm != 'hotspot' }}
  243. # gradle enterprise is used for the build cache
  244. gradle-home-cache-excludes: caches/build-cache-1
  245. - name: Upload deadlock detector artifacts if any
  246. if: failure()
  247. uses: actions/upload-artifact@v3
  248. with:
  249. name: deadlock-detector-test-${{ matrix.test-java-version }}-${{ matrix.vm }}-${{ matrix.test-partition }}
  250. path: /tmp/deadlock-detector-*
  251. if-no-files-found: ignore
  252. - name: Upload jvm crash dump files if any
  253. if: failure()
  254. uses: actions/upload-artifact@v3
  255. with:
  256. name: javacore-test-${{ matrix.test-java-version }}-${{ matrix.test-partition }}
  257. path: |
  258. **/hs_err_pid*.log
  259. **/javacore.*.txt
  260. **/Snap.*.trc
  261. **/core.*.dmp
  262. **/jitdump.*.dmp
  263. if-no-files-found: ignore
  264. smoke-test:
  265. runs-on: ${{ matrix.os }}
  266. strategy:
  267. matrix:
  268. os:
  269. - windows-latest
  270. - ubuntu-latest
  271. smoke-test-suite:
  272. - jetty
  273. - liberty
  274. - payara
  275. - tomcat
  276. - tomee
  277. - websphere
  278. - wildfly
  279. - other
  280. exclude:
  281. - os: ${{ inputs.skip-windows-smoke-tests && 'windows-latest' || '' }}
  282. - os: windows-latest
  283. smoke-test-suite: websphere
  284. fail-fast: false
  285. steps:
  286. - name: Support long paths
  287. run: git config --system core.longpaths true
  288. if: matrix.os == 'windows-latest'
  289. - uses: actions/checkout@v3
  290. - name: Free disk space
  291. run: .github/scripts/gha-free-disk-space.sh
  292. - name: Set up JDK for running Gradle
  293. uses: actions/setup-java@v3
  294. with:
  295. distribution: temurin
  296. java-version: 17.0.6
  297. - name: Set up Gradle cache
  298. uses: gradle/gradle-build-action@v2
  299. with:
  300. # only push cache for one matrix option per OS since github action cache space is limited
  301. cache-read-only: ${{ inputs.cache-read-only || matrix.smoke-test-suite != 'tomcat' }}
  302. # gradle enterprise is used for the build cache
  303. gradle-home-cache-excludes: caches/build-cache-1
  304. - name: Build
  305. env:
  306. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  307. GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
  308. GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
  309. # running suite "none" compiles everything needed by smoke tests without executing any tests
  310. run: ./gradlew :smoke-tests:test -PsmokeTestSuite=none --no-daemon ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  311. - name: Test
  312. env:
  313. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
  314. GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
  315. GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
  316. run: ./gradlew :smoke-tests:test -PsmokeTestSuite=${{ matrix.smoke-test-suite }}${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  317. - name: Upload jvm crash dump files if any
  318. if: failure()
  319. uses: actions/upload-artifact@v3
  320. with:
  321. name: javacore-smoke-test-${{ matrix.smoke-test-suite }}-${{ matrix.os }}
  322. # we expect crash dumps either in root director or in smoke-tests
  323. # not using **/ here because actions/upload-artifact fails with long paths https://github.com/actions/upload-artifact/issues/309
  324. path: |
  325. hs_err_pid*.log
  326. smoke-tests/hs_err_pid*.log
  327. javacore.*.txt
  328. smoke-tests/javacore.*.txt
  329. Snap.*.trc
  330. smoke-tests/Snap.*.trc
  331. core.*.dmp
  332. smoke-tests/core.*.dmp
  333. jitdump.*.dmp
  334. smoke-tests/jitdump.*.dmp
  335. if-no-files-found: ignore
  336. gradle-plugins:
  337. runs-on: ubuntu-latest
  338. steps:
  339. - uses: actions/checkout@v3
  340. - name: Free disk space
  341. run: .github/scripts/gha-free-disk-space.sh
  342. - name: Set up JDK for running Gradle
  343. uses: actions/setup-java@v3
  344. with:
  345. distribution: temurin
  346. java-version: 17.0.6
  347. - name: Build
  348. uses: gradle/gradle-build-action@v2
  349. with:
  350. arguments: build ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
  351. build-root-directory: gradle-plugins
  352. cache-read-only: ${{ inputs.cache-read-only }}
  353. examples:
  354. runs-on: ubuntu-latest
  355. steps:
  356. - uses: actions/checkout@v3
  357. - name: Free disk space
  358. run: .github/scripts/gha-free-disk-space.sh
  359. - name: Set up JDK for running Gradle
  360. uses: actions/setup-java@v3
  361. with:
  362. distribution: temurin
  363. java-version: 17.0.6
  364. - name: Set up Gradle cache
  365. uses: gradle/gradle-build-action@v2
  366. with:
  367. cache-read-only: ${{ inputs.cache-read-only }}
  368. - name: Local publish of artifacts
  369. # javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
  370. run: ./gradlew publishToMavenLocal -x javadoc
  371. - name: Local publish of gradle plugins
  372. # javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
  373. run: ./gradlew publishToMavenLocal -x javadoc
  374. working-directory: gradle-plugins
  375. - name: Build distro
  376. run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  377. working-directory: examples/distro
  378. - name: Build extension
  379. run: ./gradlew build --init-script ../../.github/scripts/local.init.gradle.kts${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
  380. working-directory: examples/extension
  381. - name: Run muzzle check against extension
  382. run: ./gradlew muzzle --init-script ../../.github/scripts/local.init.gradle.kts
  383. working-directory: examples/extension