fix(ci): B5 schema init 改用 psql localhost:15432 直連
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

act runner 無法透過 docker ps 取得 service container name
改用 psql client 直連 localhost:15432 初始化 schema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-10 16:04:42 +08:00
parent e8d1df04c6
commit 04c25fdd60

View File

@@ -140,13 +140,19 @@ jobs:
# ── 整合測試 B5 (2026-04-10) ──────────────────────────────────────────
# B5 整合測試 — postgres-test 由 services: 提供localhost:15432 直連
# 2026-04-10 Claude Sonnet 4.6: 用 psql 直連 localhost:15432 初始化 schema
# (docker exec 在 act runner 內無法取得 service container name)
- name: Integration Tests (B5 — 真實 DB)
run: |
cd apps/api
# 初始化 schema (用 docker exec 進 service container)
PG_CTR=$(docker ps --filter name=postgres-test --format '{{.Names}}' | head -1)
docker exec -i "$PG_CTR" \
psql -U awoooi -d awoooi_test < tests/integration/setup_test_schema.sql
# 安裝 psql client (runner 層級持久,首次才裝)
if ! command -v psql &>/dev/null; then
apt-get install -y -q postgresql-client
fi
# 初始化 schema — 直連 service container (localhost:15432)
PGPASSWORD=awoooi_test_2026 psql \
-h localhost -p 15432 -U awoooi -d awoooi_test \
-f tests/integration/setup_test_schema.sql
# 跑測試 — service container 在同網路localhost:15432 可連
TEST_DATABASE_URL="postgresql+asyncpg://awoooi:awoooi_test_2026@localhost:15432/awoooi_test?ssl=disable" \
/opt/api-venv/bin/pytest tests/integration/test_b5_core_flows.py -v --tb=short