From b2d636472ddffed3747fa30f21500613f4a8c268 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Tue, 15 Oct 2024 10:09:14 +0200 Subject: [PATCH] chore: fixup all go setups with manual cache keys --- .github/workflows/buildcomponents.yaml | 18 +++++ .github/workflows/check_diff_action.yaml | 19 +++++ .github/workflows/components.yaml | 95 ++++++++++++++++++++++++ .github/workflows/lint_and_test.yaml | 38 ++++++++++ .github/workflows/mend_scan.yaml | 18 +++++ .github/workflows/push_ocm.yaml | 19 +++++ .github/workflows/release-drafter.yaml | 18 +++++ .github/workflows/release.yaml | 18 +++++ .github/workflows/releasenotes.yaml | 18 +++++ 9 files changed, 261 insertions(+) diff --git a/.github/workflows/buildcomponents.yaml b/.github/workflows/buildcomponents.yaml index c99bd4ceee..d86805b513 100644 --- a/.github/workflows/buildcomponents.yaml +++ b/.github/workflows/buildcomponents.yaml @@ -28,6 +28,24 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: buildcomponents-go-cache - name: Push OCM Components if: inputs.ocm_push == true diff --git a/.github/workflows/check_diff_action.yaml b/.github/workflows/check_diff_action.yaml index d74b68b66f..d3439e427c 100644 --- a/.github/workflows/check_diff_action.yaml +++ b/.github/workflows/check_diff_action.yaml @@ -15,6 +15,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: diff-check-go-cache + - name: Make generate and deepcopy run: | make -f hack/Makefile mdref && make -f hack/Makefile go-bindata && make generate && make generate-deepcopy diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index 29d8882013..88958fc9ed 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -22,6 +22,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: cli-go-cache + - name: CTF run: | cd components/ocmcli @@ -37,6 +56,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: helminstaller-go-cache + - name: CTF run: | cd components/helminstaller @@ -52,6 +90,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: helmdemo-go-cache + - name: CTF run: | cd components/helmdemo @@ -67,6 +124,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: helm-subchart-go-cache + - name: CTF run: | cd components/subchartsdemo @@ -85,6 +161,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: ecr-plugin-go-cache + - name: CTF run: | cd components/ecrplugin diff --git a/.github/workflows/lint_and_test.yaml b/.github/workflows/lint_and_test.yaml index d638fd8157..a728855768 100644 --- a/.github/workflows/lint_and_test.yaml +++ b/.github/workflows/lint_and_test.yaml @@ -24,6 +24,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: run-tests-go-cache + - name: Test run: make build install-requirements test @@ -39,6 +58,25 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: golint-go-cache + - name: Install goimports run: go install golang.org/x/tools/cmd/goimports@latest - name: Lint diff --git a/.github/workflows/mend_scan.yaml b/.github/workflows/mend_scan.yaml index 4e95efa57a..2de6a8063c 100644 --- a/.github/workflows/mend_scan.yaml +++ b/.github/workflows/mend_scan.yaml @@ -40,6 +40,24 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: mend-scan-go-cache - name: 'Setup jq' uses: dcarbone/install-jq-action@v2.1.0 diff --git a/.github/workflows/push_ocm.yaml b/.github/workflows/push_ocm.yaml index 77f38cd5ec..3288ef1877 100644 --- a/.github/workflows/push_ocm.yaml +++ b/.github/workflows/push_ocm.yaml @@ -101,6 +101,25 @@ jobs: with: go-version-file: '${{ github.workspace }}/go.mod' check-latest: false + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: ocm-cli-latest-go-cache + - name: Goreleaser release snapshot uses: goreleaser/goreleaser-action@v6 with: diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml index 52627911a4..efa4b7c86c 100644 --- a/.github/workflows/release-drafter.yaml +++ b/.github/workflows/release-drafter.yaml @@ -23,6 +23,24 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: release-draft-go-cache - name: Set Version run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 78d0beaa0a..3f29c6d49d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -148,6 +148,24 @@ jobs: with: go-version-file: '${{ github.workspace }}/go.mod' check-latest: false + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: release-go-cache - name: Setup Syft uses: anchore/sbom-action/download-syft@f5e124a5e5e1d497a692818ae907d3c45829d033 # v0.17.3 diff --git a/.github/workflows/releasenotes.yaml b/.github/workflows/releasenotes.yaml index d20a5e43bd..9988dd047c 100644 --- a/.github/workflows/releasenotes.yaml +++ b/.github/workflows/releasenotes.yaml @@ -21,6 +21,24 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: '${{ github.workspace }}/go.mod' + cache: false + + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + - name: Set up cache + # https://github.com/actions/setup-go/issues/358 - cache is not working with setup-go for multiple jobs + uses: actions/cache@v4 + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: releasenotes-go-cache - name: Setup git config run: |