run_test_cases.yaml 9.3 KB

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