_pr_entrypoint.yaml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. permissions:
  12. contents: read
  13. defaults:
  14. run:
  15. shell: bash
  16. env:
  17. IS_CI: "yes"
  18. jobs:
  19. init:
  20. runs-on: ubuntu-22.04
  21. outputs:
  22. BUILDER_VSN: ${{ steps.env.outputs.BUILDER_VSN }}
  23. OTP_VSN: ${{ steps.env.outputs.OTP_VSN }}
  24. ELIXIR_VSN: ${{ steps.env.outputs.ELIXIR_VSN }}
  25. BUILDER: ${{ steps.env.outputs.BUILDER }}
  26. steps:
  27. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  28. with:
  29. ref: ${{ github.event.inputs.ref }}
  30. - name: Set up environment
  31. id: env
  32. run: |
  33. source ./env.sh
  34. echo "BUILDER_VSN=$EMQX_BUILDER_VSN" | tee -a "$GITHUB_OUTPUT"
  35. echo "OTP_VSN=$OTP_VSN" | tee -a "$GITHUB_OUTPUT"
  36. echo "ELIXIR_VSN=$ELIXIR_VSN" | tee -a "$GITHUB_OUTPUT"
  37. echo "BUILDER=$EMQX_BUILDER" | tee -a "$GITHUB_OUTPUT"
  38. sanity-checks:
  39. runs-on: ubuntu-22.04
  40. needs: init
  41. container: ${{ needs.init.outputs.BUILDER }}
  42. outputs:
  43. ct-matrix: ${{ steps.matrix.outputs.ct-matrix }}
  44. ct-host: ${{ steps.matrix.outputs.ct-host }}
  45. ct-docker: ${{ steps.matrix.outputs.ct-docker }}
  46. steps:
  47. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  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. steps:
  126. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  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 "export PROFILE=${PROFILE}" | tee -a env.sh
  140. echo "export PKG_VSN=$(./pkg-vsn.sh ${PROFILE})" | tee -a env.sh
  141. zip -ryq -x@.github/workflows/.zipignore $PROFILE.zip .
  142. make ${PROFILE}-rel
  143. - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
  144. with:
  145. name: ${{ matrix.profile }}
  146. path: ${{ matrix.profile }}.zip
  147. retention-days: 7
  148. - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
  149. with:
  150. name: "${{ matrix.profile }}-schema-dump"
  151. path: |
  152. env.sh
  153. scripts/spellcheck
  154. _build/docgen/${{ matrix.profile }}/*.json
  155. _build/docgen/${{ matrix.profile }}/*.hocon
  156. retention-days: 7
  157. run_emqx_app_tests:
  158. needs:
  159. - init
  160. - sanity-checks
  161. - compile
  162. uses: ./.github/workflows/run_emqx_app_tests.yaml
  163. with:
  164. builder: ${{ needs.init.outputs.BUILDER }}
  165. before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
  166. after_ref: ${{ github.sha }}
  167. run_test_cases:
  168. needs:
  169. - init
  170. - sanity-checks
  171. - compile
  172. permissions:
  173. contents: read
  174. pull-requests: write
  175. uses: ./.github/workflows/run_test_cases.yaml
  176. with:
  177. builder: ${{ needs.init.outputs.BUILDER }}
  178. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  179. ct-host: ${{ needs.sanity-checks.outputs.ct-host }}
  180. ct-docker: ${{ needs.sanity-checks.outputs.ct-docker }}
  181. static_checks:
  182. needs:
  183. - init
  184. - sanity-checks
  185. - compile
  186. uses: ./.github/workflows/static_checks.yaml
  187. with:
  188. builder: ${{ needs.init.outputs.BUILDER }}
  189. ct-matrix: ${{ needs.sanity-checks.outputs.ct-matrix }}
  190. build_slim_packages:
  191. needs:
  192. - sanity-checks
  193. uses: ./.github/workflows/build_slim_packages.yaml
  194. build_docker_emqx:
  195. needs:
  196. - init
  197. - sanity-checks
  198. uses: ./.github/workflows/build_and_push_docker_images.yaml
  199. with:
  200. profile: emqx
  201. publish: false
  202. secrets: inherit
  203. build_docker_emqx_enterprise:
  204. needs:
  205. - init
  206. - sanity-checks
  207. uses: ./.github/workflows/build_and_push_docker_images.yaml
  208. with:
  209. profile: emqx-enterprise
  210. publish: false
  211. secrets: inherit
  212. spellcheck:
  213. needs:
  214. - sanity-checks
  215. - compile
  216. uses: ./.github/workflows/spellcheck.yaml
  217. run_conf_tests:
  218. needs:
  219. - init
  220. - sanity-checks
  221. - compile
  222. uses: ./.github/workflows/run_conf_tests.yaml
  223. with:
  224. builder: ${{ needs.init.outputs.BUILDER }}
  225. check_deps_integrity:
  226. needs:
  227. - init
  228. - sanity-checks
  229. uses: ./.github/workflows/check_deps_integrity.yaml
  230. with:
  231. builder: ${{ needs.init.outputs.BUILDER }}
  232. run_jmeter_tests:
  233. needs:
  234. - sanity-checks
  235. - build_docker_emqx
  236. uses: ./.github/workflows/run_jmeter_tests.yaml
  237. run_docker_tests:
  238. needs:
  239. - sanity-checks
  240. - build_docker_emqx
  241. - build_docker_emqx_enterprise
  242. uses: ./.github/workflows/run_docker_tests.yaml
  243. run_helm_tests:
  244. needs:
  245. - sanity-checks
  246. - build_docker_emqx
  247. - build_docker_emqx_enterprise
  248. uses: ./.github/workflows/run_helm_tests.yaml