Skip to content

Commit 2635a27

Browse files
jakobmoellerdevhilmarf
authored andcommitted
chore: fixup all go setups with manual cache keys (#960)
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it actions/setup-go#358 #### Which issue(s) this PR fixes <!-- Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Allows atomic build caches per job that actually dont overwrite each other Co-authored-by: Hilmar Falkenberg <[email protected]>
1 parent ed9537f commit 2635a27

9 files changed

+261
-0
lines changed

.github/workflows/buildcomponents.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ jobs:
2828
uses: actions/setup-go@v5
2929
with:
3030
go-version-file: '${{ github.workspace }}/go.mod'
31+
cache: false
32+
33+
- name: Get go environment for use with cache
34+
run: |
35+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
36+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
37+
- name: Set up cache
38+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
${{ env.go_cache }}
43+
${{ env.go_modcache }}
44+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
45+
restore-keys: |
46+
${{ env.cache_name }}-${{ runner.os }}-go-
47+
env:
48+
cache_name: buildcomponents-go-cache
3149

3250
- name: Push OCM Components
3351
if: inputs.ocm_push == true

.github/workflows/check_diff_action.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ jobs:
1515
uses: actions/setup-go@v5
1616
with:
1717
go-version-file: '${{ github.workspace }}/go.mod'
18+
cache: false
19+
20+
- name: Get go environment for use with cache
21+
run: |
22+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
23+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
24+
- name: Set up cache
25+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
${{ env.go_cache }}
30+
${{ env.go_modcache }}
31+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
32+
restore-keys: |
33+
${{ env.cache_name }}-${{ runner.os }}-go-
34+
env:
35+
cache_name: diff-check-go-cache
36+
1837
- name: Make generate and deepcopy
1938
run: |
2039
make -f hack/Makefile mdref && make -f hack/Makefile go-bindata && make generate && make generate-deepcopy

.github/workflows/components.yaml

+95
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ jobs:
2222
uses: actions/setup-go@v5
2323
with:
2424
go-version-file: '${{ github.workspace }}/go.mod'
25+
cache: false
26+
27+
- name: Get go environment for use with cache
28+
run: |
29+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
30+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
31+
- name: Set up cache
32+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
${{ env.go_cache }}
37+
${{ env.go_modcache }}
38+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
39+
restore-keys: |
40+
${{ env.cache_name }}-${{ runner.os }}-go-
41+
env:
42+
cache_name: cli-go-cache
43+
2544
- name: CTF
2645
run: |
2746
cd components/ocmcli
@@ -37,6 +56,25 @@ jobs:
3756
uses: actions/setup-go@v5
3857
with:
3958
go-version-file: '${{ github.workspace }}/go.mod'
59+
cache: false
60+
61+
- name: Get go environment for use with cache
62+
run: |
63+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
64+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
65+
- name: Set up cache
66+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
67+
uses: actions/cache@v4
68+
with:
69+
path: |
70+
${{ env.go_cache }}
71+
${{ env.go_modcache }}
72+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
73+
restore-keys: |
74+
${{ env.cache_name }}-${{ runner.os }}-go-
75+
env:
76+
cache_name: helminstaller-go-cache
77+
4078
- name: CTF
4179
run: |
4280
cd components/helminstaller
@@ -52,6 +90,25 @@ jobs:
5290
uses: actions/setup-go@v5
5391
with:
5492
go-version-file: '${{ github.workspace }}/go.mod'
93+
cache: false
94+
95+
- name: Get go environment for use with cache
96+
run: |
97+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
98+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
99+
- name: Set up cache
100+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
101+
uses: actions/cache@v4
102+
with:
103+
path: |
104+
${{ env.go_cache }}
105+
${{ env.go_modcache }}
106+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
107+
restore-keys: |
108+
${{ env.cache_name }}-${{ runner.os }}-go-
109+
env:
110+
cache_name: helmdemo-go-cache
111+
55112
- name: CTF
56113
run: |
57114
cd components/helmdemo
@@ -67,6 +124,25 @@ jobs:
67124
uses: actions/setup-go@v5
68125
with:
69126
go-version-file: '${{ github.workspace }}/go.mod'
127+
cache: false
128+
129+
- name: Get go environment for use with cache
130+
run: |
131+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
132+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
133+
- name: Set up cache
134+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
135+
uses: actions/cache@v4
136+
with:
137+
path: |
138+
${{ env.go_cache }}
139+
${{ env.go_modcache }}
140+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
141+
restore-keys: |
142+
${{ env.cache_name }}-${{ runner.os }}-go-
143+
env:
144+
cache_name: helm-subchart-go-cache
145+
70146
- name: CTF
71147
run: |
72148
cd components/subchartsdemo
@@ -85,6 +161,25 @@ jobs:
85161
uses: actions/setup-go@v5
86162
with:
87163
go-version-file: '${{ github.workspace }}/go.mod'
164+
cache: false
165+
166+
- name: Get go environment for use with cache
167+
run: |
168+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
169+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
170+
- name: Set up cache
171+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
172+
uses: actions/cache@v4
173+
with:
174+
path: |
175+
${{ env.go_cache }}
176+
${{ env.go_modcache }}
177+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
178+
restore-keys: |
179+
${{ env.cache_name }}-${{ runner.os }}-go-
180+
env:
181+
cache_name: ecr-plugin-go-cache
182+
88183
- name: CTF
89184
run: |
90185
cd components/ecrplugin

.github/workflows/lint_and_test.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ jobs:
2424
uses: actions/setup-go@v5
2525
with:
2626
go-version-file: '${{ github.workspace }}/go.mod'
27+
cache: false
28+
29+
- name: Get go environment for use with cache
30+
run: |
31+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
32+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
33+
- name: Set up cache
34+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
${{ env.go_cache }}
39+
${{ env.go_modcache }}
40+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
41+
restore-keys: |
42+
${{ env.cache_name }}-${{ runner.os }}-go-
43+
env:
44+
cache_name: run-tests-go-cache
45+
2746
- name: Test
2847
run: |
2948
PATH=$PATH:$(go env GOPATH)/bin make build install-requirements test
@@ -40,6 +59,25 @@ jobs:
4059
uses: actions/setup-go@v5
4160
with:
4261
go-version-file: '${{ github.workspace }}/go.mod'
62+
cache: false
63+
64+
- name: Get go environment for use with cache
65+
run: |
66+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
67+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
68+
- name: Set up cache
69+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
${{ env.go_cache }}
74+
${{ env.go_modcache }}
75+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
76+
restore-keys: |
77+
${{ env.cache_name }}-${{ runner.os }}-go-
78+
env:
79+
cache_name: golint-go-cache
80+
4381
- name: Install goimports
4482
run: |
4583
go install golang.org/x/tools/cmd/goimports@latest

.github/workflows/mend_scan.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ jobs:
4040
uses: actions/setup-go@v5
4141
with:
4242
go-version-file: '${{ github.workspace }}/go.mod'
43+
cache: false
44+
45+
- name: Get go environment for use with cache
46+
run: |
47+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
48+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
49+
- name: Set up cache
50+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
51+
uses: actions/cache@v4
52+
with:
53+
path: |
54+
${{ env.go_cache }}
55+
${{ env.go_modcache }}
56+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
57+
restore-keys: |
58+
${{ env.cache_name }}-${{ runner.os }}-go-
59+
env:
60+
cache_name: mend-scan-go-cache
4361

4462
- name: 'Setup jq'
4563
uses: dcarbone/[email protected]

.github/workflows/push_ocm.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,25 @@ jobs:
101101
with:
102102
go-version-file: '${{ github.workspace }}/go.mod'
103103
check-latest: false
104+
cache: false
105+
106+
- name: Get go environment for use with cache
107+
run: |
108+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
109+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
110+
- name: Set up cache
111+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
112+
uses: actions/cache@v4
113+
with:
114+
path: |
115+
${{ env.go_cache }}
116+
${{ env.go_modcache }}
117+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
118+
restore-keys: |
119+
${{ env.cache_name }}-${{ runner.os }}-go-
120+
env:
121+
cache_name: ocm-cli-latest-go-cache
122+
104123
- name: Goreleaser release snapshot
105124
uses: goreleaser/goreleaser-action@v6
106125
with:

.github/workflows/release-drafter.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ jobs:
2323
uses: actions/setup-go@v5
2424
with:
2525
go-version-file: '${{ github.workspace }}/go.mod'
26+
cache: false
27+
28+
- name: Get go environment for use with cache
29+
run: |
30+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
31+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
32+
- name: Set up cache
33+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
${{ env.go_cache }}
38+
${{ env.go_modcache }}
39+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
40+
restore-keys: |
41+
${{ env.cache_name }}-${{ runner.os }}-go-
42+
env:
43+
cache_name: release-draft-go-cache
2644

2745
- name: Set Version
2846
run: |

.github/workflows/release.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ jobs:
148148
with:
149149
go-version-file: '${{ github.workspace }}/go.mod'
150150
check-latest: false
151+
cache: false
152+
153+
- name: Get go environment for use with cache
154+
run: |
155+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
156+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
157+
- name: Set up cache
158+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
159+
uses: actions/cache@v4
160+
with:
161+
path: |
162+
${{ env.go_cache }}
163+
${{ env.go_modcache }}
164+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
165+
restore-keys: |
166+
${{ env.cache_name }}-${{ runner.os }}-go-
167+
env:
168+
cache_name: release-go-cache
151169

152170
- name: Setup Syft
153171
uses: anchore/sbom-action/download-syft@f5e124a5e5e1d497a692818ae907d3c45829d033 # v0.17.3

.github/workflows/releasenotes.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ jobs:
2121
uses: actions/setup-go@v5
2222
with:
2323
go-version-file: '${{ github.workspace }}/go.mod'
24+
cache: false
25+
26+
- name: Get go environment for use with cache
27+
run: |
28+
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
29+
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
30+
- name: Set up cache
31+
# https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
${{ env.go_cache }}
36+
${{ env.go_modcache }}
37+
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
38+
restore-keys: |
39+
${{ env.cache_name }}-${{ runner.os }}-go-
40+
env:
41+
cache_name: releasenotes-go-cache
2442

2543
- name: Setup git config
2644
run: |

0 commit comments

Comments
 (0)