Skip to content

Commit

Permalink
Auto merge of rust-lang#129797 - workingjubilee:cleanup-apple-ci, r=w…
Browse files Browse the repository at this point in the history
…orkingjubilee

Try to reduce space usage in dist CI

We have had recurrent CI problems as a result of GitHub adding a new version of Xcode to its runners[^0], which has consumed ~40GB of space which served as padding. Try to reduce the number of Xcodes on our systems, because we only use Xcode 14 in actual practice. Also, try to move files instead of pointlessly copy them when we're at the end of the job.

I could not resist addressing a few shellcheck lints while I was at it.

[^0]: actions/runner-images#10511
  • Loading branch information
bors committed Aug 31, 2024
2 parents 0d63418 + 10752a0 commit ca05929
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/ci/scripts/dump-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ df -h
echo

echo "biggest files in the working dir:"
set +o pipefail
du . | sort -nr | head -n100
set -o pipefail
du . | sort -n | tail -n100 | sort -nr # because piping sort to head gives a broken pipe
echo

if isMacOS
Expand Down
17 changes: 17 additions & 0 deletions src/ci/scripts/select-xcode.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#!/bin/bash
# This script selects the Xcode instance to use.
# It also tries to do some cleanup in CI jobs of unused Xcodes.

set -euo pipefail
IFS=$'\n\t'

source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"

if isMacOS; then
# This additional step is to try to remove an Xcode we aren't using because each one is HUGE
old_xcode="$(xcode-select --print-path)"
old_xcode="${old_xcode%/*}" # pop a dir
old_xcode="${old_xcode%/*}" # twice
if [[ $old_xcode =~ $SELECT_XCODE ]]; then
echo "xcode-select.sh's brutal hack may not be necessary?"
exit 1
elif [[ $SELECT_XCODE =~ "16" ]]; then
echo "Using Xcode 16? Please fix xcode-select.sh"
exit 1
fi
if [ $CI ]; then # just in case someone sources this on their real computer
sudo rm -rf "${old_xcode}"
xcode_16="${old_xcode:%/*}/Xcode-16.0.0.app"
sudo rm -rf "${xcode_16}"
fi
sudo xcode-select -s "${SELECT_XCODE}"
fi
10 changes: 5 additions & 5 deletions src/ci/scripts/upload-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ fi
if [[ "${DEPLOY-0}" -eq "1" ]] || [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then
dist_dir="${build_dir}/dist"
rm -rf "${dist_dir}/doc"
cp -r "${dist_dir}"/* "${upload_dir}"
mv "${dist_dir}"/* "${upload_dir}"
fi

# CPU usage statistics.
cp build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv"
mv build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv"

# Build metrics generated by x.py.
cp "${build_dir}/metrics.json" "${upload_dir}/metrics-${CI_JOB_NAME}.json"
mv "${build_dir}/metrics.json" "${upload_dir}/metrics-${CI_JOB_NAME}.json"

# Toolstate data.
if [[ -n "${DEPLOY_TOOLSTATES_JSON+x}" ]]; then
cp /tmp/toolstate/toolstates.json "${upload_dir}/${DEPLOY_TOOLSTATES_JSON}"
mv /tmp/toolstate/toolstates.json "${upload_dir}/${DEPLOY_TOOLSTATES_JSON}"
fi

echo "Files that will be uploaded:"
Expand All @@ -55,7 +55,7 @@ then
echo "# CI artifacts" >> "${GITHUB_STEP_SUMMARY}"

for filename in "${upload_dir}"/*.xz; do
filename=`basename "${filename}"`
filename=$(basename "${filename}")
echo "- [${filename}](${access_url}/${filename})" >> "${GITHUB_STEP_SUMMARY}"
done
fi

0 comments on commit ca05929

Please sign in to comment.