_pr_entrypoint.yaml 8.5 KB

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