Skip to content

Commit e284abe

Browse files
build: local CI mirror script
scripts/ci_local.sh runs every Android CI gate in the same order against the local tree (clang-format, metadata lint, ktlint+detekt, lint, unit tests, native C++ tests, assemble, and the integration suite when a device or --gmd is available), so a green run locally means a green run in CI. Requires JAVA_HOME; finds adb via the SDK when it is off PATH.
1 parent 15e6bde commit e284abe

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

scripts/ci_local.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env bash
2+
# Runs every gate Android CI runs, in the same order, against the local
3+
# tree. Mirrors .github/workflows/android-ci.yml so a green run here means
4+
# a green run there. Instrumented tests need a device: they run when one is
5+
# attached (or a GMD is requested with --gmd), and are skipped with a notice
6+
# otherwise so the fast gates stay usable offline.
7+
#
8+
# scripts/ci_local.sh fast gates + instrumented tests if a device is attached
9+
# scripts/ci_local.sh --gmd also boot the pixel6Api34 managed device for instrumented tests
10+
# scripts/ci_local.sh --no-instrumented fast gates only
11+
set -euo pipefail
12+
cd "$(dirname "$0")/.."
13+
14+
GMD=0
15+
INSTRUMENTED=1
16+
for arg in "$@"; do
17+
case "$arg" in
18+
--gmd) GMD=1 ;;
19+
--no-instrumented) INSTRUMENTED=0 ;;
20+
*) echo "unknown flag: $arg" >&2; exit 2 ;;
21+
esac
22+
done
23+
24+
if [ -z "${JAVA_HOME:-}" ]; then
25+
echo "JAVA_HOME is not set." >&2
26+
echo "On this machine the Android Studio JBR works, e.g.:" >&2
27+
echo " export JAVA_HOME=\"C:/Program Files/Android/Android Studio/jbr\"" >&2
28+
exit 1
29+
fi
30+
31+
# The POSIX wrapper runs under Git Bash on Windows too, so one path covers
32+
# every OS. Local dependency-verification metadata is gitignored and drifts
33+
# from committed dep bumps; CI regenerates it, so disable it locally to match.
34+
GRADLE="./gradlew"
35+
GRADLE_ARGS="--dependency-verification off --console=plain"
36+
# The instrumented gate is the integration package: the screenshots harness
37+
# has its own per-locale workflow and the ad-hoc launch tests predate the
38+
# guided-setup redirect, so neither belongs in the gate.
39+
INTEGRATION_FILTER="-Pandroid.testInstrumentationRunnerArguments.package=com.tinkernorth.dish.integration"
40+
41+
step() { echo ""; echo "=== $1 ==="; }
42+
43+
step "clang-format (JNI, check only)"
44+
if command -v clang-format >/dev/null 2>&1; then
45+
FILES=$(find app/src/main/cpp -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.c' \))
46+
[ -z "$FILES" ] || echo "$FILES" | xargs clang-format --dry-run --Werror
47+
else
48+
echo "::notice:: clang-format not installed; CI pins 22.1.4. Skipping locally."
49+
fi
50+
51+
step "Play metadata lint"
52+
python scripts/check_play_metadata.py
53+
54+
step "ktlint + detekt (all source sets incl. test + androidTest)"
55+
$GRADLE :app:ktlintCheck :app:detekt $GRADLE_ARGS
56+
57+
step "Android lint"
58+
$GRADLE :app:lint $GRADLE_ARGS
59+
60+
step "JVM unit tests"
61+
$GRADLE :app:testDebugUnitTest $GRADLE_ARGS
62+
63+
step "Native C++ tests"
64+
$GRADLE :app:nativeTest $GRADLE_ARGS
65+
66+
step "Assemble debug APK"
67+
$GRADLE :app:assembleDebug $GRADLE_ARGS
68+
69+
if [ "$INSTRUMENTED" -eq 0 ]; then
70+
echo ""; echo "=== instrumented tests skipped (--no-instrumented) ==="
71+
echo "All non-instrumented gates passed."
72+
exit 0
73+
fi
74+
75+
if [ "$GMD" -eq 1 ]; then
76+
step "Instrumented tests (pixel6Api34 managed device)"
77+
$GRADLE :app:pixel6Api34DebugAndroidTest $GRADLE_ARGS $INTEGRATION_FILTER
78+
else
79+
ADB="adb"
80+
command -v adb >/dev/null 2>&1 || {
81+
for root in "${ANDROID_HOME:-}" "${ANDROID_SDK_ROOT:-}" "${LOCALAPPDATA:-}/Android/Sdk"; do
82+
[ -n "$root" ] && [ -x "$root/platform-tools/adb" ] && ADB="$root/platform-tools/adb" && break
83+
[ -n "$root" ] && [ -x "$root/platform-tools/adb.exe" ] && ADB="$root/platform-tools/adb.exe" && break
84+
done
85+
}
86+
DEVICES=$("$ADB" devices 2>/dev/null | grep -c -w device || true)
87+
if [ "${DEVICES:-0}" -ge 1 ]; then
88+
step "Instrumented tests (attached device)"
89+
$GRADLE :app:connectedDebugAndroidTest $GRADLE_ARGS $INTEGRATION_FILTER
90+
else
91+
echo ""; echo "=== instrumented tests skipped (no device) ==="
92+
echo "Attach a device/emulator, or re-run with --gmd, to run integration tests."
93+
fi
94+
fi
95+
96+
echo ""; echo "All requested gates passed."

0 commit comments

Comments
 (0)