Skip to content

Commit 8c0038d

Browse files
authored
Get disk space usage and throw an error for low disk space (#693)
This leverages `setup-miniconda` to print out the disk usage and throw an error when the available space is less than a certain amount (3GB) This PR doesn't attempt to clean up disk space pending some discussion on pytorch/pytorch#84841
1 parent 4661bf5 commit 8c0038d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.github/actions/setup-miniconda/action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ runs:
3838
bash "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh" -b -u -p "${MINICONDA_INSTALL_PATH_MACOS}"
3939
rm -rf "${MINICONDA_INSTALL_PATH_MACOS}/miniconda.sh"
4040
echo "${MINICONDA_INSTALL_PATH_MACOS}/bin" >> $GITHUB_PATH
41+
4142
- name: Setup conda environment
4243
shell: bash
4344
env:
@@ -65,3 +66,28 @@ runs:
6566
echo "CONDA_RUN=conda run -p ${CONDA_ENV}" >> "${GITHUB_ENV}"
6667
echo "CONDA_BUILD=conda run -p ${CONDA_ENV} conda-build" >> "${GITHUB_ENV}"
6768
echo "CONDA_INSTALL=conda install -p ${CONDA_ENV}" >> "${GITHUB_ENV}"
69+
70+
- name: Get disk space usage and throw an error for low disk space
71+
shell: bash
72+
run: |
73+
echo "Print the available disk space for manual inspection"
74+
df -h
75+
76+
MINIMUM_AVAILABLE_SPACE_IN_GB=3
77+
78+
df -h | tr -s ' ' | cut -d' ' -f 4,9 | while read -r LINE;
79+
do
80+
AVAIL=$(echo $LINE | cut -f1 -d' ')
81+
MOUNT=$(echo $LINE | cut -f2 -d' ')
82+
83+
if [ "$MOUNT" = "/" ]; then
84+
AVAIL_IN_GB=${AVAIL::${#AVAIL}-2}
85+
86+
if [ "$AVAIL_IN_GB" -lt "$MINIMUM_AVAILABLE_SPACE_IN_GB" ]; then
87+
echo "There is only $AVAIL free space left in $MOUNT, which is less than the minimum requirement of ${MINIMUM_AVAILABLE_SPACE_IN_GB}Gi. Please help create an issue to PyTorch Release Engineering via https://github.com/pytorch/test-infra/issues and provide the link to the workflow run."
88+
exit 1;
89+
else
90+
echo "There is $AVAIL free space left in $MOUNT, continue"
91+
fi
92+
fi
93+
done

0 commit comments

Comments
 (0)