_pr_entrypoint.yaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. name: PR Entrypoint
  2. concurrency:
  3. group: pr-entrypoint-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. pull_request:
  7. workflow_dispatch:
  8. inputs:
  9. ref:
  10. required: false
  11. env:
  12. IS_CI: "yes"
  13. jobs:
  14. sanity-checks:
  15. runs-on: ${{ github.repository_owner == 'emqx' && 'aws-amd64' || 'ubuntu-22.04' }}
  16. container: "ghcr.io/emqx/emqx-builder/5.1-3:1.14.5-25.3.2-1-ubuntu22.04"
  17. outputs:
  18. ct-matrix: ${{ steps.matrix.outputs.ct-matrix }}
  19. ct-host: ${{ steps.matrix.outputs.ct-host }}
  20. ct-docker: ${{ steps.matrix.outputs.ct-docker }}
  21. version-emqx: ${{ steps.matrix.outputs.version-emqx }}
  22. version-emqx-enterprise: ${{ steps.matrix.outputs.version-emqx-enterprise }}
  23. runner: ${{ github.repository_owner == 'emqx' && 'aws-amd64' || 'ubuntu-22.04' }}
  24. builder: "ghcr.io/emqx/emqx-builder/5.1-3:1.14.5-25.3.2-1-ubuntu22.04"
  25. builder_vsn: "5.1-3"
  26. otp_vsn: "25.3.2-1"
  27. elixir_vsn: "1.14.5"
  28. steps:
  29. - uses: actions/checkout@v3
  30. with:
  31. ref: ${{ github.event.inputs.ref }}
  32. fetch-depth: 0
  33. - name: Work around https://github.com/actions/checkout/issues/766
  34. run: |
  35. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  36. - name: Run gitlint
  37. env:
  38. BEFORE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
  39. AFTER_REF: ${{ github.sha }}
  40. run: |
  41. pip install gitlint
  42. gitlint --commits $BEFORE_REF..$AFTER_REF --config .github/workflows/.gitlint
  43. - name: Run shellcheck
  44. run: |
  45. DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shellcheck
  46. ./scripts/shellcheck.sh
  47. - name: Run shell tests
  48. run: |
  49. DEBIAN_FRONTEND=noninteractive apt-get update -qy && apt-get install -qy shelltestrunner
  50. scripts/shelltest/run_tests.sh
  51. - name: Check workflow files
  52. env:
  53. ACTIONLINT_VSN: 1.6.25
  54. run: |
  55. wget https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VSN}/actionlint_${ACTIONLINT_VSN}_linux_amd64.tar.gz
  56. tar zxf actionlint_${ACTIONLINT_VSN}_linux_amd64.tar.gz actionlint
  57. # TODO: enable shellcheck when all the current issues are fixed
  58. ./actionlint -color \
  59. -shellcheck= \
  60. -ignore 'label ".+" is unknown' \
  61. -ignore 'value "emqx-enterprise" in "exclude"'
  62. - name: Check line-break at EOF
  63. run: |
  64. ./scripts/check-nl-at-eof.sh
  65. - name: Check apps version
  66. run: |
  67. ./scripts/apps-version-check.sh
  68. - name: Setup mix
  69. env:
  70. MIX_ENV: emqx-enterprise
  71. PROFILE: emqx-enterprise
  72. run: |
  73. mix local.hex --force --if-missing && mix local.rebar --force --if-missing
  74. - name: Check formatting
  75. env:
  76. MIX_ENV: emqx-enterprise
  77. PROFILE: emqx-enterprise
  78. run: |
  79. ./scripts/check-format.sh
  80. - name: Run elvis check
  81. run: |
  82. ./scripts/elvis-check.sh $GITHUB_BASE_REF
  83. - name: Generate CT Matrix
  84. id: matrix
  85. run: |
  86. APPS="$(./scripts/find-apps.sh --ci)"
  87. MATRIX="$(echo "${APPS}" | jq -c '
  88. [
  89. (.[] | select(.profile == "emqx") | . + {
  90. builder: "5.1-3",
  91. otp: "25.3.2-1",
  92. elixir: "1.14.5"
  93. }),
  94. (.[] | select(.profile == "emqx-enterprise") | . + {
  95. builder: "5.1-3",
  96. otp: ["25.3.2-1"][],
  97. elixir: "1.14.5"
  98. })
  99. ]
  100. ')"
  101. echo "${MATRIX}" | jq
  102. CT_MATRIX="$(echo "${MATRIX}" | jq -c 'map({profile, builder, otp, elixir}) | unique')"
  103. CT_HOST="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "host"))')"
  104. CT_DOCKER="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "docker"))')"
  105. echo "ct-matrix=${CT_MATRIX}" | tee -a $GITHUB_OUTPUT
  106. echo "ct-host=${CT_HOST}" | tee -a $GITHUB_OUTPUT
  107. echo "ct-docker=${CT_DOCKER}" | tee -a $GITHUB_OUTPUT
  108. echo "version-emqx=$(./pkg-vsn.sh emqx)" | tee -a $GITHUB_OUTPUT
  109. echo "version-emqx-enterprise=$(./pkg-vsn.sh emqx-enterprise)" | tee -a $GITHUB_OUTPUT
  110. compile:
  111. runs-on: ${{ needs.sanity-checks.outputs.runner }}
  112. container: ${{ needs.sanity-checks.outputs.builder }}
  113. needs:
  114. - sanity-checks
  115. strategy:
  116. matrix:
  117. profile:
  118. - emqx
  119. - emqx-enterprise
  120. steps:
  121. - uses: actions/checkout@v3
  122. with:
  123. fetch-depth: 0
  124. - name: Work around https://github.com/actions/checkout/issues/766
  125. run: |
  126. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  127. - id: compile
  128. env:
  129. PROFILE: ${{ matrix.profile }}
  130. ENABLE_COVER_COMPILE: 1
  131. run: |
  132. make ensure-rebar3
  133. make ${PROFILE}
  134. make test-compile
  135. zip -ryq $PROFILE.zip .
  136. - uses: actions/upload-artifact@v3
  137. with:
  138. name: ${{ matrix.profile }}
  139. path: ${{ matrix.profile }}.zip
  140. retention-days: 1
  141. run_emqx_app_tests:
  142. needs:
  143. - sanity-checks
  144. - compile
  145. uses: ./.github/workflows/run_emqx_app_tests.yaml
  146. with:
  147. runner: ${{ needs.sanity-checks.outputs.runner }}
  148. builder: ${{ needs.sanity-checks.outputs.builder }}
  149. before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
  150. after_ref: ${{ github.sha }}
  151. run_test_cases:
  152. needs:
  153. - sanity-checks
  154. - compile
  155. uses: ./.github/workflows/run_test_cases.yaml
  156. with:
  157. runner: ${{ needs.sanity-checks.outputs.runner }}
  158. builder: ${{ needs.sanity-checks.outputs.builder }}
  159. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  160. ct-host: ${{ needs.sanity-checks.outputs.ct-host }}
  161. ct-docker: ${{ needs.sanity-checks.outputs.ct-docker }}
  162. static_checks:
  163. needs:
  164. - sanity-checks
  165. - compile
  166. uses: ./.github/workflows/static_checks.yaml
  167. with:
  168. runner: ${{ needs.sanity-checks.outputs.runner }}
  169. builder: ${{ needs.sanity-checks.outputs.builder }}
  170. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  171. build_slim_packages:
  172. needs:
  173. - sanity-checks
  174. uses: ./.github/workflows/build_slim_packages.yaml
  175. with:
  176. runner: ${{ needs.sanity-checks.outputs.runner }}
  177. builder: ${{ needs.sanity-checks.outputs.builder }}
  178. builder_vsn: ${{ needs.sanity-checks.outputs.builder_vsn }}
  179. otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
  180. elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
  181. build_docker_for_test:
  182. needs:
  183. - sanity-checks
  184. uses: ./.github/workflows/build_docker_for_test.yaml
  185. with:
  186. otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
  187. elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
  188. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  189. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
  190. spellcheck:
  191. needs:
  192. - sanity-checks
  193. - build_slim_packages
  194. uses: ./.github/workflows/spellcheck.yaml
  195. with:
  196. runner: ${{ needs.sanity-checks.outputs.runner }}
  197. run_conf_tests:
  198. needs:
  199. - sanity-checks
  200. - compile
  201. uses: ./.github/workflows/run_conf_tests.yaml
  202. with:
  203. runner: ${{ needs.sanity-checks.outputs.runner }}
  204. builder: ${{ needs.sanity-checks.outputs.builder }}
  205. check_deps_integrity:
  206. needs:
  207. - sanity-checks
  208. uses: ./.github/workflows/check_deps_integrity.yaml
  209. with:
  210. runner: ${{ needs.sanity-checks.outputs.runner }}
  211. builder: ${{ needs.sanity-checks.outputs.builder }}
  212. run_jmeter_tests:
  213. needs:
  214. - sanity-checks
  215. - build_docker_for_test
  216. uses: ./.github/workflows/run_jmeter_tests.yaml
  217. with:
  218. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  219. run_docker_tests:
  220. needs:
  221. - sanity-checks
  222. - build_docker_for_test
  223. uses: ./.github/workflows/run_docker_tests.yaml
  224. with:
  225. runner: ${{ needs.sanity-checks.outputs.runner }}
  226. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  227. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
  228. run_helm_tests:
  229. needs:
  230. - sanity-checks
  231. - build_docker_for_test
  232. uses: ./.github/workflows/run_helm_tests.yaml
  233. with:
  234. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  235. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}