run_test_cases.yaml 10 KB

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