run_test_cases.yaml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. runner_labels:
  9. required: true
  10. type: string
  11. builder:
  12. required: true
  13. type: string
  14. ct-matrix:
  15. required: true
  16. type: string
  17. ct-host:
  18. required: true
  19. type: string
  20. ct-docker:
  21. required: true
  22. type: string
  23. env:
  24. IS_CI: "yes"
  25. jobs:
  26. eunit_and_proper:
  27. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  28. name: "eunit_and_proper (${{ matrix.profile }})"
  29. strategy:
  30. fail-fast: false
  31. matrix:
  32. include: ${{ fromJson(inputs.ct-matrix) }}
  33. defaults:
  34. run:
  35. shell: bash
  36. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  37. steps:
  38. - uses: actions/download-artifact@v3
  39. with:
  40. name: ${{ matrix.profile }}
  41. - name: extract artifact
  42. run: |
  43. unzip -o -q ${{ matrix.profile }}.zip
  44. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  45. # produces eunit.coverdata
  46. - name: eunit
  47. env:
  48. PROFILE: ${{ matrix.profile }}
  49. ENABLE_COVER_COMPILE: 1
  50. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  51. run: make eunit
  52. # produces proper.coverdata
  53. - name: proper
  54. env:
  55. PROFILE: ${{ matrix.profile }}
  56. ENABLE_COVER_COMPILE: 1
  57. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  58. run: make proper
  59. - uses: actions/upload-artifact@v3
  60. with:
  61. name: coverdata
  62. path: _build/test/cover
  63. ct_docker:
  64. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  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@v3
  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@v3
  99. with:
  100. name: coverdata
  101. path: _build/test/cover
  102. - name: compress logs
  103. if: failure()
  104. run: tar -czf logs.tar.gz _build/test/logs
  105. - uses: actions/upload-artifact@v3
  106. if: failure()
  107. with:
  108. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  109. path: logs.tar.gz
  110. ct:
  111. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  112. name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
  113. strategy:
  114. fail-fast: false
  115. matrix:
  116. include: ${{ fromJson(inputs.ct-host) }}
  117. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  118. defaults:
  119. run:
  120. shell: bash
  121. steps:
  122. - uses: actions/download-artifact@v3
  123. with:
  124. name: ${{ matrix.profile }}
  125. - name: extract artifact
  126. run: |
  127. unzip -o -q ${{ matrix.profile }}.zip
  128. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  129. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  130. - name: run common tests
  131. env:
  132. PROFILE: ${{ matrix.profile }}
  133. SUITEGROUP: ${{ matrix.suitegroup }}
  134. ENABLE_COVER_COMPILE: 1
  135. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  136. run: |
  137. make "${{ matrix.app }}-ct"
  138. - uses: actions/upload-artifact@v3
  139. with:
  140. name: coverdata
  141. path: _build/test/cover
  142. if-no-files-found: warn # do not fail if no coverdata found
  143. - name: compress logs
  144. if: failure()
  145. run: tar -czf logs.tar.gz _build/test/logs
  146. - uses: actions/upload-artifact@v3
  147. if: failure()
  148. with:
  149. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  150. path: logs.tar.gz
  151. tests_passed:
  152. needs:
  153. - eunit_and_proper
  154. - ct
  155. - ct_docker
  156. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  157. strategy:
  158. fail-fast: false
  159. steps:
  160. - run: echo "All tests passed"
  161. make_cover:
  162. needs:
  163. - eunit_and_proper
  164. - ct
  165. - ct_docker
  166. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  167. container: ${{ inputs.builder }}
  168. strategy:
  169. fail-fast: false
  170. matrix:
  171. profile:
  172. - emqx-enterprise
  173. steps:
  174. - uses: actions/download-artifact@v3
  175. with:
  176. name: ${{ matrix.profile }}
  177. - name: extract artifact
  178. run: |
  179. unzip -o -q ${{ matrix.profile }}.zip
  180. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  181. - uses: actions/download-artifact@v3
  182. name: download coverdata
  183. with:
  184. name: coverdata
  185. path: _build/test/cover
  186. - name: make cover
  187. env:
  188. PROFILE: emqx-enterprise
  189. run: make cover
  190. - name: send to coveralls
  191. env:
  192. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  193. PROFILE: emqx-enterprise
  194. run: make coveralls
  195. - name: get coveralls logs
  196. if: failure()
  197. run: cat rebar3.crashdump
  198. # do this in a separate job
  199. upload_coverdata:
  200. needs: make_cover
  201. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  202. steps:
  203. - name: Coveralls Finished
  204. env:
  205. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  206. run: |
  207. curl -v -k https://coveralls.io/webhook \
  208. --header "Content-Type: application/json" \
  209. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true