From 2f30b4a018e29b3738dc52906cd02fa95ad996f0 Mon Sep 17 00:00:00 2001 From: Moritz Mahringer Date: Sun, 12 Sep 2021 22:41:18 +0200 Subject: [PATCH 1/3] Add multi-arch build --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ e2e/docker-compose.yml | 2 ++ 2 files changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03ee8eb6..60bfcaa5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,11 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -75,6 +80,7 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} target: production + platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Build and push (testing image) uses: docker/build-push-action@v2 @@ -91,16 +97,29 @@ jobs: tags: ${{ steps.docker_meta_testing.outputs.tags }} labels: ${{ steps.docker_meta_testing.outputs.labels }} target: testing + platforms: linux/amd64,linux/arm64,linux/arm/v7 test: runs-on: ubuntu-20.04 needs: - build + strategy: + matrix: + platform: + - "linux/amd64" + - "linux/arm64" + - "linux/arm/v7" + steps: - name: Checkout code uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Run tests run: | mkdir coverage @@ -108,6 +127,7 @@ jobs: docker run \ --rm \ + --platform=${{ matrix.platform }} \ --user pdf_service_user \ -v "$(pwd)/coverage:/usr/src/app/coverage/" \ mormahr/pdf-service:sha-${{ github.sha }}-testing \ @@ -134,14 +154,27 @@ jobs: needs: - build + strategy: + matrix: + platform: + - "linux/amd64" + - "linux/arm64" + - "linux/arm/v7" + steps: - name: Checkout code uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Run visual tests run: | cd e2e export TAG="sha-$GITHUB_SHA" + export PLATFORM="${{ matrix.platform }}" docker-compose build test docker-compose run --rm test diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index 0bca7dc5..5e09625a 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -2,6 +2,8 @@ version: "3.8" services: pdf: image: "mormahr/pdf-service:${TAG}" + platform: ${PLATFORM} + test: build: . links: From 5205273a66f19a453045eebf6e88f4de2c55dc40 Mon Sep 17 00:00:00 2001 From: Moritz Mahringer Date: Mon, 13 Sep 2021 19:39:26 +0200 Subject: [PATCH 2/3] Optimize QEMU platforms --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60bfcaa5..0153c0f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,7 +118,8 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@master with: - platforms: all + platforms: ${{ matrix.platform }} + if: ${{ matrix.platform != 'linux/amd64' }} - name: Run tests run: | @@ -168,7 +169,8 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@master with: - platforms: all + platforms: ${{ matrix.platform }} + if: ${{ matrix.platform != 'linux/amd64' }} - name: Run visual tests run: | From 41f3fdce73202284b96038712df8410d7de57955 Mon Sep 17 00:00:00 2001 From: Moritz Mahringer Date: Mon, 13 Sep 2021 19:48:24 +0200 Subject: [PATCH 3/3] Use shared e2e driver image --- .github/workflows/ci.yml | 55 +++++++++++++++++++++++++++++++++++++++- e2e/docker-compose.yml | 2 +- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0153c0f6..e5b8b09c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,6 +99,59 @@ jobs: target: testing platforms: linux/amd64,linux/arm64,linux/arm/v7 + build-e2e: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker meta (e2e) + id: docker_meta_testing + uses: docker/metadata-action@v3 + with: + images: mormahr/pdf-service + flavor: | + latest=false + suffix=-e2e + tags: | + type=ref,event=branch + type=ref,event=pr + type=edge,branch=main + type=sha,format=long + labels: | + org.opencontainers.image.vendor=Moritz Mahringer + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract branch name + shell: bash + run: | + BRANCH=${GITHUB_REF#refs/heads/} + SAFE_BRANCH=${BRANCH//\//_} + echo "##[set-output name=branch;]$(echo $SAFE_BRANCH)" + id: extract_branch + + - name: Build and push (e2e image) + uses: docker/build-push-action@v2 + with: + context: e2e + push: ${{ github.event_name != 'pull_request' }} + build-args: GITHUB_SHA=${{ github.sha }} + cache-from: | + type=registry,ref=mormahr/pdf-service:main-e2e + type=registry,ref=mormahr/pdf-service:${{ steps.extract_branch.outputs.branch }}-e2e + cache-to: type=inline + tags: ${{ steps.docker_meta_testing.outputs.tags }} + labels: ${{ steps.docker_meta_testing.outputs.labels }} + test: runs-on: ubuntu-20.04 needs: @@ -154,6 +207,7 @@ jobs: runs-on: ubuntu-20.04 needs: - build + - build-e2e strategy: matrix: @@ -177,7 +231,6 @@ jobs: cd e2e export TAG="sha-$GITHUB_SHA" export PLATFORM="${{ matrix.platform }}" - docker-compose build test docker-compose run --rm test tag: diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index 5e09625a..1025c827 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -5,6 +5,6 @@ services: platform: ${PLATFORM} test: - build: . + image: "mormahr/pdf-service:${TAG}-e2e" links: - "pdf:pdf"