#!/usr/bin/env bash # The app's CI job (#19), in OxygenFlow's Android image with no network: # unit tests with coverage and a debug build. Not the screenshot tests: # their references change with the clock, so are not kept, and CI would # have nothing to compare a screen with. Gradle runs every task even when # one fails (--continue), so the reports are written either way: # junit.xml every unit test class's JUnit XML in one # coverage.xml JaCoCo XML of the unit tests, for the Coverage tab set -u cd "$(dirname "$0")/.." status=0 # Gradle's daemon wants Java 25 (gradle/gradle-daemon-jvm.properties). The # image's warm build provisioned one under /opt/gradle-home/jdks, but the # job's GRADLE_USER_HOME is a fresh one: name the JDKs there, and never # download (there is no network to download with). jdks=$(ls -d /opt/gradle-home/jdks/*/ 2>/dev/null | sed 's:/$::' | paste -sd, -) if [ -n "$jdks" ] && [ -n "${GRADLE_USER_HOME:-}" ]; then mkdir -p "$GRADLE_USER_HOME" { echo "org.gradle.java.installations.paths=$jdks" echo "org.gradle.java.installations.auto-download=false" } >> "$GRADLE_USER_HOME/gradle.properties" fi gradle --offline --no-daemon --continue \ :app:createDebugUnitTestCoverageReport \ :app:assembleDebug || status=$? { echo '' echo '' for f in app/build/test-results/testDebugUnitTest/TEST-*.xml; do [ -f "$f" ] && sed '/^' } > junit.xml report=app/build/reports/coverage/test/debug/report.xml if [ -f "$report" ]; then cp "$report" coverage.xml else echo "ci: no coverage report at $report" >&2 [ "$status" -ne 0 ] || status=1 fi exit "$status"