diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55cb3cebb5..b9b360e100 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,10 @@ jobs: run: | echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT && \ echo "mod_cache=$(make go.mod.cachedir)" >> $GITHUB_OUTPUT && \ - echo "analysis_cache=$HOME/.cache/golangci-lint" >> $GITHUB_OUTPUT + echo "analysis_cache=$HOME/.cache/golangci-lint" >> $GITHUB_OUTPUT && \ + echo "analysis_cache_key=$(make go.lint.analysiskey)" >> $GITHUB_OUTPUT && \ + echo "analysis_cache_key_int=$(make go.lint.analysiskey-interval)" >> $GITHUB_OUTPUT + - name: Cache the Go Build Cache uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 @@ -72,8 +75,9 @@ jobs: uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 with: path: ${{ steps.go_cache.outputs.analysis_cache }} - key: ${{ runner.os }}-analysis-lint-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-analysis-lint- + key: ${{ steps.go_cache.outputs.analysis_cache_key }} + restore-keys: | + ${{ steps.go_cache.outputs.analysis_cache_key_int }} - name: Vendor Dependencies run: make vendor vendor.check diff --git a/Makefile b/Makefile index 36cfb403ab..88af93c764 100644 --- a/Makefile +++ b/Makefile @@ -312,7 +312,13 @@ go.cachedir: go.mod.cachedir: @go env GOMODCACHE -.PHONY: cobertura reviewable submodules fallthrough go.mod.cachedir go.cachedir run crds.clean $(TERRAFORM_PROVIDER_SCHEMA) +go.lint.analysiskey-interval: + @echo golangci-lint.cache-$$(( $$(date +%s) / 604800 ))- + +go.lint.analysiskey: + @echo $$(make go.lint.analysiskey-interval)$$(sha1sum go.mod | cut -d' ' -f1) + +.PHONY: cobertura reviewable submodules fallthrough go.mod.cachedir go.cachedir go.lint.analysiskey-interval go.lint.analysiskey run crds.clean $(TERRAFORM_PROVIDER_SCHEMA) build.init: kustomize-crds