From ecdfbbc1a8210ce639ae29c33842c443bca750f4 Mon Sep 17 00:00:00 2001 From: Danny Date: Fri, 15 Jul 2022 16:54:24 -0400 Subject: [PATCH] CI Cache Implementation (#354) Caching adding for build and mods. Significantly improves CI `go test -v ./...`. --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 562cebebd..7bf3e3f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,9 +27,33 @@ jobs: with: go-version: 1.18 + - name: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + - name: Cache Go build + uses: actions/cache@v3 + id: mybuild + with: + path: ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + - name: Cache Go Mod + uses: actions/cache@v3 + id: cache + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + - name: Run go mod download + if: steps.cache.outputs.cache-hit != 'true' run: go mod download + - name: Go build + if: steps.mybuild.outputs.cache-hit != 'true' + run: go build ./... + - name: Get go-licenses run: go install github.com/google/go-licenses@latest