2022-10-19 22:08:11 +00:00
|
|
|
name: Tests
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
jobs:
|
|
|
|
docker-tests:
|
|
|
|
runs-on: ubuntu-latest
|
2022-10-21 13:23:23 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
dockerfile: [ "Dockerfile", "Dockerfile.alpine" ]
|
2022-10-19 22:08:11 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2023-06-26 20:20:09 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-10-19 22:08:11 +00:00
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
|
|
|
- name: Build test image
|
2023-06-28 20:59:54 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2022-10-19 22:08:11 +00:00
|
|
|
with:
|
|
|
|
context: ./
|
2022-10-21 13:23:23 +00:00
|
|
|
file: ${{ matrix.dockerfile }}
|
2022-10-19 22:08:11 +00:00
|
|
|
push: false
|
|
|
|
pull: true
|
|
|
|
target: builder
|
2022-10-20 12:44:44 +00:00
|
|
|
tags: frankenphp:${{ github.sha }}-builder
|
2022-10-19 22:08:11 +00:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
|
|
|
outputs: type=docker,dest=/tmp/.builder.tar
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
docker load -i /tmp/.builder.tar
|
2023-06-28 20:59:54 +00:00
|
|
|
docker run --rm frankenphp:${{ github.sha }}-builder "sh -c 'go test -race -v ./... && cd caddy && go test -race -v ./...'"
|
2022-10-19 22:08:11 +00:00
|
|
|
push-image:
|
|
|
|
runs-on: ubuntu-latest
|
2022-10-21 13:23:23 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
dockerfile: [ "Dockerfile", "Dockerfile.alpine" ]
|
2022-10-27 13:53:51 +00:00
|
|
|
include:
|
|
|
|
- dockerfile: Dockerfile
|
|
|
|
flavor: ""
|
|
|
|
- dockerfile: Dockerfile.alpine
|
|
|
|
flavor: "-alpine"
|
2022-10-19 22:08:11 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
2022-10-27 13:53:51 +00:00
|
|
|
flavor: |
|
|
|
|
suffix=${{matrix.flavor}}
|
2022-10-19 22:08:11 +00:00
|
|
|
# list of Docker images to use as base name for tags
|
|
|
|
images: |
|
2022-10-20 12:44:44 +00:00
|
|
|
frankenphp
|
2022-10-19 22:08:11 +00:00
|
|
|
# generate Docker tags based on the following events/attributes
|
|
|
|
tags: |
|
|
|
|
type=schedule
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
2022-10-27 13:53:51 +00:00
|
|
|
type=raw,value=latest
|
2022-10-19 22:08:11 +00:00
|
|
|
type=sha
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2023-06-26 20:20:09 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-10-19 22:08:11 +00:00
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
2023-06-28 20:59:54 +00:00
|
|
|
- name: Set up QEMU
|
2022-10-19 22:08:11 +00:00
|
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
|
2023-06-28 20:59:54 +00:00
|
|
|
- name: Build Image
|
|
|
|
uses: docker/build-push-action@v4
|
2022-10-19 22:08:11 +00:00
|
|
|
with:
|
|
|
|
context: ./
|
2022-10-21 13:23:23 +00:00
|
|
|
file: ${{ matrix.dockerfile }}
|
2022-10-20 12:44:44 +00:00
|
|
|
push: false
|
2022-10-19 22:08:11 +00:00
|
|
|
pull: true
|
|
|
|
target: final
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
cache-from: type=gha
|
2022-10-23 14:47:00 +00:00
|
|
|
cache-to: type=gha,mode=max
|