Free up disk space for Android emulator in CI#12946
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12946 +/- ##
=======================================
Coverage 98.95% 98.95%
=======================================
Files 131 131
Lines 47998 47998
Branches 2494 2494
=======================================
Hits 47498 47498
Misses 376 376
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
ESPHome tried this first and it was slow and ended up with the bind mount solution in https://github.com/esphome/esphome/blob/29e8949e3e66c1cea04b5a16ab32b87eb539bd6f/.github/workflows/ci.yml#L856 as it contains the full solution.
You likely looked at an old pr
Examples
- name: Validate and compile components with intelligent grouping
run: |
. venv/bin/activate
# Check if /mnt has more free space than / before bind mounting
# Extract available space in KB for comparison
root_avail=$(df -k / | awk 'NR==2 {print $4}')
mnt_avail=$(df -k /mnt 2>/dev/null | awk 'NR==2 {print $4}')
echo "Available space: / has ${root_avail}KB, /mnt has ${mnt_avail}KB"
# Only use /mnt if it has more space than /
if [ -n "$mnt_avail" ] && [ "$mnt_avail" -gt "$root_avail" ]; then
echo "Using /mnt for build files (more space available)"
# Bind mount PlatformIO directory to /mnt (tools, packages, build cache all go there)
sudo mkdir -p /mnt/platformio
sudo chown $USER:$USER /mnt/platformio
mkdir -p ~/.platformio
sudo mount --bind /mnt/platformio ~/.platformio
# Bind mount test build directory to /mnt
sudo mkdir -p /mnt/test_build_components_build
sudo chown $USER:$USER /mnt/test_build_components_build
mkdir -p tests/test_build_components/build
sudo mount --bind /mnt/test_build_components_build tests/test_build_components/build
else
echo "Using / for build files (more space available than /mnt or /mnt unavailable)"
fi
...
# Show disk space before compilation
echo "Disk space before compilation:"
df -h
echo ""...
- name: Prepare build storage on /mnt
# Bind-mount the larger /mnt disk over the IDF install + build dirs BEFORE
# restoring the cache, so the ~4.5GB restore lands on the roomier volume
# instead of being shadowed by a mount set up later in the run step.
run: |
root_avail=$(df -k / | awk 'NR==2 {print $4}')
mnt_avail=$(df -k /mnt 2>/dev/null | awk 'NR==2 {print $4}')
echo "Available space: / has ${root_avail}KB, /mnt has ${mnt_avail}KB"
if [ -n "$mnt_avail" ] && [ "$mnt_avail" -gt "$root_avail" ]; then
echo "Using /mnt for build files (more space available)"
sudo mkdir -p /mnt/esphome-idf
sudo chown $USER:$USER /mnt/esphome-idf
mkdir -p ~/.esphome-idf
sudo mount --bind /mnt/esphome-idf ~/.esphome-idf
sudo mkdir -p /mnt/test_build_components_build
sudo chown $USER:$USER /mnt/test_build_components_build
mkdir -p tests/test_build_components/build
sudo mount --bind /mnt/test_build_components_build tests/test_build_components/build
else
echo "Using / for build files (more space available than /mnt or /mnt unavailable)"
fi
|
@aiolibsbot rr |
Reviewed. Maintainer feedback stands: |
|
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
PR summary doesn't match what this pr does |
|
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
It looks like the runner layout is different for aio-libs vs esphome.
|
|
Your original |
Confirmed. Same partition, |
Agreed. Will revert to |
Correct. Description says |
PR Review — Free up disk space for Android emulator in CIApproach doesn't work on aio-libs runners — the bind-mount is a no-op and frees no disk space.
🔴 Blocking1. Bind-mount is a no-op on aio-libs runners (/ and /mnt share one partition) (`.github/workflows/ci-cd.yml`, L343-376)The CI logs bdraco posted confirm this step does nothing on the aio-libs runner image:
The ESPHome bind-mount pattern works there only because their runners have a distinct, larger Per bdraco's follow-up, the right fix for this repo is to go back to the 🟡 Important1. PR description does not match the diff (`.github/workflows/ci-cd.yml`, L343-376)The PR description states it adds a Whichever approach lands, update the description to match so reviewers and the changelog fragment describe the real change. Checklist
To rebase specific severity levels, mention me: Automated review by Kōan (Claude) |
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Only 22s run to free up the space so this approach is likely fine and maintainable |
What do these changes do?
Add a
jlumbroso/free-disk-spacestep before the Android emulator install in thetest-mobileCI job. The default GitHub Actions runner image may run out of disk space when installing the Android emulator, causing sporadic failures. Reclaiming space from unused toolchains (dotnet, haskell, etc.) gives the emulator install room to succeed.Closes #12902
Are there changes in behavior for the user?
No user-facing changes.
Is it a substantial burden for the maintainers to support this?
No — it's a single pinned-SHA action invocation with minimal options. The
jlumbroso/free-disk-spaceaction is widely used across open-source projects for exactly this purpose.Related issue number
#12902 (bdraco's suggestion)
Checklist
CONTRIBUTORS.txtCHANGES/folderAgent run output
jlumbroso/free-disk-space@v1.3.1(SHA-pinned) step guarded byplatform == 'android'android: falsekeeps the Android SDK intact; only unused toolchains are removedlarge-packages: falseskips the slow apt purgeDrafted with Kōan (claude-opus-4-8[1m]).
Quality Report
Changes: 2 files changed, 14 insertions(+)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan