Skip to content

Commit 78b18ef

Browse files
lystopadsudeepdino008
authored andcommitted
ci: improve disk space management on self-hosted Windows runner (#19593)
## Changes - Move `GOMODCACHE`/`GOCACHE` env vars to job level so all steps share the same cache paths - Add **pre-run** `go clean -testcache` (`if: always()`) — ensures tests run fresh and catches leftovers from cancelled runs - Add **LFS prune** step after checkout — removes blobs no longer referenced by the current branch - Replace old `Cleanup` with **post-run** `go clean -cache` — clears compiled artifacts after each run to prevent unbounded growth on the persistent runner - Post-run cleanup also removes `coverage-test-all.out` and `$env:RUNNER_TEMP` (previously only `$env:TEMP` was cleaned)
1 parent 0e2e5ff commit 78b18ef

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/workflows/test-all-erigon.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
concurrency:
120120
group: >-
121121
${{
122-
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) &&
122+
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) &&
123123
format('{0}-{1}-{2}', github.workflow, matrix.os, github.run_id) ||
124124
format('{0}-{1}-{2}', github.workflow, matrix.os, github.ref)
125125
}}
@@ -130,6 +130,10 @@ jobs:
130130
runs-on:
131131
group: "selfhosted-win"
132132

133+
env:
134+
GOMODCACHE: C:\go-cache\mod
135+
GOCACHE: C:\go-cache\build
136+
133137
steps:
134138
# not needed on self-hosted runner. already configured.
135139
#- name: Configure Pagefile
@@ -147,6 +151,12 @@ jobs:
147151
lfs: true
148152
clean: true
149153

154+
# Prune LFS blobs that are no longer referenced by the current checkout.
155+
- name: Prune stale Git LFS objects
156+
if: needs.source-of-changes.outputs.changed_files != 'true'
157+
shell: bash
158+
run: git lfs prune --verify-remote=false
159+
150160
- name: Setup Go environment on ${{ matrix.os }}
151161
if: needs.source-of-changes.outputs.changed_files != 'true'
152162
uses: actions/setup-go@v6
@@ -161,15 +171,20 @@ jobs:
161171
- name: Run all tests on ${{ matrix.os }}
162172
if: needs.source-of-changes.outputs.changed_files != 'true'
163173
shell: bash
164-
env:
165-
GOMODCACHE: C:\go-cache\mod
166-
GOCACHE: C:\go-cache\build
167174
run: make test-all
168175

169-
- name: Cleanup
176+
# Clears the Go build cache after the run so compiled artifacts do not
177+
# accumulate on the persistent self-hosted runner across runs.
178+
# GOMODCACHE is intentionally kept: it is bounded by the number of unique
179+
# dependency versions and saves re-downloading modules on the next run.
180+
- name: Post-run cleanup
170181
if: always()
182+
shell: bash
171183
run: |
172-
Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue
184+
go clean -cache
185+
rm -f coverage-test-all.out
186+
rm -rf "$TEMP/"* 2>/dev/null || true
187+
rm -rf "$RUNNER_TEMP/"* 2>/dev/null || true
173188
174189
- name: This ${{ matrix.os }} check does not make sense for changes within out-of-scope directories
175190
if: needs.source-of-changes.outputs.changed_files == 'true'

0 commit comments

Comments
 (0)