diff --git a/infra/staging/smoke_suite.sh b/infra/staging/smoke_suite.sh index debd645..ca47bf5 100755 --- a/infra/staging/smoke_suite.sh +++ b/infra/staging/smoke_suite.sh @@ -50,16 +50,26 @@ PY echo "[smoke] healthz check: ${BASE_URL}/healthz" curl -fsS "${BASE_URL}/healthz" >/dev/null || { SMOKE_FAIL_MESSAGE="healthz check failed" fail "healthz check failed"; } +ENV_FILE="${ENV_FILE:-/etc/wpp/staging.env}" + +run_manage() { + local cmd="$1" + ( + cd "${APP_DIR}" + if [[ -f "${ENV_FILE}" ]]; then + set -a + # shellcheck disable=SC1090 + source "${ENV_FILE}" + set +a + fi + .venv/bin/python manage.py ${cmd} + ) +} + echo "[smoke] migration consistency check" -( - cd "${APP_DIR}" - .venv/bin/python manage.py migrate --check --noinput -) || { SMOKE_FAIL_MESSAGE="schema drift: unapplied migrations in staging" fail "schema drift: unapplied migrations in staging"; } +run_manage "migrate --check --noinput" || { SMOKE_FAIL_MESSAGE="schema drift: unapplied migrations in staging" fail "schema drift: unapplied migrations in staging"; } echo "[smoke] gameplay flow via management command" -( - cd "${APP_DIR}" - .venv/bin/python manage.py smoke_staging -) || { SMOKE_FAIL_MESSAGE="manage.py smoke_staging failed" fail "manage.py smoke_staging failed"; } +run_manage "smoke_staging" || { SMOKE_FAIL_MESSAGE="manage.py smoke_staging failed" fail "manage.py smoke_staging failed"; } echo "[smoke] OK"