Skip to content

Commit d1c7eb6

Browse files
use larger disk for build artifacts in CI
I was debugging an issue where my CI jobs were running out of disk space: ``` === df -h === Filesystem Size Used Avail Use% Mounted on /dev/root 72G 71G 1.2G 99% / tmpfs 7.9G 84K 7.9G 1% /dev/shm tmpfs 3.2G 1.1M 3.2G 1% /run tmpfs 5.0M 0 5.0M 0% /run/lock /dev/sdb16 881M 62M 758M 8% /boot /dev/sdb15 105M 6.2M 99M 6% /boot/efi /dev/sda1 74G 4.1G 66G 6% /mnt tmpfs 1.6G 12K 1.6G 1% /run/user/1001 === Top directories in workspace === sort: write failed: 'standard output': Broken pipe 16G ./target/debug 16G ./target 16G . 15G ./target/debug/deps 1.5G ./target/debug/examples 348M ./target/debug/build 19M ./target/debug/.fingerprint ``` See how `/` is 99% full. It turns out that `Swatinem/rust-cache@v2` was caching some outdated artifacts, causing `./target/debug` to be 3-4GB too large. I was able to fix the issue by reseting the cache, however, the disk usage is still quite high. ``` === df -h === Filesystem Size Used Avail Use% Mounted on /dev/root 72G 66G 5.8G 93% / tmpfs 7.9G 84K 7.9G 1% /dev/shm tmpfs 3.2G 1.2M 3.2G 1% /run tmpfs 5.0M 0 5.0M 0% /run/lock /dev/sda16 881M 62M 758M 8% /boot /dev/sda15 105M 6.2M 99M 6% /boot/efi /dev/sdb1 74G 4.1G 66G 6% /mnt tmpfs 1.6G 12K 1.6G 1% /run/user/1001 === Top directories in workspace === 12G ./target/debug 12G ./target 12G . 9.2G ./target/debug/deps 2.2G ./target/debug/examples 200M ./target/debug/build ``` I did some research while debugging this and uncovered that it is common to use `mnt` for cargo artifacts. This change makes cargo use `mnt` for the `target` directory.
1 parent 83efd9e commit d1c7eb6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.github/actions/setup/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ runs:
1717
echo $HOME
1818
echo ${{ runner.os }}
1919
20+
- shell: bash
21+
run: |
22+
# Create target directory if CARGO_TARGET_DIR is set
23+
if [ -n "$CARGO_TARGET_DIR" ]; then
24+
sudo mkdir -p "$CARGO_TARGET_DIR" && sudo chown -R $USER:$USER "$CARGO_TARGET_DIR"
25+
fi
26+
2027
- uses: dtolnay/rust-toolchain@stable
2128
with:
2229
toolchain: stable

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ jobs:
3232
lfs: true
3333
- uses: ./.github/actions/setup
3434
- run: cargo test --features integration
35+
- name: Show disk usage
36+
if: always()
37+
run: |
38+
echo "=== df -h ==="
39+
df -h
40+
echo "=== Top directories in workspace ==="
41+
du -h . 2>/dev/null | sort -hr | head -n 20 || true
42+
echo "=== cargo dirs ==="
43+
du -sh ~/.cargo 2>/dev/null || true
44+
du -sh ~/.cargo/registry 2>/dev/null || true
45+
du -sh ~/.cargo/git 2>/dev/null || true
46+
du -sh /mnt/target 2>/dev/null || true
47+
du -sh target 2>/dev/null || true
48+
echo "=== target/debug/deps sizes ==="
49+
du -h /mnt/target/debug/deps 2>/dev/null | sort -hr | head -n 30 || true
50+
du -h target/debug/deps 2>/dev/null | sort -hr | head -n 30 || true
51+
echo "=== home directory ==="
52+
du -sh ~ 2>/dev/null | head -n 10 || true
3553
3654
tpch-test:
3755
runs-on: ubuntu-latest
@@ -48,3 +66,4 @@ jobs:
4866
with:
4967
components: rustfmt
5068
- run: cargo fmt --all -- --check
69+

0 commit comments

Comments
 (0)