run_test_cases.yaml 8.4 KB

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