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>
61 lines
1.8 KiB
YAML
61 lines
1.8 KiB
YAML
# AWOOOI 整合測試用 Docker Compose
|
||
# ===================================
|
||
# 用途: CI 環境中提供完全隔離的 PostgreSQL + Redis
|
||
# 不用於生產環境
|
||
#
|
||
# 啟動: docker compose -f docker-compose.test.yml up -d
|
||
# 停止: docker compose -f docker-compose.test.yml down -v
|
||
#
|
||
# 2026-04-10 Claude Sonnet 4.6 Asia/Taipei
|
||
|
||
services:
|
||
postgres-test:
|
||
image: pgvector/pgvector:pg16
|
||
environment:
|
||
POSTGRES_DB: awoooi_test
|
||
POSTGRES_USER: awoooi
|
||
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
|
||
timeout: 3s
|
||
retries: 10
|
||
tmpfs:
|
||
- /var/lib/postgresql/data # 記憶體內 — 快 + 隔離
|
||
|
||
redis-test:
|
||
image: redis:7-alpine
|
||
ports:
|
||
- "16380:6379"
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
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 時才啟動
|