tests.yaml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Tests
  2. on:
  3. pull_request:
  4. branches:
  5. - main
  6. jobs:
  7. docker-tests:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - uses: actions/checkout@v3
  11. with:
  12. submodules: recursive
  13. - name: Set up Docker Buildx
  14. id: buildx
  15. uses: docker/setup-buildx-action@master
  16. with:
  17. install: true
  18. - name: Build test image
  19. uses: docker/build-push-action@v3
  20. with:
  21. context: ./
  22. file: Dockerfile
  23. push: false
  24. pull: true
  25. target: builder
  26. tags: ${{secrets.REGISTRY_LOGIN_SERVER}}/${{ secrets.REGISTRY_USERNAME }}/frankenphp:${{ github.sha }}-builder
  27. builder: ${{ steps.buildx.outputs.name }}
  28. cache-from: type=gha
  29. cache-to: type=gha,mode=max
  30. outputs: type=docker,dest=/tmp/.builder.tar
  31. - name: Run tests
  32. run: |
  33. docker load -i /tmp/.builder.tar
  34. docker run --rm ${{secrets.REGISTRY_LOGIN_SERVER}}/${{ secrets.REGISTRY_USERNAME }}/frankenphp:${{ github.sha }}-builder "go test"
  35. push-image:
  36. runs-on: ubuntu-latest
  37. steps:
  38. - uses: actions/checkout@v3
  39. with:
  40. submodules: recursive
  41. - name: Docker Login
  42. uses: docker/login-action@v2
  43. with:
  44. registry: ${{secrets.REGISTRY_LOGIN_SERVER}}
  45. username: ${{secrets.REGISTRY_USERNAME}}
  46. password: ${{secrets.REGISTRY_PASSWORD}}
  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. ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ secrets.REGISTRY_REPO }}/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: Dockerfile
  75. push: true
  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