-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
When using the swift-android-action to run Swift tests cases against the Android emulator, you may sometimes encounter the error:
Error: Timeout waiting for emulator to boot.
Most of the time, the real issue is that the emulator startup process immediately failed due to not having enough disk space to create the emulator. This can be confirmed by expanding the "Launch Emulator" section in the actions log, which may look like:
INFO | Guest GLES Driver: Auto (ext controls)
WARNING | Your GPU drivers may have a bug. Switching to software rendering.
library_mode swangle_indirect gpu mode swangle_indirect
INFO | Checking system compatibility:
INFO | Checking: hasSufficientDiskSpace
INFO | Ok: Disk space requirements to run avd: `test` are met
INFO | Checking: hasSufficientHwGpu
INFO | Ok: Hardware GPU compatibility checks are not required
INFO | Checking: hasSufficientSystem
INFO | Ok: System requirements to run avd: `test` are met
FATAL | Not enough space to create userdata partition. Available: 6791.23 MB at /home/runner/.android/avd/test.avd, need 7372.80 MB.It is this last FATAL error that causes the emulator to fail to start, but because we do not start the emulator in the foreground, we only identify a failure to start via a timeout waiting for it to become responsive.
We should do some better (and more immediate) diagnostics to at least report to the user that this is the problem and advise them to free up disk space.
Note that this can happen for any number of reasons (e.g., because prior actions are doing things that take up a lot of disk space), but it has recently become a more frequent occurrence due to the the stock ubuntu-latest and macos-latest actions runners becoming more loaded down with pre-installed (and usually unnecessary) software, reducing the amount of free space they have out of the box.
The solution is to free up some disk space, either using an action like https://github.com/marketplace/actions/free-disk-space-ubuntu, or just manually adding a step to your workflow like the one in this workflow's README:
jobs:
linux-android:
runs-on: ubuntu-latest
steps:
# Ubuntu runners can run low on space can cause the emulator to fail to install
- name: "Free Disk Space"
run: |
if [[ "${RUNNER_OS}" == "macOS" ]]; then
sudo rm -rf /Applications/Xcode_1[4567]*.app
else
sudo rm -rf /opt/microsoft /opt/google /opt/az /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/share/chromium /usr/local/share/powershell /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL /usr/local/share/boost
fi
docker image prune --all --force
docker builder prune -a
- uses: actions/checkout@v4
- name: "Test Swift Package on Linux"
run: swift test
- name: "Test Swift Package on Android"
uses: skiptools/swift-android-action@v2