Skip to content

Commit 3dbbfe8

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 3dbbfe8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111
RUST_BACKTRACE: 1
12+
CARGO_TARGET_DIR: /mnt/target
1213

1314
concurrency:
1415
group: ${{ github.ref }}
@@ -32,6 +33,15 @@ jobs:
3233
lfs: true
3334
- uses: ./.github/actions/setup
3435
- run: cargo test --features integration
36+
- name: Show disk usage
37+
if: always()
38+
run: |
39+
echo "=== df -h ==="
40+
df -h
41+
echo "=== top directories in workspace ==="
42+
du -h . 2>/dev/null | sort -hr | head -n 10 || true
43+
echo "=== cargo target directory ==="
44+
du -sh /mnt/target 2>/dev/null || true
3545
3646
tpch-test:
3747
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)