run_test_cases.yaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. name: Run test case
  2. concurrency:
  3. group: test-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. push:
  7. branches:
  8. - '**'
  9. tags:
  10. - v*
  11. - e*
  12. pull_request:
  13. jobs:
  14. build-matrix:
  15. runs-on: ubuntu-latest
  16. outputs:
  17. prepare: ${{ steps.matrix.outputs.prepare }}
  18. host: ${{ steps.matrix.outputs.host }}
  19. docker: ${{ steps.matrix.outputs.docker }}
  20. runs-on: ${{ steps.runner.outputs.runs-on }}
  21. steps:
  22. - uses: actions/checkout@v3
  23. - name: Build matrix
  24. id: matrix
  25. run: |
  26. APPS="$(./scripts/find-apps.sh --ci)"
  27. MATRIX="$(echo "${APPS}" | jq -c '
  28. [
  29. (.[] | select(.profile == "emqx") | . + {
  30. builder: "5.0-28",
  31. otp: "25.1.2-2",
  32. elixir: "1.13.4"
  33. }),
  34. (.[] | select(.profile == "emqx-enterprise") | . + {
  35. builder: "5.0-28",
  36. otp: ["24.3.4.2-2", "25.1.2-2"][],
  37. elixir: "1.13.4"
  38. })
  39. ]
  40. ')"
  41. echo "${MATRIX}" | jq
  42. MATRIX_PREPARE="$(echo "${MATRIX}" | jq -c 'map({profile, builder, otp, elixir}) | unique')"
  43. MATRIX_HOST="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "host"))')"
  44. MATRIX_DOCKER="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "docker"))')"
  45. echo "prepare=${MATRIX_PREPARE}" | tee -a $GITHUB_OUTPUT
  46. echo "host=${MATRIX_HOST}" | tee -a $GITHUB_OUTPUT
  47. echo "docker=${MATRIX_DOCKER}" | tee -a $GITHUB_OUTPUT
  48. - name: Choose runner host
  49. id: runner
  50. run: |
  51. RUNS_ON="ubuntu-20.04"
  52. ${{ github.repository_owner == 'emqx' }} && RUNS_ON="aws-amd64"
  53. echo "runs-on=${RUNS_ON}" | tee -a $GITHUB_OUTPUT
  54. prepare:
  55. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  56. needs: [build-matrix]
  57. strategy:
  58. fail-fast: false
  59. matrix:
  60. include: ${{ fromJson(needs.build-matrix.outputs.prepare) }}
  61. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  62. steps:
  63. - uses: AutoModality/action-clean@v1
  64. - uses: actions/checkout@v3
  65. with:
  66. path: source
  67. - name: get_all_deps
  68. working-directory: source
  69. env:
  70. PROFILE: ${{ matrix.profile }}
  71. #DIAGNOSTIC: 1
  72. run: |
  73. make ensure-rebar3
  74. # fetch all deps and compile
  75. make ${{ matrix.profile }}
  76. make static_checks
  77. make test-compile
  78. cd ..
  79. zip -ryq source.zip source/* source/.[^.]*
  80. - uses: actions/upload-artifact@v3
  81. with:
  82. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  83. path: source.zip
  84. eunit_and_proper:
  85. needs:
  86. - build-matrix
  87. - prepare
  88. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  89. strategy:
  90. fail-fast: false
  91. matrix:
  92. include: ${{ fromJson(needs.build-matrix.outputs.prepare) }}
  93. defaults:
  94. run:
  95. shell: bash
  96. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  97. steps:
  98. - uses: AutoModality/action-clean@v1
  99. - uses: actions/download-artifact@v3
  100. with:
  101. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  102. path: .
  103. - name: unzip source code
  104. run: unzip -o -q source.zip
  105. # produces eunit.coverdata
  106. - name: eunit
  107. env:
  108. PROFILE: ${{ matrix.profile }}
  109. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  110. working-directory: source
  111. run: make eunit
  112. # produces proper.coverdata
  113. - name: proper
  114. env:
  115. PROFILE: ${{ matrix.profile }}
  116. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  117. working-directory: source
  118. run: make proper
  119. - uses: actions/upload-artifact@v3
  120. with:
  121. name: coverdata
  122. path: source/_build/test/cover
  123. ct_docker:
  124. needs:
  125. - build-matrix
  126. - prepare
  127. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  128. strategy:
  129. fail-fast: false
  130. matrix:
  131. include: ${{ fromJson(needs.build-matrix.outputs.docker) }}
  132. defaults:
  133. run:
  134. shell: bash
  135. steps:
  136. - uses: AutoModality/action-clean@v1
  137. - uses: actions/download-artifact@v3
  138. with:
  139. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  140. path: .
  141. - name: unzip source code
  142. run: unzip -q source.zip
  143. - name: run tests
  144. working-directory: source
  145. env:
  146. DOCKER_CT_RUNNER_IMAGE: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  147. MONGO_TAG: "5"
  148. MYSQL_TAG: "8"
  149. PGSQL_TAG: "13"
  150. REDIS_TAG: "7.0"
  151. INFLUXDB_TAG: "2.5.0"
  152. TDENGINE_TAG: "3.0.2.4"
  153. PROFILE: ${{ matrix.profile }}
  154. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  155. run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }}
  156. - uses: actions/upload-artifact@v3
  157. with:
  158. name: coverdata
  159. path: source/_build/test/cover
  160. - uses: actions/upload-artifact@v3
  161. if: failure()
  162. with:
  163. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}
  164. path: source/_build/test/logs
  165. ct:
  166. needs:
  167. - build-matrix
  168. - prepare
  169. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  170. strategy:
  171. fail-fast: false
  172. matrix:
  173. include: ${{ fromJson(needs.build-matrix.outputs.host) }}
  174. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  175. defaults:
  176. run:
  177. shell: bash
  178. steps:
  179. - uses: AutoModality/action-clean@v1
  180. - uses: actions/download-artifact@v3
  181. with:
  182. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  183. path: .
  184. - name: unzip source code
  185. run: unzip -q source.zip
  186. # produces $PROFILE-<app-name>.coverdata
  187. - name: run common test
  188. working-directory: source
  189. env:
  190. PROFILE: ${{ matrix.profile }}
  191. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  192. run: |
  193. make "${{ matrix.app }}-ct"
  194. - uses: actions/upload-artifact@v3
  195. with:
  196. name: coverdata
  197. path: source/_build/test/cover
  198. if-no-files-found: warn # do not fail if no coverdata found
  199. - uses: actions/upload-artifact@v3
  200. if: failure()
  201. with:
  202. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}
  203. path: source/_build/test/logs
  204. make_cover:
  205. needs:
  206. - eunit_and_proper
  207. - ct
  208. - ct_docker
  209. runs-on: ubuntu-20.04
  210. container: "ghcr.io/emqx/emqx-builder/5.0-28:1.13.4-24.3.4.2-2-ubuntu20.04"
  211. steps:
  212. - uses: AutoModality/action-clean@v1
  213. - uses: actions/download-artifact@v3
  214. with:
  215. name: source-emqx-enterprise-24.3.4.2-2
  216. path: .
  217. - name: unzip source code
  218. run: unzip -q source.zip
  219. - uses: actions/download-artifact@v3
  220. name: download coverdata
  221. with:
  222. name: coverdata
  223. path: source/_build/test/cover
  224. - name: make cover
  225. working-directory: source
  226. env:
  227. PROFILE: emqx-enterprise
  228. run: make cover
  229. - name: send to coveralls
  230. working-directory: source
  231. env:
  232. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  233. PROFILE: emqx-enterprise
  234. run: make coveralls
  235. - name: get coveralls logs
  236. working-directory: source
  237. if: failure()
  238. run: cat rebar3.crashdump
  239. # do this in a separate job
  240. upload_coverdata:
  241. needs: make_cover
  242. runs-on: ubuntu-20.04
  243. steps:
  244. - name: Coveralls Finished
  245. env:
  246. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  247. run: |
  248. curl -v -k https://coveralls.io/webhook \
  249. --header "Content-Type: application/json" \
  250. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true