1f94d0a38a
docs/PERFORMANCE.md has been honest that three of its four numbers do not exist. They exist now as measurements, if not yet as results: benchmark/ is a macrobenchmark module with four tests - cold start with StartupTimingMetric, then opening, scrolling and searching a folder of a thousand files with FrameTimingMetric - sharing a fixture at /sdcard/AABenchmark that is created once per run and deleted in @AfterClass. Frames rather than a named trace section on purpose: what a user calls slow is jank on screen, and the alternative puts benchmarking calls into production code for the sake of a number. CompilationMode.None() is the honest cold-install baseline; Partial() plus a baseline profile is the follow-up and needs the same module. The storage grant is applied with appops in setup, which is what lets the run be unattended - a permission dialog is the one thing a test cannot answer. Three build facts had to be discovered rather than designed, and each is now written where it will be read. The app under test cannot keep its own package id: it needs a debug signature to install on a test device, so it cannot replace a release install, and an un-suffixed build is exactly that. It also cannot use the obvious suffix: `.benchmark` is already the benchmark module's own APK id, and the test APK then fails to install with INSTALL_FAILED_VERSION_DOWNGRADE - which is what the first attempt did. Hence `.perf`. And `testBuildType = "benchmark"` cannot be set unconditionally, because it makes benchmark the variant that *unit* tests run against and :app:testDebugUnitTest - the task the entire gate is built on - stops existing; it is behind -PbenchmarkBuild instead. All three were measured, not guessed, and the third would have broken CI silently. Two smaller things came with it. tools/verify.sh --release now also compiles the app's benchmark variant and the test APK, because build wiring nobody runs is wiring that rots; no device is involved. And the code map grew an EXTRA_ROOTS section so it indexes benchmark/ too - a map that silently omits a module lies by omission, which is worse than the one line it costs. The numbers themselves are still missing, and for a device reason rather than a code one: installing the new package id on this MIUI phone fails with INSTALL_FAILED_USER_RESTRICTED (the "Install via USB" gate, which wants a human and answered too late). Both APKs are pushed to /sdcard/Download/ for a manual install, and the run is one command away: `adb shell am instrument -w -e class de.softwareapp_hb.filemanager.benchmark.BrowserBenchmark de.softwareapp_hb.filemanager.benchmark/androidx.test.runner.AndroidJUnitRunner`. Gate green with --release, including the new compile step; map current; 386 tests unchanged.
56 lines
1.9 KiB
Bash
Executable File
56 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# The gate. Everything that has to be true before a change is finished, in one command:
|
|
#
|
|
# ./tools/verify.sh # what every change has to pass
|
|
# ./tools/verify.sh --release # ...and an R8 release build, which is what the nightly runs
|
|
# GRADLE_FLAGS=--offline ./tools/verify.sh # keeps working without a network
|
|
#
|
|
# Cheapest first, so a stale document fails in a second rather than after a release build. Each step
|
|
# is here because it has caught a real defect in this project at least once; nothing is on the list
|
|
# because it is fashionable.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
release=false
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--release) release=true ;;
|
|
*) echo "verify: unknown option '$arg' (only --release is understood)" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
# Word splitting is intended here: GRADLE_FLAGS is a place to put several flags.
|
|
# shellcheck disable=SC2086
|
|
gradle() { ./gradlew ${GRADLE_FLAGS:-} "$@" --console=plain; }
|
|
|
|
step() { printf '\n\033[1m== %s\033[0m\n' "$1"; }
|
|
|
|
step "Code map is current"
|
|
python3 tools/make-code-map.py --check
|
|
|
|
step "Kotlin static analysis (detekt, against the baseline)"
|
|
gradle :app:detekt
|
|
|
|
step "JVM unit tests"
|
|
gradle :app:testDebugUnitTest
|
|
|
|
step "Android Lint"
|
|
gradle :app:lintDebug
|
|
|
|
if $release; then
|
|
step "Release build (R8)"
|
|
# Signed when keystore.properties happens to be present, unsigned otherwise — either way R8
|
|
# runs, and a release-only defect (a class reached only through a resource, for instance) is
|
|
# exactly what this step is for.
|
|
gradle :app:assembleRelease
|
|
|
|
step "Benchmark APKs compile"
|
|
# No device: this only proves that :benchmark still compiles against the app's benchmark build
|
|
# type, which is the thing that rots silently between device runs.
|
|
gradle :app:assembleBenchmark :benchmark:assembleDebug
|
|
fi
|
|
|
|
printf '\n\033[1mverify: all checks passed\033[0m\n'
|