#!/usr/bin/env bash # The one command. CI calls this; so do you, and so do agents. # Keeping the logic here rather than in .tangled/workflows keeps the forge replaceable. # # ./scripts/check.sh docs + guards + build (if a toolchain is present) # ./scripts/check.sh --no-build docs + guards only (works with no Android SDK) set -uo pipefail cd "$(dirname "$0")/.." || exit 1 MODE="${1:-}" fail=0 run() { local name=$1; shift printf '\n==> %s\n' "$name" if "$@"; then return 0; else fail=1; return 1; fi } run "documentation budgets" ./scripts/check-docs.sh run "pure-module boundary" ./scripts/guards/no-android-in-api.sh run "SPDX headers" ./scripts/guards/spdx-headers.sh run "no binaries in git" ./scripts/guards/no-binaries-in-git.sh run "module graph" ./scripts/guards/module-graph.sh if [ -f scripts/guards/licence-checksums.txt ]; then run "licence integrity" bash -c 'sha256sum -c --quiet scripts/guards/licence-checksums.txt' fi run "commit-msg hook" ./scripts/guards/commit-hook-selftest.sh # Preflight the JDK only when we are actually going to build: AGP 8.7 fails late and obscurely # on JDK 22+, and an unhelpful error here costs an agent a whole session. java_ok() { command -v java >/dev/null || { printf ' java not found. Run ./scripts/setup-toolchain.sh\n'; return 1; } local major major=$(java -version 2>&1 | sed -n 's/.*version "\([0-9][0-9]*\).*/\1/p' | head -1) if [ "${major:-0}" -gt 21 ] || [ "${major:-0}" -lt 17 ]; then printf ' java %s is outside the supported range 17-21 (AGP 8.7).\n' "${major:-unknown}" printf ' export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64\n' return 1 fi printf ' java %s OK\n' "$major" } if [ "$MODE" = "--no-build" ]; then printf '\n==> build: skipped (--no-build)\n' elif [ -x ./gradlew ]; then run "JDK range" java_ok && run "gradle check" ./gradlew check elif command -v gradle >/dev/null 2>&1; then run "JDK range" java_ok && run "gradle check" gradle check else printf '\n==> build: SKIPPED — no ./gradlew yet.\n' printf ' Run ./scripts/setup-toolchain.sh to install the SDK and generate the wrapper.\n' fi printf '\n' if [ "$fail" -ne 0 ]; then printf 'CHECK FAILED\n'; exit 1 fi printf 'CHECK PASSED\n'