run_test_cases.yaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. - '**'
  9. tags:
  10. - v*
  11. - e*
  12. pull_request:
  13. jobs:
  14. prepare:
  15. runs-on: ubuntu-20.04
  16. # prepare source with any OTP version, no need for a matrix
  17. container: "ghcr.io/emqx/emqx-builder/5.0-18:1.13.4-24.3.4.2-1-ubuntu20.04"
  18. outputs:
  19. fast_ct_apps: ${{ steps.run_find_apps.outputs.fast_ct_apps }}
  20. docker_ct_apps: ${{ steps.run_find_apps.outputs.docker_ct_apps }}
  21. steps:
  22. - uses: actions/checkout@v3
  23. with:
  24. path: source
  25. fetch-depth: 0
  26. - name: find_ct_apps
  27. working-directory: source
  28. id: run_find_apps
  29. run: |
  30. fast_ct_apps="$(./scripts/find-apps.sh --ct fast --json)"
  31. docker_ct_apps="$(./scripts/find-apps.sh --ct docker --json)"
  32. echo "fast-ct-apps: $fast_ct_apps"
  33. echo "docer-ct-apps: $docker_ct_apps"
  34. echo "::set-output name=fast_ct_apps::$fast_ct_apps"
  35. echo "::set-output name=docker_ct_apps::$docker_ct_apps"
  36. - name: get_all_deps
  37. working-directory: source
  38. run: |
  39. make deps-all
  40. ./rebar3 as test compile
  41. cd ..
  42. zip -ryq source.zip source/* source/.[^.]*
  43. - uses: actions/upload-artifact@v3
  44. with:
  45. name: source
  46. path: source.zip
  47. eunit_and_proper:
  48. needs: prepare
  49. runs-on: aws-amd64
  50. strategy:
  51. fail-fast: false
  52. matrix:
  53. profile:
  54. - emqx
  55. - emqx-enterprise
  56. defaults:
  57. run:
  58. shell: bash
  59. container: "ghcr.io/emqx/emqx-builder/5.0-18:1.13.4-24.3.4.2-1-ubuntu20.04"
  60. steps:
  61. - uses: AutoModality/action-clean@v1
  62. - uses: actions/download-artifact@v3
  63. with:
  64. name: source
  65. path: .
  66. - name: unzip source code
  67. env:
  68. PROFILE: ${{ matrix.profile }}
  69. run: unzip -o -q source.zip
  70. # produces eunit.coverdata
  71. - name: eunit
  72. env:
  73. PROFILE: ${{ matrix.profile }}
  74. working-directory: source
  75. run: make eunit
  76. # produces proper.coverdata
  77. - name: proper
  78. env:
  79. PROFILE: ${{ matrix.profile }}
  80. working-directory: source
  81. run: make proper
  82. - uses: actions/upload-artifact@v3
  83. with:
  84. name: coverdata
  85. path: source/_build/test/cover
  86. ct_docker:
  87. needs: prepare
  88. strategy:
  89. fail-fast: false
  90. matrix:
  91. app_name: ${{ fromJson(needs.prepare.outputs.docker_ct_apps) }}
  92. otp_release:
  93. - "erlang24"
  94. runs-on: aws-amd64
  95. defaults:
  96. run:
  97. shell: bash
  98. steps:
  99. - uses: AutoModality/action-clean@v1
  100. - uses: actions/download-artifact@v3
  101. with:
  102. name: source
  103. path: .
  104. - name: unzip source code
  105. run: unzip -q source.zip
  106. - name: docker compose up
  107. working-directory: source
  108. env:
  109. MONGO_TAG: 5
  110. MYSQL_TAG: 8
  111. PGSQL_TAG: 13
  112. REDIS_TAG: 6
  113. run: |
  114. rm _build/default/lib/rocksdb/_build/cmake/CMakeCache.txt
  115. ./scripts/ct/run.sh --app ${{ matrix.app_name }}
  116. - uses: actions/upload-artifact@v3
  117. with:
  118. name: coverdata
  119. path: source/_build/test/cover
  120. - uses: actions/upload-artifact@v3
  121. if: failure()
  122. with:
  123. name: logs_${{ matrix.otp_release }}-${{ matrix.profile }}
  124. path: source/_build/test/logs
  125. ct:
  126. needs: prepare
  127. strategy:
  128. fail-fast: false
  129. matrix:
  130. app_name: ${{ fromJson(needs.prepare.outputs.fast_ct_apps) }}
  131. profile:
  132. - emqx
  133. - emqx-enterprise
  134. runs-on: aws-amd64
  135. container: "ghcr.io/emqx/emqx-builder/5.0-18:1.13.4-24.3.4.2-1-ubuntu20.04"
  136. defaults:
  137. run:
  138. shell: bash
  139. steps:
  140. - uses: AutoModality/action-clean@v1
  141. - uses: actions/download-artifact@v3
  142. with:
  143. name: source
  144. path: .
  145. - name: unzip source code
  146. run: unzip -q source.zip
  147. # produces <app-name>.coverdata
  148. - name: run common test
  149. working-directory: source
  150. env:
  151. PROFILE: ${{ matrix.profile }}
  152. WHICH_APP: ${{ matrix.app_name }}
  153. run: |
  154. if [ "$PROFILE" = 'emqx-enterprise' ]; then
  155. COMPILE_FLAGS="$(grep -R "EMQX_RELEASE_EDITION" "$WHICH_APP" | wc -l || true)"
  156. if [ "$COMPILE_FLAGS" -gt 0 ]; then
  157. # need to clean first because the default profile was
  158. make clean
  159. make "${WHICH_APP}-ct"
  160. else
  161. echo "skip_common_test_run_for_app ${WHICH_APP}-ct"
  162. fi
  163. else
  164. case "$WHICH_APP" in
  165. lib-ee/*)
  166. echo "skip_opensource_edition_test_for_lib-ee"
  167. ;;
  168. *)
  169. make "${WHICH_APP}-ct"
  170. ;;
  171. esac
  172. fi
  173. - uses: actions/upload-artifact@v3
  174. with:
  175. name: coverdata
  176. path: source/_build/test/cover
  177. if-no-files-found: warn # do not fail if no coverdata found
  178. - uses: actions/upload-artifact@v3
  179. if: failure()
  180. with:
  181. name: logs_${{ matrix.otp_release }}-${{ matrix.profile }}
  182. path: source/_build/test/logs
  183. make_cover:
  184. needs:
  185. - eunit_and_proper
  186. - ct
  187. - ct_docker
  188. runs-on: ubuntu-20.04
  189. container: "ghcr.io/emqx/emqx-builder/5.0-18:1.13.4-24.3.4.2-1-ubuntu20.04"
  190. steps:
  191. - uses: AutoModality/action-clean@v1
  192. - uses: actions/download-artifact@v3
  193. with:
  194. name: source
  195. path: .
  196. - name: unzip source code
  197. run: unzip -q source.zip
  198. - uses: actions/download-artifact@v3
  199. name: download coverdata
  200. with:
  201. name: coverdata
  202. path: source/_build/test/cover
  203. - name: make cover
  204. working-directory: source
  205. run: make cover
  206. - name: send to coveralls
  207. working-directory: source
  208. env:
  209. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  210. run: make coveralls
  211. - name: get coveralls logs
  212. working-directory: source
  213. if: failure()
  214. run: cat rebar3.crashdump
  215. # do this in a separate job
  216. upload_coverdata:
  217. needs: make_cover
  218. runs-on: ubuntu-20.04
  219. steps:
  220. - name: Coveralls Finished
  221. env:
  222. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  223. run: |
  224. curl -v -k https://coveralls.io/webhook \
  225. --header "Content-Type: application/json" \
  226. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true
  227. allgood_functional_tests:
  228. runs-on: ubuntu-20.04
  229. needs:
  230. - eunit_and_proper
  231. - ct_docker
  232. - ct
  233. steps:
  234. - name: Check if all functional tests succeeded
  235. uses: re-actors/alls-green@release/v1
  236. with:
  237. #allowed-failures:
  238. #allowed-skips:
  239. jobs: ${{ toJSON(needs) }}