-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Free more disk space with free-disk-space script #134151
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
a356fe0
to
2d374ca
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
b7805b1
to
de0761b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
126c581
to
de0761b
Compare
Confirmed that the script behaves the same when moved to the repo, still trying to figure out if jlumbroso/free-disk-space#26 makes a tangible difference. Currently, free disk space can clean up 36GB with the changes up to this point, so a 10GB improvement so far. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d0a6385
to
ce5b7e5
Compare
This comment has been minimized.
This comment has been minimized.
0850509
to
e447a4f
Compare
This comment has been minimized.
This comment has been minimized.
|
Nope, will be reverting that one, jlumbroso/free-disk-space#26 also doesn't seem to make a noticeable improvement, especially compared to the example in that PR |
5ef7bf7
to
e0d0d4b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7e4bea1
to
f0e8e11
Compare
This comment has been minimized.
This comment has been minimized.
f0e8e11
to
b291103
Compare
This comment has been minimized.
This comment has been minimized.
Hey @whiteio is there a milestone that you reached that we can merge? E.g. getting rid of the GH Action and moving the scripts here is already something we are willing to merge. We can do the optimizations in other PRs 👍 |
101beca
to
b291103
Compare
Hey @marcoieni sorry about the delay, I think it's in a good place now. In regards to the E.g. lines such as this:
|
560ff2e
to
fe01c4f
Compare
This comment has been minimized.
This comment has been minimized.
fe01c4f
to
c068c75
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y microsoft-edge-stable --fix-missing || echo "::debug::The command [sudo apt-get remove -y microsoft-edge-stable --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get remove -y snapd --fix-missing || echo "::debug::The command [sudo apt-get remove -y snapd --fix-missing] failed to complete successfully. Proceeding..." | ||
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..." | ||
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y microsoft-edge-stable --fix-missing || echo "::debug::The command [sudo apt-get remove -y microsoft-edge-stable --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get remove -y snapd --fix-missing || echo "::debug::The command [sudo apt-get remove -y snapd --fix-missing] failed to complete successfully. Proceeding..." | |
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..." | |
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..." | |
PACKAGES_TO_REMOVE=( | |
'^aspnetcore-.*' | |
'^dotnet-.*' | |
'^llvm-.*' | |
'php.*' | |
'^mongodb-.*' | |
'^mysql-.*' | |
'azure-cli' | |
'google-chrome-stable' | |
'firefox' | |
'powershell' | |
'mono-devel' | |
'libgl1-mesa-dri' | |
'google-cloud-sdk' | |
'google-cloud-cli' | |
'microsoft-edge-stable' | |
'snapd' | |
) | |
for pkg in "${PACKAGES_TO_REMOVE[@]}"; do | |
sudo apt-get remove -y "$pkg" --fix-missing || echo "::warning::Failed to remove $pkg" | |
done | |
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed" | |
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed failed" |
We can simplify the code like this. What do you think?
The difference is that '^aspnetcore-.*'
didn't have --fix-missing
but I'm not sure why, so we can try to add it if you agree 👍
@@ -0,0 +1,218 @@ | |||
#!/bin/bash | |||
# Free disk space on Linux GitHub action runners |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's write at the beginning of the file something like script is inspired by https://github.com/jlumbroso/free-disk-space
, to give the author the credit they deserve 👍
|
||
BEFORE=$(getAvailableSpace) | ||
|
||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you do this also on line 186?
BEFORE=$(getAvailableSpace) | ||
|
||
sudo rm -rf /usr/local/share/powershell || true | ||
|
||
AFTER=$(getAvailableSpace) | ||
SAVED=$((AFTER-BEFORE)) | ||
printSavedSpace $SAVED "Powershell" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this pattern is repeated over and over.
Can we extract it into a function?
Something like this:
removeDir() {
dir=${1}
BEFORE=$(getAvailableSpace)
sudo rm -rf "$dir" || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "$dir"
}
so in the code you only do removeDir /usr/local/share/powershell
Consider also using an array as I suggested for the packages if you think it would look nice!
# Remove tool cache | ||
# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159 | ||
|
||
BEFORE=$(getAvailableSpace) | ||
|
||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true | ||
|
||
AFTER=$(getAvailableSpace) | ||
SAVED=$((AFTER-BEFORE)) | ||
printSavedSpace $SAVED "Tool cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Remove tool cache | |
# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159 | |
BEFORE=$(getAvailableSpace) | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true | |
AFTER=$(getAvailableSpace) | |
SAVED=$((AFTER-BEFORE)) | |
printSavedSpace $SAVED "Tool cache" |
removing this was false by default, so I wouldn't do this here. We can evaluate it later and remove it in another PR if we can 👍
echo "" | ||
} | ||
|
||
# macro to print output of dh with caption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dh is a typo. See https://github.com/jlumbroso/free-disk-space/pull/37/files
echo "$ dh -a /" | ||
echo "" | ||
df -a / | ||
echo "$ dh -a" | ||
echo "" | ||
df -a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "$ dh -a /" | |
echo "" | |
df -a / | |
echo "$ dh -a" | |
echo "" | |
df -a |
imo dh -h /
is enough.
Hey, unfortunately this is becoming blocking for things like rust-lang/infra-team#189 and #135774 Sorry if we couldn't wait longer 🙏 I'll create a new PR based on your work, thank you so much for taking the time to kick start this. I'll indicate you as a co-author in my commit |
☔ The latest upstream changes (presumably #135959) made this pull request unmergeable. Please resolve the merge conflicts. |
@marcoieni Sorry about all the delays. Thank you for taking it over. I'll close this as you're change is merged. Sorry again! |
Attempting to move the free-disk-space github action into the repo as it isn't currently maintained. This involves moving the script within free-disk-space into the repo.
I'm opening this as a draft to verify that the saved space is the same as the original action. Once that is verified, I'll look into integrating these two PRs to improve it:
Changes so far:
free-disk-space
repo and moved it intosrc/ci/scripts/
jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
GitHub actionSee this issue for more info: rust-lang/infra-team#183