_pr_entrypoint.yaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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: ubuntu-22.04
  16. container: "ghcr.io/emqx/emqx-builder/5.3-8:1.15.7-26.2.5-2-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. builder: "ghcr.io/emqx/emqx-builder/5.3-8:1.15.7-26.2.5-2-ubuntu22.04"
  24. builder_vsn: "5.3-8"
  25. otp_vsn: "26.2.5-2"
  26. elixir_vsn: "1.15.7"
  27. permissions:
  28. contents: read
  29. steps:
  30. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  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. mix local.hex 2.0.6 --force --if-missing && mix local.rebar --force --if-missing
  77. - name: Check formatting
  78. env:
  79. MIX_ENV: emqx-enterprise
  80. PROFILE: emqx-enterprise
  81. run: |
  82. ./scripts/check-format.sh
  83. - name: Run elvis check
  84. run: |
  85. ./scripts/elvis-check.sh $GITHUB_BASE_REF
  86. - name: Generate CT Matrix
  87. id: matrix
  88. run: |
  89. APPS="$(./scripts/find-apps.sh --ci)"
  90. MATRIX="$(echo "${APPS}" | jq -c '
  91. [
  92. (.[] | select(.profile == "emqx") | . + {
  93. builder: "5.3-8",
  94. otp: "26.2.5-2",
  95. elixir: "1.15.7"
  96. }),
  97. (.[] | select(.profile == "emqx-enterprise") | . + {
  98. builder: "5.3-8",
  99. otp: ["26.2.5-2"][],
  100. elixir: "1.15.7"
  101. })
  102. ]
  103. ')"
  104. echo "${MATRIX}" | jq
  105. CT_MATRIX="$(echo "${MATRIX}" | jq -c 'map({profile, builder, otp, elixir}) | unique')"
  106. CT_HOST="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "host"))')"
  107. CT_DOCKER="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "docker"))')"
  108. echo "ct-matrix=${CT_MATRIX}" | tee -a $GITHUB_OUTPUT
  109. echo "ct-host=${CT_HOST}" | tee -a $GITHUB_OUTPUT
  110. echo "ct-docker=${CT_DOCKER}" | tee -a $GITHUB_OUTPUT
  111. echo "version-emqx=$(./pkg-vsn.sh emqx)" | tee -a $GITHUB_OUTPUT
  112. echo "version-emqx-enterprise=$(./pkg-vsn.sh emqx-enterprise)" | tee -a $GITHUB_OUTPUT
  113. compile:
  114. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral-xl","linux","x64"]') }}
  115. container: ${{ needs.sanity-checks.outputs.builder }}
  116. needs:
  117. - sanity-checks
  118. strategy:
  119. matrix:
  120. profile:
  121. - emqx
  122. - emqx-enterprise
  123. permissions:
  124. contents: read
  125. steps:
  126. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  127. with:
  128. fetch-depth: 0
  129. - name: Work around https://github.com/actions/checkout/issues/766
  130. run: |
  131. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  132. - id: compile
  133. env:
  134. PROFILE: ${{ matrix.profile }}
  135. ENABLE_COVER_COMPILE: 1
  136. run: |
  137. make ensure-rebar3
  138. make ${PROFILE}-compile test-compile
  139. echo "PROFILE=${PROFILE}" | tee -a .env
  140. echo "PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a .env
  141. zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip .
  142. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  143. with:
  144. name: ${{ matrix.profile }}
  145. path: ${{ matrix.profile }}.zip
  146. retention-days: 7
  147. run_emqx_app_tests:
  148. needs:
  149. - sanity-checks
  150. - compile
  151. uses: ./.github/workflows/run_emqx_app_tests.yaml
  152. with:
  153. builder: ${{ needs.sanity-checks.outputs.builder }}
  154. before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
  155. after_ref: ${{ github.sha }}
  156. run_test_cases:
  157. needs:
  158. - sanity-checks
  159. - compile
  160. uses: ./.github/workflows/run_test_cases.yaml
  161. with:
  162. builder: ${{ needs.sanity-checks.outputs.builder }}
  163. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  164. ct-host: ${{ needs.sanity-checks.outputs.ct-host }}
  165. ct-docker: ${{ needs.sanity-checks.outputs.ct-docker }}
  166. static_checks:
  167. needs:
  168. - sanity-checks
  169. - compile
  170. uses: ./.github/workflows/static_checks.yaml
  171. with:
  172. builder: ${{ needs.sanity-checks.outputs.builder }}
  173. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  174. build_slim_packages:
  175. needs:
  176. - sanity-checks
  177. uses: ./.github/workflows/build_slim_packages.yaml
  178. with:
  179. builder: ${{ needs.sanity-checks.outputs.builder }}
  180. builder_vsn: ${{ needs.sanity-checks.outputs.builder_vsn }}
  181. otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
  182. elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
  183. build_docker_for_test:
  184. needs:
  185. - sanity-checks
  186. uses: ./.github/workflows/build_docker_for_test.yaml
  187. with:
  188. otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
  189. elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
  190. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  191. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
  192. spellcheck:
  193. needs:
  194. - sanity-checks
  195. - build_slim_packages
  196. uses: ./.github/workflows/spellcheck.yaml
  197. run_conf_tests:
  198. needs:
  199. - sanity-checks
  200. - compile
  201. uses: ./.github/workflows/run_conf_tests.yaml
  202. with:
  203. builder: ${{ needs.sanity-checks.outputs.builder }}
  204. check_deps_integrity:
  205. needs:
  206. - sanity-checks
  207. uses: ./.github/workflows/check_deps_integrity.yaml
  208. with:
  209. builder: ${{ needs.sanity-checks.outputs.builder }}
  210. run_jmeter_tests:
  211. needs:
  212. - sanity-checks
  213. - build_docker_for_test
  214. uses: ./.github/workflows/run_jmeter_tests.yaml
  215. with:
  216. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  217. run_docker_tests:
  218. needs:
  219. - sanity-checks
  220. - build_docker_for_test
  221. uses: ./.github/workflows/run_docker_tests.yaml
  222. with:
  223. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  224. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
  225. run_helm_tests:
  226. needs:
  227. - sanity-checks
  228. - build_docker_for_test
  229. uses: ./.github/workflows/run_helm_tests.yaml
  230. with:
  231. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  232. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}