From 483b42e8cc3eb63745b0d48d9822659dc4400ef2 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 28 Apr 2026 13:56:00 +0200 Subject: [PATCH] fix(ci): redirect Go caches to a per-job temp dir Self-hosted runners persist `$GOMODCACHE` (`/data/gh-home/go/pkg/mod`) across jobs, so the `actions/setup-go` cache restore extracts a tarball on top of files that already exist and emits hundreds of `tar: Cannot open: File exists` lines before bailing out with `Failed to restore`. The build still succeeds because the on-disk modules are reused, but the log noise is alarming and the ~500 MB cache download is wasted. Set `GOMODCACHE` and `GOCACHE` to `${{ runner.temp }}/go/...` before each `setup-go` invocation so the cache always lands in an empty, job-scoped directory. Behaviour on GitHub-hosted runners is unchanged; self-hosted runners stop colliding without losing the GHA cache. --- .github/actions/build-benchmark-genesis/action.yaml | 9 +++++++++ .github/actions/build-evm-client/geth/action.yaml | 9 +++++++++ .github/workflows/hive-consume.yaml | 8 ++++++++ .github/workflows/hive-execute.yaml | 8 ++++++++ 4 files changed, 34 insertions(+) diff --git a/.github/actions/build-benchmark-genesis/action.yaml b/.github/actions/build-benchmark-genesis/action.yaml index 1838ed22c91..81d35d6c3c7 100644 --- a/.github/actions/build-benchmark-genesis/action.yaml +++ b/.github/actions/build-benchmark-genesis/action.yaml @@ -18,6 +18,15 @@ runs: ref: master path: hive + # Redirect Go's module/build caches to a per-job temp dir so the + # actions/setup-go cache restore extracts into an empty target. On + # self-hosted runners $GOMODCACHE persists across jobs and would + # otherwise collide with the cache tarball ("File exists" from tar). + - name: Use ephemeral Go cache dirs + shell: bash + run: | + echo "GOMODCACHE=${{ runner.temp }}/go/mod" >> "$GITHUB_ENV" + echo "GOCACHE=${{ runner.temp }}/go/build" >> "$GITHUB_ENV" - name: Setup Go for Hive uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 with: diff --git a/.github/actions/build-evm-client/geth/action.yaml b/.github/actions/build-evm-client/geth/action.yaml index 8dd39d43254..7770f0192c1 100644 --- a/.github/actions/build-evm-client/geth/action.yaml +++ b/.github/actions/build-evm-client/geth/action.yaml @@ -42,6 +42,15 @@ runs: repository: ${{ inputs.repo }} ref: ${{ steps.geth-sha.outputs.sha }} path: go-ethereum + # See note in build-benchmark-genesis/action.yaml: redirect Go caches + # to a per-job temp dir so setup-go's cache restore doesn't collide + # with a persistent $GOMODCACHE on self-hosted runners. + - name: Use ephemeral Go cache dirs + if: steps.cache-restore.outputs.cache-hit != 'true' + shell: bash + run: | + echo "GOMODCACHE=${{ runner.temp }}/go/mod" >> "$GITHUB_ENV" + echo "GOCACHE=${{ runner.temp }}/go/build" >> "$GITHUB_ENV" - name: Setup golang if: steps.cache-restore.outputs.cache-hit != 'true' uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 diff --git a/.github/workflows/hive-consume.yaml b/.github/workflows/hive-consume.yaml index d57778086f4..7e38cfb0dba 100644 --- a/.github/workflows/hive-consume.yaml +++ b/.github/workflows/hive-consume.yaml @@ -128,6 +128,14 @@ jobs: ref: master path: hive + # Redirect Go's caches to a per-job temp dir so the setup-go cache + # restore doesn't collide with a persistent $GOMODCACHE on + # self-hosted runners (see build-benchmark-genesis/action.yaml). + - name: Use ephemeral Go cache dirs + shell: bash + run: | + echo "GOMODCACHE=${{ runner.temp }}/go/mod" >> "$GITHUB_ENV" + echo "GOCACHE=${{ runner.temp }}/go/build" >> "$GITHUB_ENV" - name: Setup go env and cache uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 with: diff --git a/.github/workflows/hive-execute.yaml b/.github/workflows/hive-execute.yaml index b4508a5423e..c4230b6ceeb 100644 --- a/.github/workflows/hive-execute.yaml +++ b/.github/workflows/hive-execute.yaml @@ -52,6 +52,14 @@ jobs: ref: master path: hive + # Redirect Go's caches to a per-job temp dir so the setup-go cache + # restore doesn't collide with a persistent $GOMODCACHE on + # self-hosted runners (see build-benchmark-genesis/action.yaml). + - name: Use ephemeral Go cache dirs + shell: bash + run: | + echo "GOMODCACHE=${{ runner.temp }}/go/mod" >> "$GITHUB_ENV" + echo "GOCACHE=${{ runner.temp }}/go/build" >> "$GITHUB_ENV" - name: Setup Go uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 with: