run_test_cases.yaml 8.2 KB

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