build_docker_for_test.yaml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. name: Build docker image for test
  2. concurrency:
  3. group: docker-test-build-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. workflow_call:
  7. inputs:
  8. otp_vsn:
  9. required: true
  10. type: string
  11. elixir_vsn:
  12. required: true
  13. type: string
  14. version-emqx:
  15. required: true
  16. type: string
  17. version-emqx-enterprise:
  18. required: true
  19. type: string
  20. permissions:
  21. contents: read
  22. jobs:
  23. docker:
  24. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  25. env:
  26. EMQX_NAME: ${{ matrix.profile }}
  27. PKG_VSN: ${{ startsWith(matrix.profile, 'emqx-enterprise') && inputs.version-emqx-enterprise || inputs.version-emqx }}
  28. OTP_VSN: ${{ inputs.otp_vsn }}
  29. ELIXIR_VSN: ${{ inputs.elixir_vsn }}
  30. strategy:
  31. fail-fast: false
  32. matrix:
  33. profile:
  34. - emqx
  35. - emqx-enterprise
  36. - emqx-elixir
  37. - emqx-enterprise-elixir
  38. steps:
  39. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  40. - name: build and export to Docker
  41. id: build
  42. run: |
  43. make ${EMQX_NAME}-docker
  44. echo "_EMQX_DOCKER_IMAGE_TAG=$(head -n 1 .emqx_docker_image_tags)" >> $GITHUB_ENV
  45. - name: smoke test
  46. run: |
  47. CID=$(docker run -d --rm -P $_EMQX_DOCKER_IMAGE_TAG)
  48. HTTP_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "18083/tcp") 0).HostPort}}' $CID)
  49. ./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT
  50. docker stop $CID
  51. - name: export docker image
  52. run: |
  53. docker save $_EMQX_DOCKER_IMAGE_TAG | gzip > $EMQX_NAME-docker-$PKG_VSN.tar.gz
  54. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  55. with:
  56. name: "${{ env.EMQX_NAME }}-docker"
  57. path: "${{ env.EMQX_NAME }}-docker-${{ env.PKG_VSN }}.tar.gz"
  58. retention-days: 3