Skip to content

Commit beec122

Browse files
committed
[ci] Free disk space in Gradle in Bazel builds
1 parent e47b4a5 commit beec122

File tree

2 files changed

+77
-47
lines changed

2 files changed

+77
-47
lines changed

.github/workflows/bazel.yml

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
include:
15-
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
16-
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
17-
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
18-
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
19-
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
20-
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
21-
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
22-
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
15+
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, action: "build" }
16+
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, action: "build" }
17+
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, action: "build" }
18+
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, action: "build" }
19+
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, action: "test" }
20+
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, action: "test" }
21+
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, action: "test" }
22+
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, action: "test" }
2323

2424
- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, action: "test" }
2525

@@ -34,8 +34,34 @@ jobs:
3434

3535
name: "${{ matrix.action == 'test' && 'Test' || 'Build' }} ${{ matrix.name }}"
3636
runs-on: ${{ matrix.os }}
37-
container: ${{ matrix.container }}
3837
steps:
38+
- name: Check disk free space pre-cleanup
39+
run: df -h
40+
41+
- name: Free disk space (Linux)
42+
uses: jlumbroso/free-disk-space@main
43+
with:
44+
tool-cache: false
45+
android: true
46+
dotnet: true
47+
haskell: true
48+
large-packages: false
49+
docker-images: false
50+
swap-storage: false
51+
if: startsWith(matrix.os, 'ubuntu')
52+
- name: Free disk space (macOS)
53+
# CodeQL: 5G
54+
# go: 748M
55+
# Android: 12G
56+
run: |
57+
rm -rf /Users/runner/hostedtoolcache/CodeQL
58+
rm -rf /Users/runner/hostedtoolcache/go
59+
rm -rf /Users/runner/Library/Android
60+
if: startsWith(matrix.os, 'macOS')
61+
62+
- name: Check disk free space post-cleanup
63+
run: df -h
64+
3965
- uses: actions/checkout@v4
4066
with: { fetch-depth: 0 }
4167

@@ -45,6 +71,10 @@ jobs:
4571
username: ${{ secrets.BAZEL_CACHE_USERNAME }}
4672
password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
4773

74+
- name: Install apt dependencies
75+
if: matrix.os == 'ubuntu-24.04'
76+
run: sudo apt-get install -y libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev
77+
4878
- if: matrix.os == 'ubuntu-24.04'
4979
uses: bazel-contrib/[email protected]
5080
with:
@@ -61,15 +91,9 @@ jobs:
6191
fi
6292
shell: bash
6393

64-
- name: Free Space
94+
- name: Check disk free space
6595
if: always()
66-
shell: bash
67-
run: |
68-
if [[ "${{ matrix.os }}" == "windows-2022" ]]; then
69-
fsutil volume diskfree C:
70-
else
71-
df -h /
72-
fi
96+
run: df -h
7397

7498
buildifier:
7599
name: "buildifier"

.github/workflows/gradle.yml

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ jobs:
3535
runs-on: ubuntu-24.04
3636
needs: [validation]
3737
steps:
38-
- name: Free Disk Space
38+
- name: Check disk free space pre-cleanup
39+
run: df -h
40+
41+
- name: Free disk space
3942
uses: jlumbroso/free-disk-space@main
4043
with:
4144
tool-cache: false
@@ -45,6 +48,10 @@ jobs:
4548
large-packages: false
4649
docker-images: false
4750
swap-storage: false
51+
52+
- name: Check disk free space post-cleanup
53+
run: df -h
54+
4855
- uses: actions/checkout@v4
4956
with:
5057
fetch-depth: 0
@@ -55,18 +62,20 @@ jobs:
5562
uses: addnab/docker-run-action@v3
5663
with:
5764
image: ${{ matrix.container }}
58-
options: -v ${{ github.workspace }}:/work -w /work -e ARTIFACTORY_PUBLISH_USERNAME -e ARTIFACTORY_PUBLISH_PASSWORD -e GITHUB_REF -e CI
59-
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
65+
options: -v ${{ github.workspace }}:/work -w /work -e ARTIFACTORY_PUBLISH_USERNAME -e ARTIFACTORY_PUBLISH_PASSWORD
66+
run: ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
6067
env:
6168
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
6269
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
63-
- name: Check free disk space
64-
run: df .
6570
- uses: actions/upload-artifact@v4
6671
with:
6772
name: ${{ matrix.artifact-name }}
6873
path: build/allOutputs
6974

