Skip to content

ci: improve Go caching #7954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reduce thrashing
  • Loading branch information
ammario committed Jun 10, 2023
commit fe090853e1a759bbc9c67ff4c7e379e57f336e51
27 changes: 21 additions & 6 deletions .github/actions/setup-go/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,30 @@ runs:
cache: false
go-version: ${{ inputs.version }}

- name: Cache go
- name: Get cache dirs
id: get_cache_dirs
shell: bash
run: |
echo "::set-output name=go-mod-cache::$(go env GOMODCACHE)"
echo "::set-output name=go-cache::$(go env GOCACHE)"
# We split up GOMODCACHE from GOCACHE because the latter must be invalidated
# on code change, but the former can be kept.
- name: Cache $GOMODCACHE
uses: buildjet/cache@v3
with:
path: |
${{ steps.get_cache_dirs.outputs.go-mod-cache }}}
key: gomodcache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
gomodcache-${{ runner.os }}-${{ github.job }}-
gomodcache-${{ runner.os }}-
gomodcache-

- name: Cache $GOCACHE
uses: buildjet/cache@v3
with:
# ~/go/pkg is the same across operating systems.
path: |
~/go/pkg
~/.cache/go-build
~/AppData/Local/go-build
~/Library/Caches/go-build
${{ steps.get_cache_dirs.outputs.go-cache }}}
# Job name must be included in the key for effective
# test cache reuse.
key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
Expand Down