run_test_cases.yaml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. name: Run test case
  2. concurrency:
  3. group: test-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. workflow_call:
  7. inputs:
  8. builder:
  9. required: true
  10. type: string
  11. ct-matrix:
  12. required: true
  13. type: string
  14. ct-host:
  15. required: true
  16. type: string
  17. ct-docker:
  18. required: true
  19. type: string
  20. permissions:
  21. contents: read
  22. env:
  23. IS_CI: "yes"
  24. jobs:
  25. eunit_and_proper:
  26. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  27. name: "eunit_and_proper (${{ matrix.profile }})"
  28. strategy:
  29. fail-fast: false
  30. matrix:
  31. include: ${{ fromJson(inputs.ct-matrix) }}
  32. defaults:
  33. run:
  34. shell: bash
  35. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  36. steps:
  37. - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
  38. with:
  39. name: ${{ matrix.profile }}
  40. - name: extract artifact
  41. run: |
  42. unzip -o -q ${{ matrix.profile }}.zip
  43. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  44. # produces eunit.coverdata
  45. - name: eunit
  46. env:
  47. PROFILE: ${{ matrix.profile }}
  48. ENABLE_COVER_COMPILE: 1
  49. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  50. run: make eunit
  51. # produces proper.coverdata
  52. - name: proper
  53. env:
  54. PROFILE: ${{ matrix.profile }}
  55. ENABLE_COVER_COMPILE: 1
  56. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  57. run: make proper
  58. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  59. with:
  60. name: coverdata-${{ matrix.profile }}-${{ matrix.otp }}
  61. path: _build/test/cover
  62. retention-days: 7
  63. ct_docker:
  64. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  65. name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
  66. strategy:
  67. fail-fast: false
  68. matrix:
  69. include: ${{ fromJson(inputs.ct-docker) }}
  70. defaults:
  71. run:
  72. shell: bash
  73. steps:
  74. - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
  75. with:
  76. name: ${{ matrix.profile }}
  77. - name: extract artifact
  78. run: |
  79. unzip -o -q ${{ matrix.profile }}.zip
  80. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  81. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  82. - name: run common tests
  83. env:
  84. DOCKER_CT_RUNNER_IMAGE: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  85. MONGO_TAG: "5"
  86. MYSQL_TAG: "8"
  87. PGSQL_TAG: "13"
  88. REDIS_TAG: "7.0"
  89. INFLUXDB_TAG: "2.5.0"
  90. TDENGINE_TAG: "3.0.2.4"
  91. OPENTS_TAG: "9aa7f88"
  92. MINIO_TAG: "RELEASE.2023-03-20T20-16-18Z"
  93. PROFILE: ${{ matrix.profile }}
  94. SUITEGROUP: ${{ matrix.suitegroup }}
  95. ENABLE_COVER_COMPILE: 1
  96. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  97. run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }}
  98. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  99. with:
  100. name: coverdata-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  101. path: _build/test/cover
  102. retention-days: 7
  103. - name: compress logs
  104. if: failure()
  105. run: tar -czf logs.tar.gz _build/test/logs
  106. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  107. if: failure()
  108. with:
  109. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  110. path: logs.tar.gz
  111. compression-level: 0
  112. retention-days: 7
  113. ct:
  114. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  115. name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
  116. strategy:
  117. fail-fast: false
  118. matrix:
  119. include: ${{ fromJson(inputs.ct-host) }}
  120. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  121. defaults:
  122. run:
  123. shell: bash
  124. steps:
  125. - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
  126. with:
  127. name: ${{ matrix.profile }}
  128. - name: extract artifact
  129. run: |
  130. unzip -o -q ${{ matrix.profile }}.zip
  131. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  132. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  133. - name: run common tests
  134. env:
  135. PROFILE: ${{ matrix.profile }}
  136. SUITEGROUP: ${{ matrix.suitegroup }}
  137. ENABLE_COVER_COMPILE: 1
  138. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  139. run: |
  140. make "${{ matrix.app }}-ct"
  141. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  142. with:
  143. name: coverdata-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  144. path: _build/test/cover
  145. if-no-files-found: warn # do not fail if no coverdata found
  146. retention-days: 7
  147. - name: compress logs
  148. if: failure()
  149. run: tar -czf logs.tar.gz _build/test/logs
  150. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  151. if: failure()
  152. with:
  153. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  154. path: logs.tar.gz
  155. compression-level: 0
  156. retention-days: 7
  157. tests_passed:
  158. needs:
  159. - eunit_and_proper
  160. - ct
  161. - ct_docker
  162. runs-on: ubuntu-22.04
  163. strategy:
  164. fail-fast: false
  165. steps:
  166. - run: echo "All tests passed"
  167. make_cover:
  168. needs:
  169. - eunit_and_proper
  170. - ct
  171. - ct_docker
  172. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  173. container: ${{ inputs.builder }}
  174. strategy:
  175. fail-fast: false
  176. matrix:
  177. profile:
  178. - emqx-enterprise
  179. steps:
  180. - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
  181. with:
  182. name: ${{ matrix.profile }}
  183. - name: extract artifact
  184. run: |
  185. unzip -o -q ${{ matrix.profile }}.zip
  186. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  187. - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
  188. name: download coverdata
  189. with:
  190. pattern: coverdata-${{ matrix.profile }}-*
  191. path: _build/test/cover
  192. merge-multiple: true
  193. - name: make cover
  194. env:
  195. PROFILE: emqx-enterprise
  196. run: make cover
  197. - name: send to coveralls
  198. env:
  199. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  200. PROFILE: emqx-enterprise
  201. run: make coveralls
  202. - name: get coveralls logs
  203. if: failure()
  204. run: cat rebar3.crashdump
  205. # do this in a separate job
  206. upload_coverdata:
  207. needs: make_cover
  208. runs-on: ubuntu-22.04
  209. steps:
  210. - name: Coveralls Finished
  211. env:
  212. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  213. run: |
  214. curl -v -k https://coveralls.io/webhook \
  215. --header "Content-Type: application/json" \
  216. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true