run_test_cases.yaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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-26",
  31. otp: "25.1.2-2",
  32. elixir: "1.13.4"
  33. }),
  34. (.[] | select(.profile == "emqx-enterprise") | . + {
  35. builder: "5.0-26",
  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 test-compile
  77. cd ..
  78. zip -ryq source.zip source/* source/.[^.]*
  79. - uses: actions/upload-artifact@v3
  80. with:
  81. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  82. path: source.zip
  83. eunit_and_proper:
  84. needs:
  85. - build-matrix
  86. - prepare
  87. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  88. strategy:
  89. fail-fast: false
  90. matrix:
  91. include: ${{ fromJson(needs.build-matrix.outputs.prepare) }}
  92. defaults:
  93. run:
  94. shell: bash
  95. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  96. steps:
  97. - uses: AutoModality/action-clean@v1
  98. - uses: actions/download-artifact@v3
  99. with:
  100. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  101. path: .
  102. - name: unzip source code
  103. run: unzip -o -q source.zip
  104. # produces eunit.coverdata
  105. - name: eunit
  106. env:
  107. PROFILE: ${{ matrix.profile }}
  108. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  109. working-directory: source
  110. run: make eunit
  111. # produces proper.coverdata
  112. - name: proper
  113. env:
  114. PROFILE: ${{ matrix.profile }}
  115. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  116. working-directory: source
  117. run: make proper
  118. - uses: actions/upload-artifact@v3
  119. with:
  120. name: coverdata
  121. path: source/_build/test/cover
  122. ct_docker:
  123. needs:
  124. - build-matrix
  125. - prepare
  126. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  127. strategy:
  128. fail-fast: false
  129. matrix:
  130. include: ${{ fromJson(needs.build-matrix.outputs.docker) }}
  131. defaults:
  132. run:
  133. shell: bash
  134. steps:
  135. - uses: AutoModality/action-clean@v1
  136. - uses: actions/download-artifact@v3
  137. with:
  138. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  139. path: .
  140. - name: unzip source code
  141. run: unzip -q source.zip
  142. - name: run tests
  143. working-directory: source
  144. env:
  145. DOCKER_CT_RUNNER_IMAGE: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  146. MONGO_TAG: 5
  147. MYSQL_TAG: 8
  148. PGSQL_TAG: 13
  149. REDIS_TAG: 6
  150. INFLUXDB_TAG: 2.5.0
  151. PROFILE: ${{ matrix.profile }}
  152. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  153. run: ./scripts/ct/run.sh --app ${{ matrix.app }}
  154. - uses: actions/upload-artifact@v3
  155. with:
  156. name: coverdata
  157. path: source/_build/test/cover
  158. - uses: actions/upload-artifact@v3
  159. if: failure()
  160. with:
  161. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}
  162. path: source/_build/test/logs
  163. ct:
  164. needs:
  165. - build-matrix
  166. - prepare
  167. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  168. strategy:
  169. fail-fast: false
  170. matrix:
  171. include: ${{ fromJson(needs.build-matrix.outputs.host) }}
  172. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu20.04"
  173. defaults:
  174. run:
  175. shell: bash
  176. steps:
  177. - uses: AutoModality/action-clean@v1
  178. - uses: actions/download-artifact@v3
  179. with:
  180. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  181. path: .
  182. - name: unzip source code
  183. run: unzip -q source.zip
  184. # produces $PROFILE-<app-name>.coverdata
  185. - name: run common test
  186. working-directory: source
  187. env:
  188. PROFILE: ${{ matrix.profile }}
  189. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  190. run: |
  191. make "${{ matrix.app }}-ct"
  192. - uses: actions/upload-artifact@v3
  193. with:
  194. name: coverdata
  195. path: source/_build/test/cover
  196. if-no-files-found: warn # do not fail if no coverdata found
  197. - uses: actions/upload-artifact@v3
  198. if: failure()
  199. with:
  200. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}
  201. path: source/_build/test/logs
  202. make_cover:
  203. needs:
  204. - eunit_and_proper
  205. - ct
  206. - ct_docker
  207. runs-on: ubuntu-20.04
  208. container: "ghcr.io/emqx/emqx-builder/5.0-26:1.13.4-24.3.4.2-1-ubuntu20.04"
  209. steps:
  210. - uses: AutoModality/action-clean@v1
  211. - uses: actions/download-artifact@v3
  212. with:
  213. name: source-emqx-enterprise-24.3.4.2-1
  214. path: .
  215. - name: unzip source code
  216. run: unzip -q source.zip
  217. - uses: actions/download-artifact@v3
  218. name: download coverdata
  219. with:
  220. name: coverdata
  221. path: source/_build/test/cover
  222. - name: make cover
  223. working-directory: source
  224. env:
  225. PROFILE: emqx-enterprise
  226. run: make cover
  227. - name: send to coveralls
  228. working-directory: source
  229. env:
  230. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  231. PROFILE: emqx-enterprise
  232. run: make coveralls
  233. - name: get coveralls logs
  234. working-directory: source
  235. if: failure()
  236. run: cat rebar3.crashdump
  237. # do this in a separate job
  238. upload_coverdata:
  239. needs: make_cover
  240. runs-on: ubuntu-20.04
  241. steps:
  242. - name: Coveralls Finished
  243. env:
  244. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  245. run: |
  246. curl -v -k https://coveralls.io/webhook \
  247. --header "Content-Type: application/json" \
  248. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true