Skip to content

Commit 9ddbd1d

Browse files
authored
Merge pull request #1878 from lightninglabs/wip/build-reduce-disk-space-use
CI: add reusable cleanup workflow and clear Go caches
2 parents 154b609 + 3050e97 commit 9ddbd1d

File tree

3 files changed

+70
-13
lines changed

3 files changed

+70
-13
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Clean up runner disk space"
2+
description: "Removes large, non-essential toolsets to free up disk space on the runner."
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Free up disk space
8+
shell: bash
9+
run: |
10+
echo "Removing large toolsets to free up disk space..."
11+
echo "Disk space before cleanup:"
12+
df -h
13+
14+
# Remove dotnet to save disk space.
15+
sudo rm -rf /usr/share/dotnet
16+
# Remove android to save disk space.
17+
sudo rm -rf /usr/local/lib/android
18+
# Remove ghc to save disk space.
19+
sudo rm -rf /opt/ghc
20+
# Remove large packages.
21+
sudo rm -rf /usr/share/swift
22+
sudo rm -rf /usr/local/julia*
23+
sudo rm -rf /opt/hostedtoolcache
24+
25+
# Remove docker images to save space.
26+
docker image prune -a -f || true
27+
28+
# Remove large apt packages.
29+
sudo apt-get remove -y \
30+
'^aspnetcore-.*' \
31+
'^dotnet-.*' \
32+
'^llvm-.*' \
33+
'php.*' \
34+
'^mongodb-.*' \
35+
'^mysql-.*' \
36+
azure-cli \
37+
google-chrome-stable \
38+
firefox \
39+
powershell \
40+
mono-devel \
41+
libgl1-mesa-dri 2>/dev/null || true
42+
sudo apt-get autoremove -y
43+
sudo apt-get clean
44+
45+
# Remove caches.
46+
sudo rm -rf /usr/local/share/boost
47+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
48+
49+
echo "Disk space after cleanup:"
50+
df -h

.github/workflows/main.yaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ jobs:
175175
runs-on: ubuntu-latest
176176
steps:
177177
- name: git checkout
178-
uses: actions/checkout@v4
178+
uses: actions/checkout@v5
179+
180+
- name: Clean up runner space
181+
uses: ./.github/actions/cleanup-space
179182

180183
- name: Setup go ${{ env.GO_VERSION }}
181184
uses: actions/setup-go@v5
@@ -280,11 +283,11 @@ jobs:
280283
name: run itests
281284
runs-on: ubuntu-latest
282285
steps:
283-
- name: cleanup space
284-
run: rm -rf /opt/hostedtoolcache
285-
286286
- name: git checkout
287-
uses: actions/checkout@v4
287+
uses: actions/checkout@v5
288+
289+
- name: Clean up runner space
290+
uses: ./.github/actions/cleanup-space
288291

289292
- name: Setup go ${{ env.GO_VERSION }}
290293
uses: actions/setup-go@v5
@@ -323,11 +326,11 @@ jobs:
323326
name: run itests postgres
324327
runs-on: ubuntu-latest
325328
steps:
326-
- name: cleanup space
327-
run: rm -rf /opt/hostedtoolcache
328-
329329
- name: git checkout
330-
uses: actions/checkout@v4
330+
uses: actions/checkout@v5
331+
332+
- name: Clean up runner space
333+
uses: ./.github/actions/cleanup-space
331334

332335
- name: Setup go ${{ env.GO_VERSION }}
333336
uses: actions/setup-go@v5
@@ -367,11 +370,11 @@ jobs:
367370
runs-on: ubuntu-latest
368371

369372
steps:
370-
- name: cleanup space
371-
run: rm -rf /opt/hostedtoolcache
372-
373373
- name: git checkout
374-
uses: actions/checkout@v4
374+
uses: actions/checkout@v5
375+
376+
- name: Clean up runner space
377+
uses: ./.github/actions/cleanup-space
375378

376379
- name: Setup go ${{ env.GO_VERSION }}
377380
uses: actions/setup-go@v5

scripts/release.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ required Go version ($goversion)."
183183
env CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" GOARM=$arm GOAMD64="v1" go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/tapcli
184184
popd
185185

186+
# Clear Go build cache to prevent disk space issues during multi-platform
187+
# builds.
188+
go clean -cache
189+
186190
# Add the hashes for the individual binaries as well for easy verification
187191
# of a single installed binary.
188192
shasum -a 256 "${dir}/"* >> "manifest-$tag.txt"

0 commit comments

Comments
 (0)