~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain-android

1 collaborator
0
1
main
62 lines · 3.0 KB Raw History
# The JVM test suite and the coverage gate, on pushes to main and pulls into
# it or into a feature branch.
#
# No emulator. The suite runs the view models, the API layer and every Compose
# screen under Robolectric, so all of it is a plain JVM run. The tests that
# need a device live in androidTest and are not run here; `just coverage`
# measures those, on a machine with one attached.
#
# The gate is `coverageVerification` in app/build.gradle.kts, a floor of 80%
# line coverage. It fails rather than skipping when there is no execution
# data, so a run where the tests silently did nothing goes red.
#
# `build-release` is not here: R8 is not incremental and a release build takes
# about an hour.
#
# x86_64 only. AGP publishes no linux-arm64 AAPT2, so on an arm64 runner the
# build dies in `processDebugResources` with "Daemon startup failed".
#
# A run has 3 GB, and gradle.properties asks for a 3 GB heap, so Gradle gets
# less here and compiles Kotlin in its own process rather than a second
# daemon. The SDK and Gradle's caches are kept between runs.
image: eclipse-temurin:17-jdk
on:
  push: { refs: [refs/heads/main] }
  pull: { base: [refs/heads/main, refs/heads/feature/*] }
cache: [/opt/android-sdk, /root/.gradle/caches, /root/.gradle/wrapper]
env:
  # cmdline-tools 23.0, pinned: an SDK that moves under the pipeline turns an
  # unrelated push red.
  CMDLINE_TOOLS: commandlinetools-linux-16111833_latest.zip
  # Both track app/build.gradle.kts. compileSdk 37 is packaged as
  # `android-37.0` under the newer SDK versioning.
  ANDROID_PLATFORM: platforms;android-37.0
  ANDROID_BUILD_TOOLS: build-tools;36.0.0
  ANDROID_HOME: /opt/android-sdk
steps:
  - name: android sdk
    run: |
      apt-get update -qq
      apt-get install -y -qq git unzip curl >/dev/null
      have="$CMDLINE_TOOLS $ANDROID_PLATFORM $ANDROID_BUILD_TOOLS"
      [ "$(cat "$ANDROID_HOME/.installed" 2>/dev/null)" = "$have" ] && exit 0
      find "$ANDROID_HOME" -mindepth 1 -delete 2>/dev/null || true
      mkdir -p "$ANDROID_HOME/cmdline-tools"
      curl -fsSL -o /tmp/cmdline-tools.zip "https://dl.google.com/android/repository/$CMDLINE_TOOLS"
      unzip -q /tmp/cmdline-tools.zip -d "$ANDROID_HOME/cmdline-tools"
      mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"
      sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
      # sdkmanager reads yes once per licence and closes the pipe.
      yes 2>/dev/null | "$sdk" --licenses >/dev/null 2>&1 || true
      "$sdk" "platform-tools" "$ANDROID_PLATFORM" "$ANDROID_BUILD_TOOLS" >/dev/null
      echo "$have" > "$ANDROID_HOME/.installed"
  - name: tests and gate
    timeout: 30
    run: |
      # -Pcoverage turns on the JaCoCo agent; without it the gate has nothing
      # to read and says so.
      ./gradlew --no-daemon -Pcoverage \
        -Dorg.gradle.jvmargs="-Xmx1536m -Dfile.encoding=UTF-8" \
        -Pkotlin.compiler.execution.strategy=in-process \
        -Dorg.gradle.workers.max=2 \
        :app:testDebugUnitTest :app:coverageVerification