OXYGENHUB
# aa627197ec18 oxygenhub-android / scripts / ci.sh
1.1 KiB · Bourne Again Shell (bash) · executable · last changed CI on OxygenFlow: unit tests with JUnit and JaCoCo coverage, and a debug build, offline (closes #19) 9 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 --offline --no-daemon --continue \
13
    :app:createDebugUnitTestCoverageReport \
14
    :app:assembleDebug || status=$?
15
16
{
17
    echo '<?xml version="1.0" encoding="UTF-8"?>'
18
    echo '<testsuites>'
19
    for f in app/build/test-results/testDebugUnitTest/TEST-*.xml; do
20
        [ -f "$f" ] && sed '/^<?xml /d' "$f"
21
    done
22
    echo '</testsuites>'
23
} > junit.xml
24
report=app/build/reports/coverage/test/debug/report.xml
25
if [ -f "$report" ]; then
26
    cp "$report" coverage.xml
27
else
28
    echo "ci: no coverage report at $report" >&2
29
    [ "$status" -ne 0 ] || status=1
30
fi
31
exit "$status"