Skip to content

Commit ddd258d

Browse files
committed
setup_go_with_cache: migrate from actions/setup-go
Signed-off-by: Norio Nomura <[email protected]>
1 parent 7cfcddd commit ddd258d

File tree

3 files changed

+16
-36
lines changed

3 files changed

+16
-36
lines changed

.github/actions/setup_cache_for_go/action.yml renamed to .github/actions/setup_go_with_cache/action.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: setup cache for go
2-
description: setup cache for go. export GOMODCACHE environment variable
1+
name: setup go with cache
2+
description: setup go with cache. export GOMODCACHE environment variable
33
inputs:
44
go-version:
55
description: go version
@@ -13,6 +13,11 @@ inputs:
1313
runs:
1414
using: "composite"
1515
steps:
16+
- id: setup-go
17+
uses: actions/setup-go@v5
18+
with:
19+
cache: false
20+
go-version: ${{ inputs.go-version }}
1621
- name: Set GOMODCACHE environment variable
1722
run: echo "GOMODCACHE=$(pwd)/.gomodcache" >> $GITHUB_ENV
1823
shell: bash
@@ -27,18 +32,18 @@ runs:
2732
uses: actions/cache@v4
2833
with:
2934
path: .gomodcache
30-
key: go-modcache-${{ inputs.working-directory }}-${{ inputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }}
35+
key: go-modcache-${{ inputs.working-directory }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }}
3136
restore-keys: |
32-
go-modcache-${{ inputs.working-directory }}-${{ inputs.go-version }}-
37+
go-modcache-${{ inputs.working-directory }}-${{ steps.setup-go.outputs.go-version }}-
3338
go-modcache-${{ inputs.working-directory }}-
3439
enableCrossOsArchive: true
3540
- name: Cache go build cache
3641
uses: actions/cache@v4
3742
with:
3843
path: ${{ steps.go-env.outputs.GOCACHE }}
39-
key: go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }}
44+
key: go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }}
4045
restore-keys: |
41-
go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.go-version }}-
46+
go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ steps.setup-go.outputs.go-version }}-
4247
go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-
4348
go-cache-${{ inputs.working-directory }}-
4449
- name: Download dependencies

.github/workflows/build.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,9 @@ jobs:
2929
- uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 0
32-
- id: setup-go
33-
uses: actions/setup-go@v5
32+
- uses: ./.github/actions/setup_go_with_cache
3433
with:
35-
cache: false
3634
go-version: ${{ inputs.go-version }}
37-
- uses: ./.github/actions/setup_cache_for_go
38-
with:
39-
go-version: ${{ steps.setup-go.outputs.go-version }}
4035
runs-on: ${{ inputs.runs-on }}
4136
- name: Make
4237
run: make

.github/workflows/test.yml

+4-24
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,9 @@ jobs:
8181
- uses: actions/checkout@v4
8282
with:
8383
fetch-depth: 1
84-
- id: setup-go
85-
uses: actions/setup-go@v5
84+
- uses: ./.github/actions/setup_go_with_cache
8685
with:
87-
cache: false
8886
go-version: ${{ matrix.go-version }}
89-
- uses: ./.github/actions/setup_cache_for_go
90-
with:
91-
go-version: ${{ steps.setup-go.outputs.go-version }}
9287
runs-on: ubuntu-24.04
9388
- name: Unit tests
9489
run: go test -v ./...
@@ -167,14 +162,9 @@ jobs:
167162
- uses: actions/checkout@v4
168163
with:
169164
fetch-depth: 1
170-
- id: setup-go
171-
uses: actions/setup-go@v5
165+
- uses: ./.github/actions/setup_go_with_cache
172166
with:
173-
cache: false
174167
go-version: 1.23.x
175-
- uses: ./.github/actions/setup_cache_for_go
176-
with:
177-
go-version: ${{ steps.setup-go.outputs.go-version }}
178168
runs-on: macos-12
179169
- name: Unit tests
180170
run: go test -v ./...
@@ -312,14 +302,9 @@ jobs:
312302
repository: abiosoft/colima
313303
ref: ${{ matrix.colima-version }}
314304
path: colima
315-
- id: setup-go
316-
uses: actions/setup-go@v5
305+
- uses: ./.github/actions/setup_go_with_cache
317306
with:
318-
cache: false
319307
go-version: 1.23.x
320-
- uses: ./.github/actions/setup_cache_for_go
321-
with:
322-
go-version: ${{ steps.setup-go.outputs.go-version }}
323308
runs-on: macos-12
324309
working-directory: ./colima
325310
- name: Install colima
@@ -405,14 +390,9 @@ jobs:
405390
- uses: actions/checkout@v4
406391
with:
407392
fetch-depth: 0
408-
- id: setup-go
409-
uses: actions/setup-go@v5
393+
- uses: ./.github/actions/setup_go_with_cache
410394
with:
411-
cache: false
412395
go-version: 1.23.x
413-
- uses: ./.github/actions/setup_cache_for_go
414-
with:
415-
go-version: ${{ steps.setup-go.outputs.go-version }}
416396
runs-on: macos-12
417397
- name: Cache image used by ${{ matrix.oldver }}/examples/ubuntu-lts.yaml
418398
uses: ./.github/actions/setup_cache_for_template

0 commit comments

Comments
 (0)