build_docker_for_test.yaml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: ${{ 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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  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 logs $CID
  51. exit 1
  52. }
  53. docker stop $CID
  54. - name: export docker image
  55. if: always()
  56. run: |
  57. docker save $_EMQX_DOCKER_IMAGE_TAG | gzip > $EMQX_NAME-docker-$PKG_VSN.tar.gz
  58. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  59. with:
  60. name: "${{ env.EMQX_NAME }}-docker"
  61. path: "${{ env.EMQX_NAME }}-docker-${{ env.PKG_VSN }}.tar.gz"
  62. retention-days: 3