build_docker_for_test.yaml 1.8 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. runner_labels:
  9. required: true
  10. type: string
  11. otp_vsn:
  12. required: true
  13. type: string
  14. elixir_vsn:
  15. required: true
  16. type: string
  17. version-emqx:
  18. required: true
  19. type: string
  20. version-emqx-enterprise:
  21. required: true
  22. type: string
  23. jobs:
  24. docker:
  25. runs-on: ${{ fromJSON(inputs.runner_labels) }}
  26. env:
  27. EMQX_NAME: ${{ matrix.profile }}
  28. PKG_VSN: ${{ startsWith(matrix.profile, 'emqx-enterprise') && inputs.version-emqx-enterprise || inputs.version-emqx }}
  29. OTP_VSN: ${{ inputs.otp_vsn }}
  30. ELIXIR_VSN: ${{ inputs.elixir_vsn }}
  31. strategy:
  32. fail-fast: false
  33. matrix:
  34. profile:
  35. - emqx
  36. - emqx-enterprise
  37. - emqx-elixir
  38. - emqx-enterprise-elixir
  39. steps:
  40. - uses: actions/checkout@v3
  41. - name: build and export to Docker
  42. id: build
  43. run: |
  44. make ${EMQX_NAME}-docker
  45. echo "EMQX_IMAGE_TAG=$(cat .docker_image_tag)" >> $GITHUB_ENV
  46. - name: smoke test
  47. run: |
  48. CID=$(docker run -d --rm -P $EMQX_IMAGE_TAG)
  49. HTTP_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "18083/tcp") 0).HostPort}}' $CID)
  50. ./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT
  51. docker stop $CID
  52. - name: export docker image
  53. run: |
  54. docker save $EMQX_IMAGE_TAG | gzip > $EMQX_NAME-docker-$PKG_VSN.tar.gz
  55. - uses: actions/upload-artifact@v3
  56. with:
  57. name: "${{ env.EMQX_NAME }}-docker"
  58. path: "${{ env.EMQX_NAME }}-docker-${{ env.PKG_VSN }}.tar.gz"
  59. retention-days: 3