diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 7ff15ea..c030888 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -37,7 +37,6 @@ jobs: with: distribution: temurin java-version: ${{ env.JAVA_VERSION }} - cache: gradle - name: Set up Flutter uses: subosito/flutter-action@v2 @@ -46,6 +45,39 @@ jobs: channel: stable cache: true + - name: Free runner disk space + shell: bash + run: | + set -euo pipefail + echo '--- Disk usage before cleanup ---' + df -h / + echo '--- Largest top-level directories ---' + sudo du -xhd1 / 2>/dev/null | sort -h | tail -n 15 || true + + # GitHub-hosted Ubuntu images contain many preinstalled SDKs and + # toolchains that MotorSignal does not use. Remove only disposable + # software; keep Android SDK command-line tools, platform-tools, + # the active API/build-tools, CMake and NDK installations intact. + sudo rm -rf /usr/share/dotnet \ + /usr/local/share/powershell \ + /opt/ghc \ + /usr/local/.ghcup \ + /usr/local/lib/android/sdk/emulator \ + /usr/local/lib/android/sdk/system-images + + sudo apt-get clean || true + sudo rm -rf /var/lib/apt/lists/* + docker system prune -af --volumes 2>/dev/null || true + + echo '--- Disk usage after cleanup ---' + df -h / + AVAILABLE_KB="$(df --output=avail / | tail -n 1 | tr -d ' ')" + MIN_AVAILABLE_KB=$((5 * 1024 * 1024)) + if [ "$AVAILABLE_KB" -lt "$MIN_AVAILABLE_KB" ]; then + echo "ERROR: less than 5 GiB remains on the runner after cleanup." + exit 1 + fi + - name: Create Flutter local.properties shell: bash run: | @@ -86,6 +118,7 @@ jobs: flutter doctor -v java -version sdkmanager --list_installed | grep -E 'platforms;android-37|build-tools;37|platform-tools' || true + df -h / - name: Get dependencies run: flutter pub get @@ -97,7 +130,12 @@ jobs: run: flutter test - name: Build debug APK - run: flutter build apk --debug + shell: bash + run: | + set -euo pipefail + df -h / + flutter build apk --debug + df -h / - name: Verify debug APK shell: bash @@ -135,7 +173,6 @@ jobs: with: distribution: temurin java-version: ${{ env.JAVA_VERSION }} - cache: gradle - name: Set up Flutter uses: subosito/flutter-action@v2 @@ -144,6 +181,37 @@ jobs: channel: stable cache: true + - name: Free runner disk space + shell: bash + run: | + set -euo pipefail + echo '--- Disk usage before cleanup ---' + df -h / + echo '--- Largest top-level directories ---' + sudo du -xhd1 / 2>/dev/null | sort -h | tail -n 15 || true + + # Keep only software relevant to the Android build. Android SDK + # command-line tools, active SDK/build-tools, CMake and NDK are kept. + sudo rm -rf /usr/share/dotnet \ + /usr/local/share/powershell \ + /opt/ghc \ + /usr/local/.ghcup \ + /usr/local/lib/android/sdk/emulator \ + /usr/local/lib/android/sdk/system-images + + sudo apt-get clean || true + sudo rm -rf /var/lib/apt/lists/* + docker system prune -af --volumes 2>/dev/null || true + + echo '--- Disk usage after cleanup ---' + df -h / + AVAILABLE_KB="$(df --output=avail / | tail -n 1 | tr -d ' ')" + MIN_AVAILABLE_KB=$((5 * 1024 * 1024)) + if [ "$AVAILABLE_KB" -lt "$MIN_AVAILABLE_KB" ]; then + echo "ERROR: less than 5 GiB remains on the runner after cleanup." + exit 1 + fi + - name: Create Flutter local.properties shell: bash run: | @@ -223,10 +291,20 @@ jobs: -alias "$KEY_ALIAS" >/dev/null - name: Build release APK - run: flutter build apk --release + shell: bash + run: | + set -euo pipefail + df -h / + flutter build apk --release + df -h / - name: Build release App Bundle - run: flutter build appbundle --release + shell: bash + run: | + set -euo pipefail + df -h / + flutter build appbundle --release + df -h / - name: Verify release artifacts and signatures shell: bash