diff --git a/.gitea/workflows/android.yml b/.gitea/workflows/android.yml index 7484917b..406af1f7 100644 --- a/.gitea/workflows/android.yml +++ b/.gitea/workflows/android.yml @@ -7,7 +7,7 @@ on: jobs: android: - runs-on: windows-latest + runs-on: ubuntu-24.04 timeout-minutes: 40 steps: - uses: actions/checkout@v4 @@ -19,18 +19,26 @@ jobs: distribution: temurin java-version: '21' - name: Set up Android SDK - shell: powershell - run: ./scripts/setup-android-ci.ps1 + shell: bash + run: bash scripts/setup-android-ci.sh - name: Test and build exact commit - shell: powershell + shell: bash run: | - $ErrorActionPreference = 'Stop' - if ((git rev-parse HEAD).Trim() -ne $env:GITHUB_SHA) { throw 'Checkout SHA mismatch' } - Get-CimInstance Win32_OperatingSystem | Select-Object TotalVisibleMemorySize, FreePhysicalMemory - # A fresh runner compiles both variants from scratch. Keep their compiler - # heaps separate in time; the previous shared 2 GiB heap exhausted itself. - $buildArgs = @('--no-daemon', '--console=plain', '--max-workers=1', '-Pkotlin.daemon.jvmargs=-Xmx4096m') - .\gradlew.bat testDebugUnitTest assembleDebug @buildArgs - if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - .\gradlew.bat compileReleaseKotlin @buildArgs - exit $LASTEXITCODE + set -euo pipefail + test "$(git rev-parse HEAD)" = "$GITHUB_SHA" + uname -a + free -m + # One compiler process inside the server's bounded, serial CI runner. + build_args=(--no-daemon --console=plain --max-workers=1 + '-Dorg.gradle.jvmargs=-Xmx2560m -Dfile.encoding=UTF-8' + '-Pkotlin.compiler.execution.strategy=in-process') + bash gradlew testDebugUnitTest assembleDebug "${build_args[@]}" + bash gradlew compileReleaseKotlin "${build_args[@]}" + - name: Keep exact-commit APK and test reports + uses: actions/upload-artifact@v3 + with: + name: aiturk-android-${{ github.sha }} + if-no-files-found: error + path: | + app/build/outputs/apk/debug/app-debug.apk + app/build/reports/tests/testDebugUnitTest diff --git a/scripts/setup-android-ci.sh b/scripts/setup-android-ci.sh new file mode 100644 index 00000000..7d62303c --- /dev/null +++ b/scripts/setup-android-ci.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Linux CI on the TurkServis server; no workstation Android installation required. +set -euo pipefail +sdk_root="${RUNNER_TEMP:?}/android-sdk" +archive="${RUNNER_TEMP}/commandlinetools-linux-16111833.zip" +mkdir -p "$sdk_root/cmdline-tools" "$sdk_root/licenses" +curl --fail --location --retry 3 --max-time 300 \ + https://dl.google.com/android/repository/commandlinetools-linux-16111833_latest.zip -o "$archive" +# Official checksum from Google's repository2-3.xml, cmdline-tools;latest, linux. +printf '%s %s\n' e025545c62a8e64c7559119566a569fb1dec5f60 "$archive" | sha1sum -c - +unzip -q "$archive" -d "$sdk_root/cmdline-tools" +mv "$sdk_root/cmdline-tools/cmdline-tools" "$sdk_root/cmdline-tools/latest" +cp scripts/android-licenses/android-sdk-license "$sdk_root/licenses/" +"$sdk_root/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$sdk_root" \ + 'platform-tools' 'platforms;android-37.0' 'build-tools;37.0.0' +test -f "$sdk_root/platforms/android-37.0/android.jar" +test -x "$sdk_root/build-tools/37.0.0/aapt2" +printf 'ANDROID_HOME=%s\nANDROID_SDK_ROOT=%s\n' "$sdk_root" "$sdk_root" >> "$GITHUB_ENV"