run_test_cases.yaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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-27",
  31. otp: "25.1.2-2",
  32. elixir: "1.13.4"
  33. }),
  34. (.[] | select(.profile == "emqx-enterprise") | . + {
  35. builder: "5.0-27",
  36. otp: ["24.3.4.2-1", "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: aws-amd64
  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. PROFILE: ${{ matrix.profile }}
  153. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  154. run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }}
  155. - uses: actions/upload-artifact@v3
  156. with:
  157. name: coverdata
  158. path: source/_build/test/cover
  159. - uses: actions/upload-artifact@v3
  160. if: failure()
  161. with:
  162. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}
  163. path: source/_build/test/logs
  164. ct:
  165. needs:
  166. - build-matrix
  167. - prepare
  168. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  169. strategy:
  170. fail-fast: false
  171. matrix:
  172. include: ${{ fromJson(needs.build-matrix.outputs.host) }}
  173. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  174. defaults:
  175. run:
  176. shell: bash
  177. steps:
  178. - uses: AutoModality/action-clean@v1
  179. - uses: actions/download-artifact@v3
  180. with:
  181. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  182. path: .
  183. - name: unzip source code
  184. run: unzip -q source.zip
  185. # produces $PROFILE-<app-name>.coverdata
  186. - name: run common test
  187. working-directory: source
  188. env:
  189. PROFILE: ${{ matrix.profile }}
  190. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  191. run: |
  192. make "${{ matrix.app }}-ct"
  193. - uses: actions/upload-artifact@v3
  194. with:
  195. name: coverdata
  196. path: source/_build/test/cover
  197. if-no-files-found: warn # do not fail if no coverdata found
  198. - uses: actions/upload-artifact@v3
  199. if: failure()
  200. with:
  201. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}
  202. path: source/_build/test/logs
  203. make_cover:
  204. needs:
  205. - eunit_and_proper
  206. - ct
  207. - ct_docker
  208. runs-on: ubuntu-20.04
  209. container: "ghcr.io/emqx/emqx-builder/5.0-27:1.13.4-24.3.4.2-1-ubuntu20.04"
  210. steps:
  211. - uses: AutoModality/action-clean@v1
  212. - uses: actions/download-artifact@v3
  213. with:
  214. name: source-emqx-enterprise-24.3.4.2-1
  215. path: .
  216. - name: unzip source code
  217. run: unzip -q source.zip
  218. - uses: actions/download-artifact@v3
  219. name: download coverdata
  220. with:
  221. name: coverdata
  222. path: source/_build/test/cover
  223. - name: make cover
  224. working-directory: source
  225. env:
  226. PROFILE: emqx-enterprise
  227. run: make cover
  228. - name: send to coveralls
  229. working-directory: source
  230. env:
  231. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  232. PROFILE: emqx-enterprise
  233. run: make coveralls
  234. - name: get coveralls logs
  235. working-directory: source
  236. if: failure()
  237. run: cat rebar3.crashdump
  238. # do this in a separate job
  239. upload_coverdata:
  240. needs: make_cover
  241. runs-on: ubuntu-20.04
  242. steps:
  243. - name: Coveralls Finished
  244. env:
  245. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  246. run: |
  247. curl -v -k https://coveralls.io/webhook \
  248. --header "Content-Type: application/json" \
  249. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true