Skip to content

Commit 629eafd

Browse files
committed
ci: Parallelize container build via matrix
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 <[email protected]>
1 parent fd6d942 commit 629eafd

File tree

5 files changed

+26
-64
lines changed

5 files changed

+26
-64
lines changed

.github/workflows/master.yml

+6-14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
deploy_containers:
1010
name: Build and deploy container images
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
image-name: ["kas", "kas-isar"]
1215
steps:
1316
- name: Check out repo
1417
uses: actions/checkout@v4
@@ -27,26 +30,15 @@ jobs:
2730
with:
2831
deploy-user: ${{ secrets.PACKAGE_DEPLOY_USER }}
2932
deploy-token: ${{ secrets.PACKAGE_DEPLOY_TOKEN }}
30-
- name: Build kas image
33+
- name: Build ${{ matrix.image-name }} image
3134
uses: docker/build-push-action@v5
3235
if: ${{ env.PUSH_MASTER }}
3336
with:
3437
context: /home/runner/kas-clone
38+
target: ${{ matrix.image-name }}
3539
platforms: linux/amd64,linux/arm64
3640
build-args: |
3741
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
3842
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
3943
outputs: type=registry,rewrite-timestamp=true
40-
tags: ghcr.io/siemens/kas/kas
41-
- name: Build kas-isar image
42-
uses: docker/build-push-action@v5
43-
if: ${{ env.PUSH_MASTER }}
44-
with:
45-
context: /home/runner/kas-clone
46-
target: kas-isar
47-
platforms: linux/amd64,linux/arm64
48-
build-args: |
49-
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
50-
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
51-
outputs: type=registry,rewrite-timestamp=true
52-
tags: ghcr.io/siemens/kas/kas-isar
44+
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}

.github/workflows/next.yml

+12-32
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ jobs:
6565
name: Build, test and deploy container images
6666
needs: perform_tests
6767
runs-on: ubuntu-latest
68+
strategy:
69+
matrix:
70+
image-name: ["kas", "kas-isar"]
6871
steps:
6972
- name: Check out repo
7073
uses: actions/checkout@v4
@@ -74,52 +77,29 @@ jobs:
7477
deploy-user: ${{ secrets.PACKAGE_DEPLOY_USER }}
7578
deploy-token: ${{ secrets.PACKAGE_DEPLOY_TOKEN }}
7679

77-
- name: Build kas image
78-
uses: docker/build-push-action@v5
79-
with:
80-
context: /home/runner/kas-clone
81-
build-args: |
82-
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
83-
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
84-
outputs: type=docker,rewrite-timestamp=true
85-
tags: ghcr.io/siemens/kas/kas:next
86-
- name: Test kas image
87-
run: |
88-
cd image-tests/poky
89-
KAS_IMAGE_VERSION=next ../../kas-container build kas.yml
90-
- name: Complete build and deploy kas image
91-
uses: docker/build-push-action@v5
92-
with:
93-
context: /home/runner/kas-clone
94-
platforms: linux/amd64,linux/arm64
95-
build-args: |
96-
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
97-
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
98-
outputs: type=registry,rewrite-timestamp=true
99-
tags: ghcr.io/siemens/kas/kas:next
100-
101-
- name: Build kas-isar image
80+
- name: Build ${{ matrix.image-name }} image
10281
uses: docker/build-push-action@v5
10382
with:
10483
context: /home/runner/kas-clone
105-
target: kas-isar
84+
target: ${{ matrix.image-name }}
85+
platforms: linux/amd64
10686
build-args: |
10787
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
10888
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
10989
outputs: type=docker,rewrite-timestamp=true
110-
tags: ghcr.io/siemens/kas/kas-isar:next
111-
- name: Test kas-isar image
90+
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}:next
91+
- name: Test ${{ matrix.image-name }} image
11292
run: |
113-
cd image-tests/isar
93+
cd image-tests/${{ matrix.image-name }}
11494
KAS_IMAGE_VERSION=next ../../kas-container build kas.yml
115-
- name: Complete build and deploy kas-isar image
95+
- name: Complete build and deploy ${{ matrix.image-name }} image
11696
uses: docker/build-push-action@v5
11797
with:
11898
context: /home/runner/kas-clone
119-
target: kas-isar
99+
target: ${{ matrix.image-name }}
120100
platforms: linux/amd64,linux/arm64
121101
build-args: |
122102
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
123103
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
124104
outputs: type=registry,rewrite-timestamp=true
125-
tags: ghcr.io/siemens/kas/kas-isar:next
105+
tags: ghcr.io/siemens/kas/${{ matrix.image-name }}:next

.github/workflows/release.yml

+8-18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
deploy_containers:
1010
name: Build and deploy container images
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
image-name: ["kas", "kas-isar"]
1215
steps:
1316
- name: Check out repo
1417
uses: actions/checkout@v4
@@ -19,30 +22,17 @@ jobs:
1922
with:
2023
deploy-user: ${{ secrets.PACKAGE_DEPLOY_USER }}
2124
deploy-token: ${{ secrets.PACKAGE_DEPLOY_TOKEN }}
22-
- name: Build kas image
25+
- name: Build ${{ matrix.image-name }} image
2326
uses: docker/build-push-action@v5
2427
with:
2528
context: /home/runner/kas-clone
29+
target: ${{ matrix.image-name }}
2630
platforms: linux/amd64,linux/arm64
2731
build-args: |
2832
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
2933
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
3034
outputs: type=registry,rewrite-timestamp=true
3135
tags: |
32-
ghcr.io/siemens/kas/kas
33-
ghcr.io/siemens/kas/kas:${{ env.RELEASE_VERSION }}
34-
ghcr.io/siemens/kas/kas:latest-release
35-
- name: Build kas-isar image
36-
uses: docker/build-push-action@v5
37-
with:
38-
context: /home/runner/kas-clone
39-
target: kas-isar
40-
platforms: linux/amd64,linux/arm64
41-
build-args: |
42-
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
43-
DEBIAN_TAG=${{ env.DEBIAN_TAG }}
44-
outputs: type=registry,rewrite-timestamp=true
45-
tags: |
46-
ghcr.io/siemens/kas/kas-isar
47-
ghcr.io/siemens/kas/kas-isar:${{ env.RELEASE_VERSION }}
48-
ghcr.io/siemens/kas/kas-isar:latest-release
36+
ghcr.io/siemens/kas/${{ matrix.image-name }}
37+
ghcr.io/siemens/kas/${{ matrix.image-name }}:${{ env.RELEASE_VERSION }}
38+
ghcr.io/siemens/kas/${{ matrix.image-name }}:latest-release
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)