run_test_cases.yaml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. name: Run test case
  2. concurrency:
  3. group: test-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. workflow_call:
  7. inputs:
  8. builder:
  9. required: true
  10. type: string
  11. ct-matrix:
  12. required: true
  13. type: string
  14. ct-host:
  15. required: true
  16. type: string
  17. ct-docker:
  18. required: true
  19. type: string
  20. permissions:
  21. contents: read
  22. env:
  23. IS_CI: "yes"
  24. jobs:
  25. eunit_and_proper:
  26. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  27. name: "eunit_and_proper (${{ matrix.profile }})"
  28. strategy:
  29. fail-fast: false
  30. matrix:
  31. include: ${{ fromJson(inputs.ct-matrix) }}
  32. defaults:
  33. run:
  34. shell: bash
  35. container: ${{ inputs.builder }}
  36. env:
  37. PROFILE: ${{ matrix.profile }}
  38. ENABLE_COVER_COMPILE: 1
  39. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}
  40. steps:
  41. - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
  42. with:
  43. name: ${{ matrix.profile }}
  44. - name: extract artifact
  45. run: |
  46. unzip -o -q ${{ matrix.profile }}.zip
  47. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  48. # produces eunit.coverdata
  49. - run: make eunit
  50. # produces proper.coverdata
  51. - run: make proper
  52. - run: make cover
  53. - name: send to coveralls
  54. if: github.repository == 'emqx/emqx'
  55. env:
  56. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  57. run: make coveralls
  58. - run: cat rebar3.crashdump || true
  59. if: failure()
  60. ct_docker:
  61. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  62. name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
  63. strategy:
  64. fail-fast: false
  65. matrix:
  66. include: ${{ fromJson(inputs.ct-docker) }}
  67. defaults:
  68. run:
  69. shell: bash
  70. env:
  71. PROFILE: ${{ matrix.profile }}
  72. steps:
  73. - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
  74. with:
  75. name: ${{ matrix.profile }}
  76. - name: extract artifact
  77. run: |
  78. unzip -o -q ${{ matrix.profile }}.zip
  79. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  80. - name: run common tests
  81. env:
  82. DOCKER_CT_RUNNER_IMAGE: ${{ inputs.builder }}
  83. MONGO_TAG: "5"
  84. MYSQL_TAG: "8"
  85. PGSQL_TAG: "13"
  86. REDIS_TAG: "7.0"
  87. INFLUXDB_TAG: "2.5.0"
  88. TDENGINE_TAG: "3.0.2.4"
  89. OPENTS_TAG: "9aa7f88"
  90. MINIO_TAG: "RELEASE.2023-03-20T20-16-18Z"
  91. SUITEGROUP: ${{ matrix.suitegroup }}
  92. ENABLE_COVER_COMPILE: 1
  93. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-sg${{ matrix.suitegroup }}
  94. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  95. run: ./scripts/ct/run.sh --ci --app ${{ matrix.app }} --keep-up
  96. - name: make cover
  97. run: |
  98. docker exec -e PROFILE="$PROFILE" -t erlang make cover
  99. - name: send to coveralls
  100. if: github.repository == 'emqx/emqx'
  101. run: |
  102. ls _build/test/cover/*.coverdata || exit 0
  103. docker exec -e PROFILE="$PROFILE" -t erlang make coveralls
  104. - name: rebar3.crashdump
  105. if: failure()
  106. run: cat rebar3.crashdump || true
  107. - name: compress logs
  108. if: failure()
  109. run: tar -czf logs.tar.gz _build/test/logs
  110. - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
  111. if: failure()
  112. with:
  113. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-sg${{ matrix.suitegroup }}
  114. path: logs.tar.gz
  115. compression-level: 0
  116. retention-days: 7
  117. ct:
  118. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  119. name: "${{ matrix.app }}-${{ matrix.suitegroup }} (${{ matrix.profile }})"
  120. strategy:
  121. fail-fast: false
  122. matrix:
  123. include: ${{ fromJson(inputs.ct-host) }}
  124. container: ${{ inputs.builder }}
  125. defaults:
  126. run:
  127. shell: bash
  128. env:
  129. PROFILE: ${{ matrix.profile }}
  130. SUITEGROUP: ${{ matrix.suitegroup }}
  131. ENABLE_COVER_COMPILE: 1
  132. CT_COVER_EXPORT_PREFIX: ${{ matrix.profile }}-sg${{ matrix.suitegroup }}
  133. steps:
  134. - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
  135. with:
  136. name: ${{ matrix.profile }}
  137. - name: extract artifact
  138. run: |
  139. unzip -o -q ${{ matrix.profile }}.zip
  140. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  141. # produces $PROFILE-<app-name>-<otp-vsn>-sg<suitegroup>.coverdata
  142. - name: run common tests
  143. run: make "${{ matrix.app }}-ct"
  144. - run: make cover
  145. - name: send to coveralls
  146. if: github.repository == 'emqx/emqx'
  147. env:
  148. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  149. run: |
  150. ls _build/test/cover/*.coverdata || exit 0
  151. make coveralls
  152. - run: cat rebar3.crashdump || true
  153. if: failure()
  154. - name: compress logs
  155. if: failure()
  156. run: tar -czf logs.tar.gz _build/test/logs
  157. - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
  158. if: failure()
  159. with:
  160. name: logs-${{ matrix.profile }}-${{ matrix.prefix }}-sg${{ matrix.suitegroup }}
  161. path: logs.tar.gz
  162. compression-level: 0
  163. retention-days: 7
  164. tests_passed:
  165. needs:
  166. - eunit_and_proper
  167. - ct
  168. - ct_docker
  169. runs-on: ubuntu-22.04
  170. strategy:
  171. fail-fast: false
  172. permissions:
  173. pull-requests: write
  174. steps:
  175. - name: Coveralls finished
  176. if: github.repository == 'emqx/emqx'
  177. uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # v2.3.0
  178. with:
  179. parallel-finished: true
  180. git-branch: ${{ github.ref }}
  181. git-commit: ${{ github.sha }}
  182. - run: echo "All tests passed"