The rate limit, the version compare and the download check were all wrapped in Android — a Context, a socket, a file — so none of them had a test, and all three shipped broken: the remote thrown out after five reconnects (0.11.1), a truncated APK handed to the installer (0.11.5), and a version compare that would read 0.11.10 as older than 0.11.9 the moment we get there. They are now plain Kotlin in AttemptBudget and UpdateRules, with the clock injected, and 20 tests covering the failures themselves. AttemptBudget also prunes expired entries before evicting: dropping only empty queues let the map grow without bound while every tracked address held one fresh failure. tests/smoke.sh installs the debug APK on the headless emulator, walks the first screen with the D-pad and fails on a crash or ANR — the class of bug unit tests cannot see, and the reason 0.11.0 crashed on startup. Forty seconds end to end. tools/release.sh does the bump, tests, signed build, tag, apk branch and Gitea release in one command. It refuses an unsigned build and never writes the release notes itself; commit subjects are offered as a draft. tests/helpers/jdk.sh picks a JDK Gradle can run on: Ubuntu moved default-java to 25, which fails the build with a bare "IllegalArgumentException: 25.0.4". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
39 lines
1.2 KiB
Bash
Executable File
39 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Picks a JDK that Gradle can actually run on and exports JAVA_HOME.
|
|
#
|
|
# Ubuntu moved default-java to 25, which the Gradle version in this repo
|
|
# refuses with a bare "IllegalArgumentException: 25.0.4" — an unhelpful
|
|
# message for a build that worked yesterday. Sourced by the scripts under
|
|
# tests/ and tools/; harmless when JAVA_HOME is already a supported JDK.
|
|
#
|
|
# . tests/helpers/jdk.sh
|
|
set -u
|
|
|
|
_jdk_major() {
|
|
"$1/bin/java" -version 2>&1 | head -1 |
|
|
sed -E 's/.*version "([0-9]+).*/\1/'
|
|
}
|
|
|
|
_jdk_pick() {
|
|
local candidate major
|
|
if [ -n "${JAVA_HOME:-}" ] && [ -x "${JAVA_HOME}/bin/java" ]; then
|
|
major="$(_jdk_major "$JAVA_HOME")"
|
|
if [ "$major" -ge 17 ] 2>/dev/null && [ "$major" -le 21 ] 2>/dev/null; then
|
|
return 0
|
|
fi
|
|
fi
|
|
for candidate in \
|
|
/usr/lib/jvm/java-21-openjdk-amd64 \
|
|
/usr/lib/jvm/java-17-openjdk-amd64 \
|
|
"$HOME"/jdk-21* \
|
|
"$HOME"/jdk-17*; do
|
|
[ -x "$candidate/bin/java" ] || continue
|
|
export JAVA_HOME="$candidate"
|
|
return 0
|
|
done
|
|
echo "no JDK 17-21 found; Gradle cannot run on $(java -version 2>&1 | head -1)" >&2
|
|
return 1
|
|
}
|
|
|
|
_jdk_pick
|