75+
- name: Check disk free space
76+
if: always()
77+
run: df -h
78+
7079
build-host:
7180
env:
7281
MACOSX_DEPLOYMENT_TARGET: 13.3
@@ -113,6 +122,22 @@ jobs:
113122
runs-on: ${{ matrix.os }}
114123
needs: [validation]
115124
steps:
125+
- name: Check disk free space pre-cleanup
126+
run: df -h
127+
128+
- name: Free disk space (macOS)
129+
# CodeQL: 5G
130+
# go: 748M
131+
# Android: 12G
132+
run: |
133+
rm -rf /Users/runner/hostedtoolcache/CodeQL
134+
rm -rf /Users/runner/hostedtoolcache/go
135+
rm -rf /Users/runner/Library/Android
136+
if: startsWith(matrix.os, 'macOS')
137+
138+
- name: Check disk free space post-cleanup
139+
run: df -h
140+
116141
- uses: actions/checkout@v4
117142
with:
118143
fetch-depth: 0
@@ -139,24 +164,6 @@ jobs:
139164
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
140165
shell: bash
141166
if: startsWith(github.ref, 'refs/tags/v2027')
142-
- name: Check disk free space (Windows)
143-
run: wmic logicaldisk get caption, freespace
144-
if: matrix.os == 'windows-2022'
145-
- name: Check disk free space pre-cleanup (macOS)
146-
run: df -h .
147-
if: matrix.os == 'macOS-15'
148-
- name: Cleanup disk space
149-
# CodeQL: 5G
150-
# go: 748M
151-
# Android: 12G
152-
run: |
153-
rm -rf /Users/runner/hostedtoolcache/CodeQL
154-
rm -rf /Users/runner/hostedtoolcache/go
155-
rm -rf /Users/runner/Library/Android
156-
if: matrix.os == 'macOS-15'
157-
- name: Check disk free space post-cleanup (macOS)
158-
run: df -h .
159-
if: matrix.os == 'macOS-15'
160167
- name: Build with Gradle
161168
run: ./gradlew ${{ matrix.task }} --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
162169
env:
@@ -167,17 +174,15 @@ jobs:
167174
if: |
168175
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
169176
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027')))
170-
- name: Check disk free space (Windows)
171-
run: wmic logicaldisk get caption, freespace
172-
if: matrix.os == 'windows-2022'
173-
- name: Check disk free space (macOS)
174-
run: df -h .
175-
if: matrix.os == 'macOS-15'
176177
- uses: actions/upload-artifact@v4
177178
with:
178179
name: ${{ matrix.artifact-name }}
179180
path: ${{ matrix.outputs }}
180181

182+
- name: Check disk free space
183+
if: always()
184+
run: df -h
185+
181186
build-documentation:
182187
name: "Build - Documentation"
183188
runs-on: ubuntu-24.04
@@ -275,7 +280,7 @@ jobs:
275280
needs: [build-docker, build-host, build-documentation]
276281
runs-on: ubuntu-24.04
277282
steps:
278-
- name: Free Disk Space
283+
- name: Free disk space
279284
if: |
280285
github.repository == 'wpilibsuite/allwpilib' &&
281286
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
@@ -288,6 +293,7 @@ jobs:
288293
large-packages: false
289294
docker-images: false
290295
swap-storage: false
296+
291297
- uses: actions/checkout@v4
292298
if: |
293299
github.repository == 'wpilibsuite/allwpilib' &&

0 commit comments

Comments
 (0)