OXYGENHUB
◆ main oxygenhub-android / scripts / ci.sh
1.7 KiB · Bourne Again Shell (bash) · executable · last changed CI: point Gradle at the image's JDK 25 for its daemon, and never download (refs #19) 8 days ago source blame history raw
1
#!/usr/bin/env bash
2
# The app's CI job (#19), in OxygenFlow's Android image with no network:
3
# unit tests with coverage and a debug build. Not the screenshot tests:
4
# their references change with the clock, so are not kept, and CI would
5
# have nothing to compare a screen with. Gradle runs every task even when
6
# one fails (--continue), so the reports are written either way:
7
#   junit.xml     every unit test class's JUnit XML in one <testsuites>
8
#   coverage.xml  JaCoCo XML of the unit tests, for the Coverage tab
9
set -u
10
cd "$(dirname "$0")/.."
11
status=0
12
# Gradle's daemon wants Java 25 (gradle/gradle-daemon-jvm.properties). The
13
# image's warm build provisioned one under /opt/gradle-home/jdks, but the
14
# job's GRADLE_USER_HOME is a fresh one: name the JDKs there, and never
15
# download (there is no network to download with).
16
jdks=$(ls -d /opt/gradle-home/jdks/*/ 2>/dev/null | sed 's:/$::' | paste -sd, -)
17
if [ -n "$jdks" ] && [ -n "${GRADLE_USER_HOME:-}" ]; then
18
    mkdir -p "$GRADLE_USER_HOME"
19
    {
20
        echo "org.gradle.java.installations.paths=$jdks"
21
        echo "org.gradle.java.installations.auto-download=false"
22
    } >> "$GRADLE_USER_HOME/gradle.properties"
23
fi
24
gradle --offline --no-daemon --continue \
25
    :app:createDebugUnitTestCoverageReport \
26
    :app:assembleDebug || status=$?
27
28
{
29
    echo '<?xml version="1.0" encoding="UTF-8"?>'
30
    echo '<testsuites>'
31
    for f in app/build/test-results/testDebugUnitTest/TEST-*.xml; do
32
        [ -f "$f" ] && sed '/^<?xml /d' "$f"
33
    done
34
    echo '</testsuites>'
35
} > junit.xml
36
report=app/build/reports/coverage/test/debug/report.xml
37
if [ -f "$report" ]; then
38
    cp "$report" coverage.xml
39
else
40
    echo "ci: no coverage report at $report" >&2
41
    [ "$status" -ne 0 ] || status=1
42
fi
43
exit "$status"