add build cache to actions (#339)

This commit is contained in:
Ahmet Alp Balkan
2021-12-26 21:50:17 -08:00
committed by GitHub
parent 60523045a5
commit 617e4f0562
3 changed files with 17 additions and 2 deletions

View File

@@ -26,6 +26,20 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.17
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Ensure gofmt
run: test -z "$(gofmt -s -d .)"
- name: Ensure go.mod is already tidied