Skip to content

Commit fa72f07

Browse files
committed
Auto merge of rust-lang#129797 - workingjubilee:cleanup-apple-ci, r=workingjubilee
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
2 parents 0d63418 + 8da1c00 commit fa72f07

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/ci/scripts/dump-environment.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ df -h
1515
echo
1616

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

2321
if isMacOS

src/ci/scripts/select-xcode.sh

+17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
#!/bin/bash
22
# This script selects the Xcode instance to use.
3+
# It also tries to do some cleanup in CI jobs of unused Xcodes.
34

45
set -euo pipefail
56
IFS=$'\n\t'
67

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

910
if isMacOS; then
11+
# This additional step is to try to remove an Xcode we aren't using because each one is HUGE
12+
old_xcode="$(xcode-select --print-path)"
13+
old_xcode="${old_xcode%/*}" # pop a dir
14+
old_xcode="${old_xcode%/*}" # twice
15+
if [[ $old_xcode =~ $SELECT_XCODE ]]; then
16+
echo "xcode-select.sh's brutal hack may not be necessary?"
17+
exit 1
18+
elif [[ $SELECT_XCODE =~ "16" ]]; then
19+
echo "Using Xcode 16? Please fix xcode-select.sh"
20+
exit 1
21+
fi
22+
if [ $CI ]; then # just in case someone sources this on their real computer
23+
sudo rm -rf "${old_xcode}"
24+
xcode_16="${old_xcode%/*}/Xcode-16.0.0.app"
25+
sudo rm -rf "${xcode_16}"
26+
fi
1027
sudo xcode-select -s "${SELECT_XCODE}"
1128
fi

src/ci/scripts/upload-artifacts.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ fi
1919
if [[ "${DEPLOY-0}" -eq "1" ]] || [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then
2020
dist_dir="${build_dir}/dist"
2121
rm -rf "${dist_dir}/doc"
22-
cp -r "${dist_dir}"/* "${upload_dir}"
22+
mv "${dist_dir}"/* "${upload_dir}"
2323
fi
2424

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

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

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

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

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

0 commit comments

Comments
 (0)