Deploy Dev Stack / deploy (push) Successful in 55s
Deploy Dev Stack / pytest-backend (push) Successful in 50s
Deploy Dev Stack / lint-backend (push) Successful in 0s
Deploy Dev Stack / build-frontend (push) Successful in 17s
Deploy Dev Stack / k6 /health Baseline (push) Successful in 32s
Deploy Dev Stack / playwright-tests (push) Failing after 7m48s
workflow_run uses the workflow file on main and fell through to the prod directory when the triggering name was missing. Dev checks now follow Deploy Dev Stack and target the dev stack explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
117 lines
3.0 KiB
Bash
117 lines
3.0 KiB
Bash
#!/bin/sh
|
|
# Prüfungen gegen den bereits deployten Stack. Ziel ist Pflicht: dev oder prod.
|
|
# Kein Default auf Produktion.
|
|
set -eu
|
|
|
|
TARGET="${1:-}"
|
|
CHECK="${2:-}"
|
|
|
|
case "$TARGET" in
|
|
dev)
|
|
APP_DIR="/home/lars/docker/shinkan-dev"
|
|
COMPOSE_FILE="docker-compose.dev-env.yml"
|
|
BASE_URL="https://dev.shinkan.jinkendo.de"
|
|
HEALTH_TRIES=90
|
|
HEALTH_SLEEP=2
|
|
;;
|
|
prod)
|
|
APP_DIR="/home/lars/docker/shinkan"
|
|
COMPOSE_FILE="docker-compose.yml"
|
|
BASE_URL="https://shinkan.jinkendo.de"
|
|
HEALTH_TRIES=60
|
|
HEALTH_SLEEP=5
|
|
;;
|
|
*)
|
|
echo "Ziel muss dev oder prod sein, war: '${TARGET}'." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "CI-Ziel: $TARGET ($APP_DIR, $BASE_URL), Prüfung: $CHECK"
|
|
|
|
wait_health() {
|
|
echo "Warte auf $BASE_URL/health …"
|
|
i=1
|
|
while [ "$i" -le "$HEALTH_TRIES" ]; do
|
|
if curl -sf "$BASE_URL/health" >/dev/null 2>&1; then
|
|
echo "Health OK (Versuch $i)"
|
|
return 0
|
|
fi
|
|
i=$((i + 1))
|
|
sleep "$HEALTH_SLEEP"
|
|
done
|
|
echo "Timeout: $BASE_URL/health nicht erreichbar"
|
|
curl -v "$BASE_URL/health" || true
|
|
return 1
|
|
}
|
|
|
|
run_pytest() {
|
|
cd "$APP_DIR"
|
|
echo "Warte auf stabilen backend-Container …"
|
|
i=1
|
|
while [ "$i" -le 60 ]; do
|
|
if docker compose -f "$COMPOSE_FILE" exec -T backend true 2>/dev/null; then
|
|
echo "Backend bereit (Versuch $i)"
|
|
break
|
|
fi
|
|
if [ "$i" -eq 60 ]; then
|
|
echo "Timeout: backend-Container nicht bereit"
|
|
docker compose -f "$COMPOSE_FILE" ps || true
|
|
docker compose -f "$COMPOSE_FILE" logs backend --tail 80 || true
|
|
exit 1
|
|
fi
|
|
i=$((i + 1))
|
|
sleep 5
|
|
done
|
|
docker compose -f "$COMPOSE_FILE" exec -T backend sh -lc "
|
|
pip install -r /app/requirements-dev.txt &&
|
|
cd /app &&
|
|
ACCESS_LAYER_STRICT=1 python scripts/check_access_layer_hints.py &&
|
|
python scripts/security_release_checks.py &&
|
|
ACCESS_LAYER_INTEGRATION=1 TRAINING_PLANNING_INTEGRATION=1 SKIP_DB_MIGRATE=1 python -m pytest tests -m 'not slow' -ra -vv --tb=short
|
|
"
|
|
}
|
|
|
|
run_lint() {
|
|
python3 -m py_compile "$APP_DIR/backend/main.py"
|
|
echo "Backend syntax OK"
|
|
}
|
|
|
|
run_frontend() {
|
|
cd "$APP_DIR/frontend"
|
|
npm install
|
|
npm run build
|
|
echo "Frontend build OK"
|
|
}
|
|
|
|
run_k6() {
|
|
wait_health
|
|
K6_VER="v0.55.0"
|
|
ARCH=$(uname -m)
|
|
case "$ARCH" in
|
|
x86_64) K6_ARCH=amd64 ;;
|
|
aarch64|arm64) K6_ARCH=arm64 ;;
|
|
*) echo "k6: unbekannte Architektur: $ARCH" >&2; exit 1 ;;
|
|
esac
|
|
echo "Installing k6 ${K6_VER} linux-${K6_ARCH}"
|
|
curl -sSL "https://github.com/grafana/k6/releases/download/${K6_VER}/k6-${K6_VER}-linux-${K6_ARCH}.tar.gz" -o /tmp/k6.tgz
|
|
tar -xzf /tmp/k6.tgz -C /tmp
|
|
sudo mv "/tmp/k6-${K6_VER}-linux-${K6_ARCH}/k6" /usr/local/bin/k6
|
|
k6 version
|
|
cd "$APP_DIR"
|
|
echo "k6 gegen BASE_URL=$BASE_URL"
|
|
BASE_URL="$BASE_URL" k6 run scripts/load/k6-health-baseline.js
|
|
echo "k6 Health-Baseline passed"
|
|
}
|
|
|
|
case "$CHECK" in
|
|
pytest) run_pytest ;;
|
|
lint) run_lint ;;
|
|
frontend) run_frontend ;;
|
|
k6) run_k6 ;;
|
|
*)
|
|
echo "Prüfung muss pytest, lint, frontend oder k6 sein, war: '${CHECK}'." >&2
|
|
exit 1
|
|
;;
|
|
esac
|