fix(ci): B5 整合測試改用 compose pytest-runner service
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m27s
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m27s
問題: runner 是 Docker-in-Docker,-v /opt/api-venv 掛到 host 路徑不存在 修正: - docker-compose.test.yml: 新增 pytest-runner service (python:3.11-slim) 在 compose 網路內跑,hostname=postgres-test 直連,自裝 deps - postgres-test: initdb.d 自動執行 setup_test_schema.sql,省去手動 psql - cd.yaml: 改用 --profile test + --exit-code-from pytest-runner Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,9 @@ services:
|
||||
POSTGRES_PASSWORD: awoooi_test_2026
|
||||
ports:
|
||||
- "15432:5432"
|
||||
# 啟動時自動執行 setup_test_schema.sql (initdb.d 機制)
|
||||
volumes:
|
||||
- ./tests/integration/setup_test_schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U awoooi -d awoooi_test"]
|
||||
interval: 5s
|
||||
@@ -34,3 +37,24 @@ services:
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
# 2026-04-10 Claude Sonnet 4.6 Asia/Taipei: 整合測試 runner
|
||||
# 在 compose 網路內跑 pytest,hostname=postgres-test 直連,不依賴 host venv
|
||||
pytest-runner:
|
||||
image: python:3.11-slim
|
||||
working_dir: /workspace
|
||||
volumes:
|
||||
- .:/workspace
|
||||
environment:
|
||||
TEST_DATABASE_URL: "postgresql+asyncpg://awoooi:awoooi_test_2026@postgres-test:5432/awoooi_test?ssl=disable"
|
||||
depends_on:
|
||||
postgres-test:
|
||||
condition: service_healthy
|
||||
redis-test:
|
||||
condition: service_healthy
|
||||
command: >
|
||||
sh -c "pip install -q uv &&
|
||||
uv pip install -q --system -e '.[dev]' &&
|
||||
pytest tests/integration/test_b5_core_flows.py -v --tb=short"
|
||||
profiles:
|
||||
- test # 只在明確指定 --profile test 時才啟動
|
||||
|
||||
Reference in New Issue
Block a user