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

Skip to content

Commit 642e4ba

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

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

.github/workflows/coder.yaml

+37-21
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,30 @@ 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+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
with:
160+
repo: gotestyourself/gotestsum
161+
tag: v1.7.0
151162

152163
- uses: hashicorp/setup-terraform@v1
153164
with:
@@ -339,17 +350,22 @@ jobs:
339350
with:
340351
install-only: true
341352

342-
- uses: actions/cache@v3
353+
- id: go-cache-paths
354+
run: |
355+
echo "::set-output name=go-build::$(go env GOCACHE)"
356+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
357+
358+
- name: Go Build Cache
359+
uses: actions/cache@v3
343360
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-
361+
path: ${{ steps.go-cache-paths.outputs.go-build }}
362+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
363+
364+
- name: Go Mod Cache
365+
uses: actions/cache@v3
366+
with:
367+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
368+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
353369

354370
- run: make build
355371

0 commit comments

Comments
 (0)