Skip to content

Commit

Permalink
test parallel build
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Ruf committed Jul 4, 2024
1 parent 5eaf653 commit 9e1935d
Showing 1 changed file with 66 additions and 31 deletions.
97 changes: 66 additions & 31 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,66 @@ jobs:
working-directory: ./src/Resources
run: yarn test

buildDevImage:
name: Build Development Docker Images
runs-on: ubuntu-latest
needs: [ test-cgl, psalm, phpmd, format, lint, testFrontendUnitFunctional ]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 10
- name: Prepare build
run: |
mkdir -p /tmp/docker/buildx
git log -n 10 --date=short --format=format:"%C(auto)%h %ad @%al %s" >> public/changelog.txt
- name: Setup docker build caches
uses: actions/cache@v4
with:
key: ${{ runner.os }}-buildx
path: /tmp/docker/buildx
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# Development image
- name: Get Docker meta for development
id: devmeta
uses: docker/metadata-action@v5
with:
images: aoepeople/meals:beta
tags: |
type=sha
type=ref,event=branch
- name: Build and push development image
id: build_dev
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: false
tags: aoepeople/meals:test
labels: ${{ steps.devmeta.outputs.labels }}
build-args: |
BUILD_DEV="true"
cache-from: |
aoepeople/meals:beta
type=local,src=/tmp/docker/buildx
cache-to: type=local,dest=/tmp/docker/buildx
outputs: type=docker,dest=/tmp/docker/dev.tar
# Upload artifacts
- name: Upload docker images
uses: actions/upload-artifact@v4
with:
name: docker-images
path: /tmp/docker/*.tar
outputs:
imageDev: aoepeople/meals:test

buildImages:
name: Build Docker Images
runs-on: ubuntu-latest
Expand Down Expand Up @@ -176,30 +236,6 @@ jobs:
type=local,src=/tmp/docker/buildx
cache-to: type=local,dest=/tmp/docker/buildx
outputs: type=docker,dest=/tmp/docker/app.tar
# Development image
- name: Get Docker meta for development
id: devmeta
uses: docker/metadata-action@v5
with:
images: aoepeople/meals:beta
tags: |
type=sha
type=ref,event=branch
- name: Build and push development image
id: build_dev
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: false
tags: aoepeople/meals:test
labels: ${{ steps.devmeta.outputs.labels }}
build-args: |
BUILD_DEV="true"
cache-from: |
aoepeople/meals:beta
type=local,src=/tmp/docker/buildx
cache-to: type=local,dest=/tmp/docker/buildx
outputs: type=docker,dest=/tmp/docker/dev.tar
# Upload artifacts
- name: Upload docker images
uses: actions/upload-artifact@v4
Expand All @@ -209,15 +245,14 @@ jobs:
outputs:
image: ${{ fromJson(steps.meta.outputs.json).tags[0] }}
images: ${{ join(steps.meta.outputs.tags, ' ') }}
imageDev: aoepeople/meals:test

cypress:
name: Run E2E-tests via Cypress
needs: [ buildImages ]
needs: [ buildDevImage ]
runs-on: ubuntu-latest
env:
SERVICE: dev # use `dev` to enable xdebug and code coverage
IMAGE_DEV: ${{ needs.buildImages.outputs.image }}
IMAGE_DEV: ${{ needs.buildDevImage.outputs.imageDev }}
COMPOSE_INTERACTIVE_NO_CLI: true
strategy:
fail-fast: false
Expand Down Expand Up @@ -272,12 +307,12 @@ jobs:
testBackendUnitFunctional:
name: Run backend unit- and functional-tests
needs: [ buildImages ]
needs: [ buildImages, buildDevImage ]
runs-on: ubuntu-latest
env:
SERVICE: app # use `dev` to enable xdebug and code coverage
IMAGE: ${{ needs.buildImages.outputs.image }}
IMAGE_DEV: ${{ needs.buildImages.outputs.imageDev }}
IMAGE_DEV: ${{ needs.buildDevImage.outputs.imageDev }}
COMPOSE_INTERACTIVE_NO_CLI: true
steps:
- name: Set up Docker Buildx
Expand Down Expand Up @@ -313,11 +348,11 @@ jobs:
publish:
name: Publish
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
needs: [ buildImages, testBackendUnitFunctional, cypress ]
needs: [ buildImages, buildDevImage, testBackendUnitFunctional, cypress ]
runs-on: ubuntu-latest
env:
IMAGES_APP: ${{ needs.buildImages.outputs.images }}
IMAGE_DEV: ${{ needs.buildImages.outputs.imageDev }}
IMAGE_DEV: ${{ needs.buildDevImage.outputs.imageDev }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down

0 comments on commit 9e1935d

Please sign in to comment.