#!/usr/bin/env bash # One round, end to end — the same gates as ship.sh, with the two things that # do not depend on each other run at the same time. # # bash src-tauri/android/ship-fast.sh [commit-message-file] # # ship.sh runs the mock walk, THEN the deploy, THEN the phone walk. But the # mock walk only drives headless Chrome against dist-smoke/ and the deploy # only builds and installs an APK: neither reads the other's output. Running # them together takes about four minutes off a round that was taking # twenty-three. # # The one thing they would collide over is vite — two builds racing for the # same dependency cache — so the dist-smoke build happens ONCE here, up # front, and the walk is told to use it (SS_SKIP_BUILD=1). By the time the # deploy runs its own build of dist/ the cache is warm and it only reads. # # The gate is unchanged in substance: nothing reaches the PHONE that the mock # walk did not pass, and nothing is committed the phone walk did not pass. A # failing mock walk now costs a wasted APK build rather than a wasted wait, # which is the right trade at four minutes a round. set -uo pipefail cd "$(dirname "$0")/../.." || { echo "cannot find the repo above $0"; exit 2; } MSG="${1:-}" T="$(cygpath -u "$TEMP")" ADB="$(cygpath -u "$LOCALAPPDATA")/Android/Sdk/platform-tools/adb.exe" stamp=$(date +%H%M%S) ALBUM="${SS_ALBUM:-Spiderman}" QUERY="${SS_QUERY:-daft punk}" echo "== build dist-smoke $(date +%T)" if ! npx vite build --outDir dist-smoke --base ./ --minify false > "$T/ss-ship-build-$stamp.log" 2>&1; then echo "DIST-SMOKE BUILD FAILED ($T/ss-ship-build-$stamp.log)" tail -20 "$T/ss-ship-build-$stamp.log" exit 1 fi echo "== mock walk + deploy $(date +%T)" SS_SKIP_BUILD=1 node tests/mobile/smoke.mjs > "$T/ss-ship-mock-$stamp.log" 2>&1 & mock=$! bash src-tauri/android/deploy.sh > "$T/ss-ship-deploy-$stamp.log" 2>&1 & dep=$! wait $mock; mockrc=$? wait $dep; deprc=$? if [ $mockrc -ne 0 ]; then echo "MOCK WALK FAILED ($T/ss-ship-mock-$stamp.log)" grep -n "FAIL" "$T/ss-ship-mock-$stamp.log" | cut -c1-160 | head sed -n '/problem(s):/,$p' "$T/ss-ship-mock-$stamp.log" | cut -c1-300 | head -20 exit 1 fi echo " mock green $(date +%T)" if [ $deprc -ne 0 ]; then echo "DEPLOY FAILED ($T/ss-ship-deploy-$stamp.log)" tail -25 "$T/ss-ship-deploy-$stamp.log" exit 1 fi grep -a "^== install\|Success\|not launched" "$T/ss-ship-deploy-$stamp.log" | tail -3 echo "== phone walk $(date +%T)" if ! node tests/mobile/smoke.mjs --phone --album "$ALBUM" --query "$QUERY" > "$T/ss-ship-phone-$stamp.log" 2>&1; then echo "PHONE WALK FAILED ($T/ss-ship-phone-$stamp.log)" grep -n "FAIL" "$T/ss-ship-phone-$stamp.log" | cut -c1-160 | head sed -n '/problem(s):/,$p' "$T/ss-ship-phone-$stamp.log" | cut -c1-300 | head -20 "$ADB" forward --remove-all exit 1 fi grep -n "audio \|no exceptions\|the app is up" "$T/ss-ship-phone-$stamp.log" | cut -c1-120 "$ADB" forward --remove-all if [ -n "$MSG" ]; then echo "== commit $(date +%T)" git add -A git -c user.name="KeelrLeek" commit -q -F "$MSG" 2>/dev/null git log -1 --format=' %h %s' | cut -c1-140 fi echo "== shipped $(date +%T)"