_pr_entrypoint.yaml 7.6 KB

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