run_test_cases.yaml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. - name: get_all_deps
  71. working-directory: source
  72. env:
  73. PROFILE: ${{ matrix.profile }}
  74. run: |
  75. make ensure-rebar3
  76. # fetch all deps and compile
  77. make ${{ matrix.profile }}-compile
  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. static_checks:
  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. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  95. steps:
  96. - uses: AutoModality/action-clean@v1
  97. - uses: actions/download-artifact@v3
  98. with:
  99. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  100. path: .
  101. - name: unzip source code
  102. run: unzip -o -q source.zip
  103. - uses: actions/cache@v3
  104. with:
  105. path: "source/emqx_dialyzer_${{ matrix.otp }}_plt"
  106. key: rebar3-dialyzer-plt-${{ matrix.profile }}-${{ matrix.otp }}
  107. - name: run static checks
  108. env:
  109. PROFILE: ${{ matrix.profile }}
  110. working-directory: source
  111. run: make static_checks
  112. eunit_and_proper:
  113. needs:
  114. - build-matrix
  115. - prepare
  116. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  117. strategy:
  118. fail-fast: false
  119. matrix:
  120. include: ${{ fromJson(needs.build-matrix.outputs.prepare) }}
  121. defaults:
  122. run:
  123. shell: bash
  124. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  125. steps:
  126. - uses: AutoModality/action-clean@v1
  127. - uses: actions/download-artifact@v3
  128. with:
  129. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  130. path: .
  131. - name: unzip source code
  132. run: unzip -o -q source.zip
  133. # produces eunit.coverdata
  134. - name: eunit
  135. env:
  136. PROFILE: ${{ matrix.profile }}
  137. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  138. working-directory: source
  139. run: make eunit
  140. # produces proper.coverdata
  141. - name: proper
  142. env:
  143. PROFILE: ${{ matrix.profile }}
  144. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  145. working-directory: source
  146. run: make proper
  147. - uses: actions/upload-artifact@v3
  148. with:
  149. name: coverdata
  150. path: source/_build/test/cover
  151. ct_docker:
  152. needs:
  153. - build-matrix
  154. - prepare
  155. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  156. strategy:
  157. fail-fast: false
  158. matrix:
  159. include: ${{ fromJson(needs.build-matrix.outputs.docker) }}
  160. defaults:
  161. run:
  162. shell: bash
  163. steps:
  164. - uses: AutoModality/action-clean@v1
  165. - uses: actions/download-artifact@v3
  166. with:
  167. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  168. path: .
  169. - name: unzip source code
  170. run: unzip -q source.zip
  171. - name: run tests
  172. working-directory: source
  173. env:
  174. DOCKER_CT_RUNNER_IMAGE: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  175. MONGO_TAG: "5"
  176. MYSQL_TAG: "8"
  177. PGSQL_TAG: "13"
  178. REDIS_TAG: "7.0"
  179. INFLUXDB_TAG: "2.5.0"
  180. TDENGINE_TAG: "3.0.2.4"
  181. OPENTS_TAG: "9aa7f88"
  182. MINIO_TAG: "RELEASE.2023-03-20T20-16-18Z"
  183. PROFILE: ${{ matrix.profile }}
  184. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  185. run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }}
  186. - uses: actions/upload-artifact@v3
  187. with:
  188. name: coverdata
  189. path: source/_build/test/cover
  190. - uses: actions/upload-artifact@v3
  191. if: failure()
  192. with:
  193. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}
  194. path: source/_build/test/logs
  195. ct:
  196. needs:
  197. - build-matrix
  198. - prepare
  199. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  200. strategy:
  201. fail-fast: false
  202. matrix:
  203. include: ${{ fromJson(needs.build-matrix.outputs.host) }}
  204. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  205. defaults:
  206. run:
  207. shell: bash
  208. steps:
  209. - uses: AutoModality/action-clean@v1
  210. - uses: actions/download-artifact@v3
  211. with:
  212. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  213. path: .
  214. - name: unzip source code
  215. run: unzip -q source.zip
  216. # produces $PROFILE-<app-name>.coverdata
  217. - name: run common test
  218. working-directory: source
  219. env:
  220. PROFILE: ${{ matrix.profile }}
  221. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}
  222. run: |
  223. make "${{ matrix.app }}-ct"
  224. - uses: actions/upload-artifact@v3
  225. with:
  226. name: coverdata
  227. path: source/_build/test/cover
  228. if-no-files-found: warn # do not fail if no coverdata found
  229. - uses: actions/upload-artifact@v3
  230. if: failure()
  231. with:
  232. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}
  233. path: source/_build/test/logs
  234. make_cover:
  235. needs:
  236. - eunit_and_proper
  237. - ct
  238. - ct_docker
  239. runs-on: ubuntu-22.04
  240. container: "ghcr.io/emqx/emqx-builder/5.0-34:1.13.4-24.3.4.2-3-ubuntu22.04"
  241. steps:
  242. - uses: AutoModality/action-clean@v1
  243. - uses: actions/download-artifact@v3
  244. with:
  245. name: source-emqx-enterprise-24.3.4.2-3
  246. path: .
  247. - name: unzip source code
  248. run: unzip -q source.zip
  249. - uses: actions/download-artifact@v3
  250. name: download coverdata
  251. with:
  252. name: coverdata
  253. path: source/_build/test/cover
  254. - name: make cover
  255. working-directory: source
  256. env:
  257. PROFILE: emqx-enterprise
  258. run: make cover
  259. - name: send to coveralls
  260. working-directory: source
  261. env:
  262. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  263. PROFILE: emqx-enterprise
  264. run: make coveralls
  265. - name: get coveralls logs
  266. working-directory: source
  267. if: failure()
  268. run: cat rebar3.crashdump
  269. # do this in a separate job
  270. upload_coverdata:
  271. needs: make_cover
  272. runs-on: ubuntu-22.04
  273. steps:
  274. - name: Coveralls Finished
  275. env:
  276. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  277. run: |
  278. curl -v -k https://coveralls.io/webhook \
  279. --header "Content-Type: application/json" \
  280. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true