run_test_cases.yaml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. runs-on: aws-amd64
  93. defaults:
  94. run:
  95. shell: bash
  96. steps:
  97. - uses: AutoModality/action-clean@v1
  98. - uses: actions/download-artifact@v3
  99. with:
  100. name: source
  101. path: .
  102. - name: unzip source code
  103. run: unzip -q source.zip
  104. - name: docker compose up
  105. working-directory: source
  106. env:
  107. MONGO_TAG: 5
  108. MYSQL_TAG: 8
  109. PGSQL_TAG: 13
  110. REDIS_TAG: 6
  111. run: |
  112. rm _build/default/lib/rocksdb/_build/cmake/CMakeCache.txt
  113. ./scripts/ct/run.sh --app ${{ matrix.app_name }}
  114. - uses: actions/upload-artifact@v3
  115. with:
  116. name: coverdata
  117. path: source/_build/test/cover
  118. - uses: actions/upload-artifact@v3
  119. if: failure()
  120. with:
  121. name: logs-${{ matrix.profile }}
  122. path: source/_build/test/logs
  123. ct:
  124. needs: prepare
  125. strategy:
  126. fail-fast: false
  127. matrix:
  128. app_name: ${{ fromJson(needs.prepare.outputs.fast_ct_apps) }}
  129. profile:
  130. - emqx
  131. - emqx-enterprise
  132. runs-on: aws-amd64
  133. container: "ghcr.io/emqx/emqx-builder/5.0-18:1.13.4-24.3.4.2-1-ubuntu20.04"
  134. defaults:
  135. run:
  136. shell: bash
  137. steps:
  138. - uses: AutoModality/action-clean@v1
  139. - uses: actions/download-artifact@v3
  140. with:
  141. name: source
  142. path: .
  143. - name: unzip source code
  144. run: unzip -q source.zip
  145. # produces <app-name>.coverdata
  146. - name: run common test
  147. working-directory: source
  148. env:
  149. PROFILE: ${{ matrix.profile }}
  150. WHICH_APP: ${{ matrix.app_name }}
  151. run: |
  152. if [ "$PROFILE" = 'emqx-enterprise' ]; then
  153. COMPILE_FLAGS="$(grep -R "EMQX_RELEASE_EDITION" "$WHICH_APP" | wc -l || true)"
  154. if [ "$COMPILE_FLAGS" -gt 0 ]; then
  155. # need to clean first because the default profile was
  156. make clean
  157. make "${WHICH_APP}-ct"
  158. else
  159. echo "skip_common_test_run_for_app ${WHICH_APP}-ct"
  160. fi
  161. else
  162. case "$WHICH_APP" in
  163. lib-ee/*)
  164. echo "skip_opensource_edition_test_for_lib-ee"
  165. ;;
  166. *)
  167. make "${WHICH_APP}-ct"
  168. ;;
  169. esac
  170. fi
  171. - uses: actions/upload-artifact@v3
  172. with:
  173. name: coverdata
  174. path: source/_build/test/cover
  175. if-no-files-found: warn # do not fail if no coverdata found
  176. - uses: actions/upload-artifact@v3
  177. if: failure()
  178. with:
  179. name: logs-${{ matrix.profile }}
  180. path: source/_build/test/logs
  181. make_cover:
  182. needs:
  183. - eunit_and_proper
  184. - ct
  185. - ct_docker
  186. runs-on: ubuntu-20.04
  187. container: "ghcr.io/emqx/emqx-builder/5.0-18:1.13.4-24.3.4.2-1-ubuntu20.04"
  188. steps:
  189. - uses: AutoModality/action-clean@v1
  190. - uses: actions/download-artifact@v3
  191. with:
  192. name: source
  193. path: .
  194. - name: unzip source code
  195. run: unzip -q source.zip
  196. - uses: actions/download-artifact@v3
  197. name: download coverdata
  198. with:
  199. name: coverdata
  200. path: source/_build/test/cover
  201. - name: make cover
  202. working-directory: source
  203. run: make cover
  204. - name: send to coveralls
  205. working-directory: source
  206. env:
  207. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  208. run: make coveralls
  209. - name: get coveralls logs
  210. working-directory: source
  211. if: failure()
  212. run: cat rebar3.crashdump
  213. # do this in a separate job
  214. upload_coverdata:
  215. needs: make_cover
  216. runs-on: ubuntu-20.04
  217. steps:
  218. - name: Coveralls Finished
  219. env:
  220. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  221. run: |
  222. curl -v -k https://coveralls.io/webhook \
  223. --header "Content-Type: application/json" \
  224. --data "{\"repo_name\":\"$GITHUB_REPOSITORY\",\"repo_token\":\"$GITHUB_TOKEN\",\"payload\":{\"build_num\":$GITHUB_RUN_ID,\"status\":\"done\"}}" || true
  225. allgood_functional_tests:
  226. runs-on: ubuntu-20.04
  227. needs:
  228. - eunit_and_proper
  229. - ct_docker
  230. - ct
  231. steps:
  232. - name: Check if all functional tests succeeded
  233. uses: re-actors/alls-green@release/v1
  234. with:
  235. #allowed-failures:
  236. #allowed-skips:
  237. jobs: ${{ toJSON(needs) }}