run_test_cases.yaml 7.0 KB

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