Skip to content

Commit

Permalink
ci: Parallelize container build via matrix
Browse files Browse the repository at this point in the history
Not only speeds things up, also reduces very similar code. We just need
to align the image-tests folder names to the images to make a simple
mapping possible.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
jan-kiszka committed Mar 4, 2024
1 parent 3f6c0c9 commit 2a49f42
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 91 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
deploy_containers:
name: Build and deploy container images
runs-on: ubuntu-latest
strategy:
matrix:
image-name: ["kas", "kas-isar"]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand All @@ -27,28 +30,16 @@ jobs:
with:
deploy-user: ${{ secrets.PACKAGE_DEPLOY_USER }}
deploy-token: ${{ secrets.PACKAGE_DEPLOY_TOKEN }}
- name: Build kas image
- name: Build ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
if: ${{ env.PUSH_MASTER }}
with:
context: /home/runner/kas-clone
no-cache: true
target: ${{ matrix.image-name }}
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas
- name: Build kas-isar image
uses: docker/build-push-action@v5
if: ${{ env.PUSH_MASTER }}
with:
context: /home/runner/kas-clone
no-cache: true
target: kas-isar
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}
73 changes: 16 additions & 57 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
name: Build, test and deploy container images
needs: perform_tests
runs-on: ubuntu-latest
strategy:
matrix:
image-name: ["kas", "kas-isar"]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand All @@ -74,94 +77,50 @@ jobs:
deploy-user: ${{ secrets.PACKAGE_DEPLOY_USER }}
deploy-token: ${{ secrets.PACKAGE_DEPLOY_TOKEN }}

- name: Build amd64 kas image
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
no-cache: true
platforms: linux/amd64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas:next
- name: Test kas image
run: |
cd image-tests/poky
KAS_IMAGE_VERSION=next ../../kas-container build kas.yml
- name: Build arm64 kas image
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
no-cache: true
platforms: linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas:next
- name: Deploy kas images
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas:next

- name: Build amd64 kas-isar image
- name: Build amd64 ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
no-cache: true
target: kas-isar
target: ${{ matrix.image-name }}
platforms: linux/amd64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar:next
- name: Test kas-isar image
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}:next
- name: Test ${{ matrix.image-name }} image
run: |
cd image-tests/isar
cd image-tests/${{ matrix.image-name }}
KAS_IMAGE_VERSION=next ../../kas-container build kas.yml
- name: Build arm64 kas-isar image
- name: Build arm64 ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
no-cache: true
target: kas-isar
target: ${{ matrix.image-name }}
platforms: linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=docker,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar:next
- name: Deploy kas-isar images
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}:next
- name: Deploy ${{ matrix.image-name }} images
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
target: kas-isar
target: ${{ matrix.image-name }}
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: ghcr.io/siemens/kas/kas-isar:next
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}:next

- name: Purge oldest untagged kas images
uses: actions/delete-package-versions@v5
with:
package-name: kas/kas
package-type: container
min-versions-to-keep: 10
delete-only-untagged-versions: true
- name: Purge oldest untagged kas-isar images
- name: Purge oldest untagged ${{ matrix.image-name }} images
uses: actions/delete-package-versions@v5
with:
package-name: kas-isar
package-name: kas/${{ matrix.image-name }}
package-type: container
min-versions-to-keep: 10
delete-only-untagged-versions: true
27 changes: 8 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
deploy_containers:
name: Build and deploy container images
runs-on: ubuntu-latest
strategy:
matrix:
image-name: ["kas", "kas-isar"]
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand All @@ -19,32 +22,18 @@ jobs:
with:
deploy-user: ${{ secrets.PACKAGE_DEPLOY_USER }}
deploy-token: ${{ secrets.PACKAGE_DEPLOY_TOKEN }}
- name: Build kas image
- name: Build ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
no-cache: true
target: ${{ matrix.image-name }}
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: |
ghcr.io/siemens/kas/kas
ghcr.io/siemens/kas/kas:${{ env.RELEASE_VERSION }}
ghcr.io/siemens/kas/kas:latest-release
- name: Build kas-isar image
uses: docker/build-push-action@v5
with:
context: /home/runner/kas-clone
no-cache: true
target: kas-isar
platforms: linux/amd64,linux/arm64
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
outputs: type=registry,rewrite-timestamp=true
tags: |
ghcr.io/siemens/kas/kas-isar
ghcr.io/siemens/kas/kas-isar:${{ env.RELEASE_VERSION }}
ghcr.io/siemens/kas/kas-isar:latest-release
ghcr.io/siemens/kas/${{ matrix.image-name }}
ghcr.io/siemens/kas/${{ matrix.image-name }}:${{ env.RELEASE_VERSION }}
ghcr.io/siemens/kas/${{ matrix.image-name }}:latest-release
File renamed without changes.
File renamed without changes.

0 comments on commit 2a49f42

Please sign in to comment.