build_docker_for_test.yaml 1.7 KB

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