build_docker_for_test.yaml 1.8 KB

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