_pr_entrypoint.yaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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-4:1.14.5-25.3.2-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. runner: ${{ github.repository_owner == 'emqx' && 'aws-amd64' || 'ubuntu-22.04' }}
  24. builder: "ghcr.io/emqx/emqx-builder/5.1-4:1.14.5-25.3.2-2-ubuntu22.04"
  25. builder_vsn: "5.1-4"
  26. otp_vsn: "25.3.2-2"
  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. -ignore 'value "emqx-enterprise-elixir" in "exclude"'
  63. - name: Check line-break at EOF
  64. run: |
  65. ./scripts/check-nl-at-eof.sh
  66. - name: Check apps version
  67. run: |
  68. ./scripts/apps-version-check.sh
  69. - name: Setup mix
  70. env:
  71. MIX_ENV: emqx-enterprise
  72. PROFILE: emqx-enterprise
  73. run: |
  74. mix local.hex --force --if-missing && mix local.rebar --force --if-missing
  75. - name: Check formatting
  76. env:
  77. MIX_ENV: emqx-enterprise
  78. PROFILE: emqx-enterprise
  79. run: |
  80. ./scripts/check-format.sh
  81. - name: Run elvis check
  82. run: |
  83. ./scripts/elvis-check.sh $GITHUB_BASE_REF
  84. - name: Generate CT Matrix
  85. id: matrix
  86. run: |
  87. APPS="$(./scripts/find-apps.sh --ci)"
  88. MATRIX="$(echo "${APPS}" | jq -c '
  89. [
  90. (.[] | select(.profile == "emqx") | . + {
  91. builder: "5.1-4",
  92. otp: "25.3.2-2",
  93. elixir: "1.14.5"
  94. }),
  95. (.[] | select(.profile == "emqx-enterprise") | . + {
  96. builder: "5.1-4",
  97. otp: ["25.3.2-2"][],
  98. elixir: "1.14.5"
  99. })
  100. ]
  101. ')"
  102. echo "${MATRIX}" | jq
  103. CT_MATRIX="$(echo "${MATRIX}" | jq -c 'map({profile, builder, otp, elixir}) | unique')"
  104. CT_HOST="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "host"))')"
  105. CT_DOCKER="$(echo "${MATRIX}" | jq -c 'map(select(.runner == "docker"))')"
  106. echo "ct-matrix=${CT_MATRIX}" | tee -a $GITHUB_OUTPUT
  107. echo "ct-host=${CT_HOST}" | tee -a $GITHUB_OUTPUT
  108. echo "ct-docker=${CT_DOCKER}" | tee -a $GITHUB_OUTPUT
  109. echo "version-emqx=$(./pkg-vsn.sh emqx)" | tee -a $GITHUB_OUTPUT
  110. echo "version-emqx-enterprise=$(./pkg-vsn.sh emqx-enterprise)" | tee -a $GITHUB_OUTPUT
  111. compile:
  112. runs-on: ${{ needs.sanity-checks.outputs.runner }}
  113. container: ${{ needs.sanity-checks.outputs.builder }}
  114. needs:
  115. - sanity-checks
  116. strategy:
  117. matrix:
  118. profile:
  119. - emqx
  120. - emqx-enterprise
  121. steps:
  122. - uses: actions/checkout@v3
  123. with:
  124. fetch-depth: 0
  125. - name: Work around https://github.com/actions/checkout/issues/766
  126. run: |
  127. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  128. - id: compile
  129. env:
  130. PROFILE: ${{ matrix.profile }}
  131. ENABLE_COVER_COMPILE: 1
  132. run: |
  133. make ensure-rebar3
  134. make ${PROFILE}
  135. make test-compile
  136. zip -ryq $PROFILE.zip .
  137. - uses: actions/upload-artifact@v3
  138. with:
  139. name: ${{ matrix.profile }}
  140. path: ${{ matrix.profile }}.zip
  141. retention-days: 1
  142. run_emqx_app_tests:
  143. needs:
  144. - sanity-checks
  145. - compile
  146. uses: ./.github/workflows/run_emqx_app_tests.yaml
  147. with:
  148. runner: ${{ needs.sanity-checks.outputs.runner }}
  149. builder: ${{ needs.sanity-checks.outputs.builder }}
  150. before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
  151. after_ref: ${{ github.sha }}
  152. run_test_cases:
  153. needs:
  154. - sanity-checks
  155. - compile
  156. uses: ./.github/workflows/run_test_cases.yaml
  157. with:
  158. runner: ${{ needs.sanity-checks.outputs.runner }}
  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. runner: ${{ needs.sanity-checks.outputs.runner }}
  170. builder: ${{ needs.sanity-checks.outputs.builder }}
  171. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  172. build_slim_packages:
  173. needs:
  174. - sanity-checks
  175. uses: ./.github/workflows/build_slim_packages.yaml
  176. with:
  177. runner: ${{ needs.sanity-checks.outputs.runner }}
  178. builder: ${{ needs.sanity-checks.outputs.builder }}
  179. builder_vsn: ${{ needs.sanity-checks.outputs.builder_vsn }}
  180. otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
  181. elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
  182. build_docker_for_test:
  183. needs:
  184. - sanity-checks
  185. uses: ./.github/workflows/build_docker_for_test.yaml
  186. with:
  187. otp_vsn: ${{ needs.sanity-checks.outputs.otp_vsn }}
  188. elixir_vsn: ${{ needs.sanity-checks.outputs.elixir_vsn }}
  189. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  190. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
  191. spellcheck:
  192. needs:
  193. - sanity-checks
  194. - build_slim_packages
  195. uses: ./.github/workflows/spellcheck.yaml
  196. with:
  197. runner: ${{ needs.sanity-checks.outputs.runner }}
  198. run_conf_tests:
  199. needs:
  200. - sanity-checks
  201. - compile
  202. uses: ./.github/workflows/run_conf_tests.yaml
  203. with:
  204. runner: ${{ needs.sanity-checks.outputs.runner }}
  205. builder: ${{ needs.sanity-checks.outputs.builder }}
  206. check_deps_integrity:
  207. needs:
  208. - sanity-checks
  209. uses: ./.github/workflows/check_deps_integrity.yaml
  210. with:
  211. runner: ${{ needs.sanity-checks.outputs.runner }}
  212. builder: ${{ needs.sanity-checks.outputs.builder }}
  213. run_jmeter_tests:
  214. needs:
  215. - sanity-checks
  216. - build_docker_for_test
  217. uses: ./.github/workflows/run_jmeter_tests.yaml
  218. with:
  219. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  220. run_docker_tests:
  221. needs:
  222. - sanity-checks
  223. - build_docker_for_test
  224. uses: ./.github/workflows/run_docker_tests.yaml
  225. with:
  226. runner: ${{ needs.sanity-checks.outputs.runner }}
  227. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  228. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}
  229. run_helm_tests:
  230. needs:
  231. - sanity-checks
  232. - build_docker_for_test
  233. uses: ./.github/workflows/run_helm_tests.yaml
  234. with:
  235. version-emqx: ${{ needs.sanity-checks.outputs.version-emqx }}
  236. version-emqx-enterprise: ${{ needs.sanity-checks.outputs.version-emqx-enterprise }}