Skip to content

Commit 28be07e

Browse files
committed
ci: add KOCACHE to speed up ko builds in GitHub Actions
Port KOCACHE optimization from pipelines-as-code to tektoncd/pipeline. This caches ko layer metadata between workflow runs, avoiding redundant compression and speeding up builds on cache hits. Changes: - ci.yaml: Add KOCACHE to multi-arch-build job - e2e-matrix.yml: Add KOCACHE to e2e-tests job (with arch in cache key) - e2e-matrix-extras.yaml: Add KOCACHE to e2e-extras job Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent 0133513 commit 28be07e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,20 @@ jobs:
151151
needs: [build]
152152
name: Multi-arch build
153153
runs-on: ubuntu-latest
154+
env:
155+
KOCACHE: /tmp/ko-cache
154156
steps:
155157
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
156158
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
157159
with:
158160
go-version-file: "go.mod"
161+
- name: Cache ko build cache
162+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
163+
with:
164+
path: /tmp/ko-cache
165+
key: ${{ runner.os }}-${{ runner.arch }}-ko-${{ hashFiles('go.sum') }}
166+
restore-keys: |
167+
${{ runner.os }}-${{ runner.arch }}-ko-
159168
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
160169
- name: ko-resolve
161170
run: |

.github/workflows/e2e-matrix-extras.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ jobs:
9494
KO_DOCKER_REPO: registry.local:5000/tekton
9595
CLUSTER_DOMAIN: c${{ github.run_id }}.local
9696
ARTIFACTS: ${{ github.workspace }}/artifacts
97+
KOCACHE: /tmp/ko-cache
9798
steps:
9899
- name: Report tests check
99100
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
@@ -116,6 +117,13 @@ jobs:
116117
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
117118
with:
118119
go-version-file: "go.mod"
120+
- name: Cache ko build cache
121+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
122+
with:
123+
path: /tmp/ko-cache
124+
key: ${{ runner.os }}-${{ runner.arch }}-ko-${{ hashFiles('go.sum') }}
125+
restore-keys: |
126+
${{ runner.os }}-${{ runner.arch }}-ko-
119127
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
120128

121129
- name: Install Dependencies

.github/workflows/e2e-matrix.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
KO_DOCKER_REPO: registry.local:5000/tekton
5151
CLUSTER_DOMAIN: c${{ github.run_id }}.local
5252
ARTIFACTS: ${{ github.workspace }}/artifacts
53+
KOCACHE: /tmp/ko-cache
5354

5455
steps:
5556
- name: Free disk space
@@ -68,6 +69,13 @@ jobs:
6869
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
6970
with:
7071
go-version-file: "go.mod"
72+
- name: Cache ko build cache
73+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
74+
with:
75+
path: /tmp/ko-cache
76+
key: ${{ runner.os }}-${{ runner.arch }}-ko-${{ hashFiles('go.sum') }}
77+
restore-keys: |
78+
${{ runner.os }}-${{ runner.arch }}-ko-
7179
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
7280

7381
- name: Install Dependencies

0 commit comments

Comments
 (0)