Skip to content

Commit fe09085

Browse files
committed
Reduce thrashing
1 parent 2cb7884 commit fe09085

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/actions/setup-go/action.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,30 @@ runs:
2323
cache: false
2424
go-version: ${{ inputs.version }}
2525

26-
- name: Cache go
26+
- name: Get cache dirs
27+
id: get_cache_dirs
28+
shell: bash
29+
run: |
30+
echo "::set-output name=go-mod-cache::$(go env GOMODCACHE)"
31+
echo "::set-output name=go-cache::$(go env GOCACHE)"
32+
# We split up GOMODCACHE from GOCACHE because the latter must be invalidated
33+
# on code change, but the former can be kept.
34+
- name: Cache $GOMODCACHE
35+
uses: buildjet/cache@v3
36+
with:
37+
path: |
38+
${{ steps.get_cache_dirs.outputs.go-mod-cache }}}
39+
key: gomodcache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
40+
restore-keys: |
41+
gomodcache-${{ runner.os }}-${{ github.job }}-
42+
gomodcache-${{ runner.os }}-
43+
gomodcache-
44+
45+
- name: Cache $GOCACHE
2746
uses: buildjet/cache@v3
2847
with:
29-
# ~/go/pkg is the same across operating systems.
3048
path: |
31-
~/go/pkg
32-
~/.cache/go-build
33-
~/AppData/Local/go-build
34-
~/Library/Caches/go-build
49+
${{ steps.get_cache_dirs.outputs.go-cache }}}
3550
# Job name must be included in the key for effective
3651
# test cache reuse.
3752
key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}

0 commit comments

Comments
 (0)