Skip to content

Commit 9c13bc8

Browse files
authored
Merge pull request #172 from GetStream/feature/uni-127-fix-gh-runners-failing-to-due-low-disk-space
Free up space on GH runners to fix failing from low disk space
2 parents 846cd36 + 36bdcf7 commit 9c13bc8

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

.github/workflows/main.ci.cd.workflow.yml

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,60 @@ jobs:
2424
- name: Checkout repository
2525
uses: actions/checkout@v4
2626

27+
- name: Check disk space before cleanup
28+
run: df -h
29+
30+
- name: Free up disk space
31+
run: |
32+
echo "Freeing up disk space..."
33+
echo "Unity version: ${{ matrix.unity_version }}"
34+
echo "Target platform: ${{ matrix.target_platform }}"
35+
36+
# Always safe to remove - not used by Unity builds
37+
sudo rm -rf /opt/ghc
38+
sudo rm -rf /opt/hostedtoolcache/CodeQL
39+
sudo rm -rf /usr/local/share/boost
40+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
41+
42+
# Remove large packages that aren't needed
43+
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "No llvm packages to remove"
44+
sudo apt-get remove -y 'php.*' --fix-missing || echo "No php packages to remove"
45+
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "No mongodb packages to remove"
46+
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "No mysql packages to remove"
47+
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "Continuing..."
48+
sudo apt-get autoremove -y || echo "Autoremove completed"
49+
sudo apt-get clean || echo "Clean completed"
50+
51+
# Remove system .NET SDK for Unity 2021 and 2022 (they use bundled Mono)
52+
# Skip for Unity 2023+ in case of CoreCLR dependencies
53+
if [ "${{ matrix.unity_version }}" == "2021" ] || [ "${{ matrix.unity_version }}" == "2022" ] || [ "${{ matrix.unity_version }}" == "2020" ]; then
54+
echo "Removing system .NET SDK (Unity ${{ matrix.unity_version }} uses bundled Mono runtime)"
55+
sudo apt-get remove -y '^aspnetcore-.*' --fix-missing || echo "No aspnetcore packages to remove"
56+
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "No dotnet packages to remove"
57+
sudo rm -rf /usr/share/dotnet
58+
else
59+
echo "Keeping system .NET SDK (Unity ${{ matrix.unity_version }} may use CoreCLR)"
60+
fi
61+
62+
# Remove Node modules (not needed for Unity)
63+
sudo rm -rf /usr/local/lib/node_modules
64+
65+
# Only remove Android SDK/NDK if NOT building for Android
66+
if [ "${{ matrix.target_platform }}" != "android" ]; then
67+
echo "Removing Android SDK/NDK (not needed for ${{ matrix.target_platform }} build)"
68+
sudo rm -rf /usr/local/lib/android
69+
else
70+
echo "Keeping Android SDK/NDK (needed for Android build)"
71+
fi
72+
73+
# Clean up Docker
74+
sudo docker image prune --all --force
75+
76+
echo "Cleanup completed."
77+
78+
- name: Check disk space after cleanup
79+
run: df -h
80+
2781
- name: Calculate Sequential Index
2882
id: calculate-index
2983
run: |
@@ -201,19 +255,12 @@ jobs:
201255
name: Test_Results_${{ env.RUNNER_ID }}
202256
path: artifacts
203257

204-
- name: Free Disk space
205-
uses: jlumbroso/[email protected]
206-
if: matrix.target_platform == 'android' || matrix.target_platform == 'ios'
207-
with:
208-
dotnet: false
209-
210258
- name: List changes
211259
run: |
212260
git diff
213261
214-
- name: Print Free Disk Space
215-
run: |
216-
df -m
262+
- name: Check disk space before build
263+
run: df -h
217264

218265
- name: Build Sample Project
219266
uses: game-ci/unity-builder@v4

0 commit comments

Comments
 (0)