run_test_cases.yaml 8.4 KB

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