run_test_cases.yaml 7.4 KB

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