Public Quart microservice that runs pytest against shared/tests/ and shared/sexp/tests/, serving an HTMX-powered sexp-rendered dashboard with pass/fail/running status, auto-refresh polling, and re-run button. No database — results stored in memory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
68 lines
1.8 KiB
Bash
Executable File
68 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REGISTRY="registry.rose-ash.com:5000"
|
|
APPS="blog market cart events federation account relations likes orders test"
|
|
|
|
usage() {
|
|
echo "Usage: deploy.sh [app ...]"
|
|
echo " deploy.sh blog # rebuild + restart blog only"
|
|
echo " deploy.sh blog market # rebuild + restart blog and market"
|
|
echo " deploy.sh --all # rebuild + restart all apps"
|
|
echo " deploy.sh # auto-detect changed apps via git"
|
|
exit 1
|
|
}
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
# Determine which apps to build
|
|
if [ $# -eq 0 ]; then
|
|
# Auto-detect: uncommitted changes + last commit
|
|
CHANGED=$(git diff --name-only HEAD 2>/dev/null; git diff --name-only HEAD~1 HEAD 2>/dev/null || true)
|
|
BUILD=()
|
|
if echo "$CHANGED" | grep -q "^shared/"; then
|
|
BUILD=($APPS)
|
|
else
|
|
for app in $APPS; do
|
|
if echo "$CHANGED" | grep -q "^$app/"; then
|
|
BUILD+=("$app")
|
|
fi
|
|
done
|
|
fi
|
|
if [ ${#BUILD[@]} -eq 0 ]; then
|
|
echo "No app changes detected. Pass app names or --all."
|
|
exit 0
|
|
fi
|
|
elif [ "$1" = "--all" ]; then
|
|
BUILD=($APPS)
|
|
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
usage
|
|
else
|
|
BUILD=("$@")
|
|
fi
|
|
|
|
echo "Building: ${BUILD[*]}"
|
|
echo ""
|
|
|
|
# --- Run unit tests before deploying ---
|
|
echo "=== Running unit tests ==="
|
|
docker build -f test/Dockerfile.unit -t rose-ash-test-unit:latest . -q
|
|
if ! docker run --rm rose-ash-test-unit:latest; then
|
|
echo ""
|
|
echo "Unit tests FAILED — aborting deploy."
|
|
exit 1
|
|
fi
|
|
echo "Unit tests passed."
|
|
echo ""
|
|
|
|
for app in "${BUILD[@]}"; do
|
|
echo "=== $app ==="
|
|
docker build -f "$app/Dockerfile" -t "$REGISTRY/$app:latest" .
|
|
docker push "$REGISTRY/$app:latest"
|
|
docker service update --force "coop_$app" 2>/dev/null \
|
|
|| echo " (service coop_$app not running — will start on next stack deploy)"
|
|
echo ""
|
|
done
|
|
|
|
echo "Done."
|