Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8441db5

Browse files
committed
chore: Improve CI builds by caching Go modules
1 parent c451f4e commit 8441db5

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

.github/workflows/coder.yaml

+35-21
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,28 @@ jobs:
135135
with:
136136
go-version: "^1.17"
137137

138-
- uses: actions/cache@v3
138+
- id: go-cache-paths
139+
run: |
140+
echo "::set-output name=go-build::$(go env GOCACHE)"
141+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
142+
143+
- name: Go Build Cache
144+
uses: actions/cache@v3
139145
with:
140-
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
141-
path: |
142-
~/go/pkg/mod
143-
~/.cache/go-build
144-
~/Library/Caches/go-build
145-
%LocalAppData%\go-build
146-
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
147-
restore-keys: |
148-
${{ matrix.os }}-go-
146+
path: ${{ steps.go-cache-paths.outputs.go-build }}
147+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
149148

150-
- run: go install gotest.tools/gotestsum@latest
149+
- name: Go Mod Cache
150+
uses: actions/cache@v3
151+
with:
152+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
153+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
154+
155+
- name: Install goreleaser
156+
uses: jaxxstorm/[email protected]
157+
with:
158+
repo: goreleaser/goreleaser
159+
tag: v1.7.0
151160

152161
- uses: hashicorp/setup-terraform@v1
153162
with:
@@ -339,17 +348,22 @@ jobs:
339348
with:
340349
install-only: true
341350

342-
- uses: actions/cache@v3
351+
- id: go-cache-paths
352+
run: |
353+
echo "::set-output name=go-build::$(go env GOCACHE)"
354+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
355+
356+
- name: Go Build Cache
357+
uses: actions/cache@v3
343358
with:
344-
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
345-
path: |
346-
~/go/pkg/mod
347-
~/.cache/go-build
348-
~/Library/Caches/go-build
349-
%LocalAppData%\go-build
350-
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
351-
restore-keys: |
352-
${{ matrix.os }}-go-
359+
path: ${{ steps.go-cache-paths.outputs.go-build }}
360+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
361+
362+
- name: Go Mod Cache
363+
uses: actions/cache@v3
364+
with:
365+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
366+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
353367

354368
- run: make build
355369

0 commit comments

Comments
 (0)