tests.yaml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: Tests
  2. on:
  3. pull_request:
  4. branches:
  5. - main
  6. jobs:
  7. docker-tests:
  8. runs-on: ubuntu-latest
  9. strategy:
  10. matrix:
  11. dockerfile: [ "Dockerfile", "Dockerfile.alpine" ]
  12. steps:
  13. - uses: actions/checkout@v3
  14. with:
  15. submodules: recursive
  16. - name: Set up Docker Buildx
  17. id: buildx
  18. uses: docker/setup-buildx-action@master
  19. with:
  20. install: true
  21. - name: Build test image
  22. uses: docker/build-push-action@v3
  23. with:
  24. context: ./
  25. file: ${{ matrix.dockerfile }}
  26. push: false
  27. pull: true
  28. target: builder
  29. tags: frankenphp:${{ github.sha }}-builder
  30. builder: ${{ steps.buildx.outputs.name }}
  31. cache-from: type=gha
  32. cache-to: type=gha,mode=max
  33. outputs: type=docker,dest=/tmp/.builder.tar
  34. - name: Run tests
  35. run: |
  36. docker load -i /tmp/.builder.tar
  37. docker run --rm frankenphp:${{ github.sha }}-builder "go test"
  38. push-image:
  39. runs-on: ubuntu-latest
  40. strategy:
  41. matrix:
  42. dockerfile: [ "Dockerfile", "Dockerfile.alpine" ]
  43. steps:
  44. - uses: actions/checkout@v3
  45. with:
  46. submodules: recursive
  47. - name: Docker meta
  48. id: meta
  49. uses: docker/metadata-action@v4
  50. with:
  51. # list of Docker images to use as base name for tags
  52. images: |
  53. frankenphp
  54. # generate Docker tags based on the following events/attributes
  55. tags: |
  56. type=schedule
  57. type=ref,event=branch
  58. type=ref,event=pr
  59. type=semver,pattern={{version}}
  60. type=semver,pattern={{major}}.{{minor}}
  61. type=semver,pattern={{major}}
  62. type=sha
  63. - name: Set up Docker Buildx
  64. id: buildx
  65. uses: docker/setup-buildx-action@master
  66. with:
  67. install: true
  68. - name: Setup QEMU
  69. uses: docker/setup-qemu-action@v2
  70. - name: Build and Push Image
  71. uses: docker/build-push-action@v3
  72. with:
  73. context: ./
  74. file: ${{ matrix.dockerfile }}
  75. push: false
  76. pull: true
  77. target: final
  78. platforms: linux/amd64,linux/arm64
  79. tags: ${{ steps.meta.outputs.tags }}
  80. labels: ${{ steps.meta.outputs.labels }}
  81. builder: ${{ steps.buildx.outputs.name }}
  82. cache-from: type=gha
  83. cache-to: type=gha,mode=max