Skip to content

Commit 6226602

Browse files
committed
Improve CI fork-PR build disk handling
- Free extra unused SDKs on GitHub-hosted runners - Fail fast with a clear message when a fork-PR VM is too small - Drop the no-op /mnt bind-mount (same filesystem as root)
1 parent 7646af1 commit 6226602

2 files changed

Lines changed: 44 additions & 13 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,30 @@ runs:
7878
docker-images: true
7979
swap-storage: true
8080

81+
# Extra unused SDKs beyond jlumbroso; only GitHub-hosted runners are disk-bound
82+
- name: Free additional disk space (Linux)
83+
if: >-
84+
inputs.free-disk-space == 'true'
85+
&& runner.os == 'Linux'
86+
&& runner.environment == 'github-hosted'
87+
shell: bash
88+
run: |
89+
echo "=== Disk usage before extra cleanup ==="
90+
df -h /
91+
for path in \
92+
/usr/share/swift \
93+
/usr/local/lib/swift \
94+
/usr/local/share/powershell \
95+
/usr/local/share/boost \
96+
/usr/local/share/chromium \
97+
/opt/google/chrome \
98+
/opt/microsoft \
99+
/usr/local/julia*; do
100+
sudo rm -rf $path || true
101+
done
102+
echo "=== Disk usage after extra cleanup ==="
103+
df -h /
104+
81105
- name: Free disk space (macOS)
82106
if: inputs.free-disk-space == 'true' && runner.os == 'macOS'
83107
shell: bash

.github/workflows/build.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,6 @@ jobs:
263263
- name: Verify immutable CI inputs (post-checkout)
264264
run: bash scripts/ci/verify-ci-inputs.sh post-checkout
265265

266-
# Fork-PR runners keep the workspace on the small root fs; bind the target
267-
# dir to the larger /mnt disk (path stays workspace-relative for rust-cache).
268-
- name: Back Cargo target with /mnt ephemeral disk (fork PRs)
269-
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
270-
run: |
271-
target="${{ github.workspace }}/target/build-linux-x86"
272-
backing="/mnt/cargo-target/build-linux-x86"
273-
sudo mkdir -p "$backing"
274-
sudo chown "$(id -u):$(id -g)" "$backing"
275-
mkdir -p "$target"
276-
sudo mount --bind "$backing" "$target"
277-
df -h / /mnt
278-
279266
- name: Common setup
280267
uses: ./.github/actions/common-setup
281268
with:
@@ -309,6 +296,26 @@ jobs:
309296
- name: Cached test data
310297
uses: ./.github/actions/common-test-data
311298

299+
# Fork-PR runners vary in disk size; fail early with a clear message
300+
# rather than a cryptic linker Bus error when a small VM runs out.
301+
- name: Check available disk space
302+
if: >-
303+
needs.plan.outputs.run-rust-tests == 'true'
304+
&& github.event_name == 'pull_request'
305+
&& github.event.pull_request.head.repo.fork
306+
run: |
307+
echo "::group::Disk space before Rust tests"
308+
df -h /
309+
echo "::endgroup::"
310+
avail_gb=$(($(df -Pk / | awk 'NR==2 {print $4}') / 1024 / 1024))
311+
echo "Available on / : ${avail_gb}G"
312+
if [ "${avail_gb}" -lt 25 ]; then
313+
echo "::error::Only ${avail_gb}G free, runner too small for the Rust build. Re-run for a larger VM."
314+
exit 1
315+
elif [ "${avail_gb}" -lt 40 ]; then
316+
echo "::warning::Only ${avail_gb}G free, the Rust build may run out of space, re-run if it fails."
317+
fi
318+
312319
- name: Run Rust tests (core)
313320
if: needs.plan.outputs.run-rust-tests == 'true'
314321
run: make cargo-test-core EXTRA_FEATURES="capnp,hypersync" NEXTEST_PROFILE=ci

0 commit comments

Comments
 (0)