Fixed all compilation and unit test failures #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Android CI | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Ensure Gradle wrapper is executable | |
| run: chmod +x ./gradlew | |
| - name: Setup JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android SDK (API 35) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| ANDROID_SDK_ROOT="$HOME/android-sdk" | |
| echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> "$GITHUB_ENV" | |
| echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> "$GITHUB_ENV" | |
| echo "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin" >> "$GITHUB_PATH" | |
| echo "$ANDROID_SDK_ROOT/platform-tools" >> "$GITHUB_PATH" | |
| mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools" | |
| curl -sSL -o cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip | |
| unzip -q cmdline-tools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools" | |
| mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest" | |
| # Ensure sdkmanager is available in this step by exporting PATH locally | |
| export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH" | |
| # Accept licenses and install required SDK components using absolute sdkmanager path | |
| # The 'yes' process may get a SIGPIPE when sdkmanager closes stdin; tolerate it. | |
| yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses --sdk_root="$ANDROID_SDK_ROOT" > /dev/null || true | |
| "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "platforms;android-35" "build-tools;35.0.0" | |
| echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties | |
| - name: Verify Android SDK installation | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "JAVA_HOME: $JAVA_HOME" | |
| echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT" | |
| ls -la "$ANDROID_SDK_ROOT" || true | |
| ls -la "$ANDROID_SDK_ROOT/platforms" || true | |
| ls -la "$ANDROID_SDK_ROOT/build-tools" || true | |
| "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --list | head -n 200 || true | |
| - name: Cache Gradle | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Echo Kotlin/Compose Compiler versions | |
| run: | | |
| echo "Kotlin version:" $(grep -Po '(?<=kotlin = ")[^\"]+' gradle/libs.versions.toml) | |
| echo "Compose Compiler version:" $(grep -Po '(?<=composeCompiler = ")[^\"]+' gradle/libs.versions.toml) | |
| - name: Gradle version | |
| run: | | |
| ./gradlew --version | |
| - name: Gradle evaluate (help) | |
| run: | | |
| ./gradlew help --stacktrace --info --console=plain --no-configuration-cache | |
| - name: Gradle assemble | |
| run: | | |
| ./gradlew clean assemble --stacktrace --info --console=plain --no-configuration-cache | |
| - name: Gradle tests and detekt | |
| run: | | |
| ./gradlew test detekt --stacktrace --info --console=plain --no-configuration-cache | |
| - name: Upload test and detekt reports on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-reports | |
| path: | | |
| **/build/reports/** | |
| **/build/test-results/** | |
| - name: Upload build artifacts (APK) | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-apks | |
| path: app/build/outputs/**/*.apk |