run_test_cases.yaml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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.1-0",
  34. otp: "25.3.2-1",
  35. elixir: "1.14.5"
  36. }),
  37. (.[] | select(.profile == "emqx-enterprise") | . + {
  38. builder: "5.1-0",
  39. otp: ["25.3.2-1"][],
  40. elixir: "1.14.5"
  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. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  174. - name: run common tests
  175. working-directory: source
  176. env:
  177. DOCKER_CT_RUNNER_IMAGE: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  178. MONGO_TAG: "5"
  179. MYSQL_TAG: "8"
  180. PGSQL_TAG: "13"
  181. REDIS_TAG: "7.0"
  182. INFLUXDB_TAG: "2.5.0"
  183. TDENGINE_TAG: "3.0.2.4"
  184. OPENTS_TAG: "9aa7f88"
  185. MINIO_TAG: "RELEASE.2023-03-20T20-16-18Z"
  186. PROFILE: ${{ matrix.profile }}
  187. SUITEGROUP: ${{ matrix.suitegroup }}
  188. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  189. run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }}
  190. - uses: actions/upload-artifact@v3
  191. with:
  192. name: coverdata
  193. path: source/_build/test/cover
  194. - uses: actions/upload-artifact@v3
  195. if: failure()
  196. with:
  197. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  198. path: source/_build/test/logs
  199. ct:
  200. needs:
  201. - build-matrix
  202. - prepare
  203. runs-on: ${{ needs.build-matrix.outputs.runs-on }}
  204. strategy:
  205. fail-fast: false
  206. matrix:
  207. include: ${{ fromJson(needs.build-matrix.outputs.host) }}
  208. container: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-ubuntu22.04"
  209. defaults:
  210. run:
  211. shell: bash
  212. steps:
  213. - uses: AutoModality/action-clean@v1
  214. - uses: actions/download-artifact@v3
  215. with:
  216. name: source-${{ matrix.profile }}-${{ matrix.otp }}
  217. path: .
  218. - name: unzip source code
  219. run: unzip -q source.zip
  220. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  221. - name: run common tests
  222. working-directory: source
  223. env:
  224. PROFILE: ${{ matrix.profile }}
  225. SUITEGROUP: ${{ matrix.suitegroup }}
  226. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  227. run: |
  228. make "${{ matrix.app }}-ct"
  229. - uses: actions/upload-artifact@v3
  230. with:
  231. name: coverdata
  232. path: source/_build/test/cover
  233. if-no-files-found: warn # do not fail if no coverdata found
  234. - uses: actions/upload-artifact@v3
  235. if: failure()
  236. with:
  237. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-${{ matrix.otp }}-sg${{ matrix.suitegroup }}
  238. path: source/_build/test/logs
  239. make_cover:
  240. needs:
  241. - eunit_and_proper
  242. - ct
  243. - ct_docker
  244. runs-on: ubuntu-22.04
  245. container: "ghcr.io/emqx/emqx-builder/5.1-0:1.14.5-25.3.2-1-ubuntu22.04"
  246. steps:
  247. - uses: AutoModality/action-clean@v1
  248. - uses: actions/download-artifact@v3
  249. with:
  250. name: source-emqx-enterprise-25.3.2-1
  251. path: .
  252. - name: unzip source code
  253. run: unzip -q source.zip
  254. - uses: actions/download-artifact@v3
  255. name: download coverdata
  256. with:
  257. name: coverdata
  258. path: source/_build/test/cover
  259. - name: make cover
  260. working-directory: source
  261. env:
  262. PROFILE: emqx-enterprise
  263. run: make cover
  264. - name: send to coveralls
  265. working-directory: source
  266. env:
  267. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  268. PROFILE: emqx-enterprise
  269. run: make coveralls
  270. - name: get coveralls logs
  271. working-directory: source
  272. if: failure()
  273. run: cat rebar3.crashdump
  274. # do this in a separate job
  275. upload_coverdata:
  276. needs: make_cover
  277. runs-on: ubuntu-22.04
  278. steps:
  279. - name: Coveralls Finished
  280. env:
  281. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  282. run: |
  283. curl -v -k https://coveralls.io/webhook \
  284. --header "Content-Type: application/json" \
  285. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true