fix(ci): B5 整合測試改用 docker run — 解決 Gitea act services: container name 為空問題
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
services: 宣告在 Gitea act runner 中 container name 為空 改為 step 內直接 docker run pg-test-b5 (port 15433) + 清理 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,21 +47,8 @@ jobs:
|
||||
# 2026-04-02 Claude Code: 加入 timeout 防止 docker build/push 卡住超過 45 分鐘
|
||||
timeout-minutes: 45
|
||||
runs-on: ubuntu-latest
|
||||
# B5 整合測試用 service container — 與 runner 同網路,localhost:15432 可用
|
||||
services:
|
||||
postgres-test:
|
||||
image: pgvector/pgvector:pg16
|
||||
env:
|
||||
POSTGRES_DB: awoooi_test
|
||||
POSTGRES_USER: awoooi
|
||||
POSTGRES_PASSWORD: awoooi_test_2026
|
||||
ports:
|
||||
- 15432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U awoooi -d awoooi_test"
|
||||
--health-interval 5s
|
||||
--health-timeout 3s
|
||||
--health-retries 10
|
||||
# 2026-04-10 ogt: B5 改用 docker run 本地啟動,移除 services: 宣告
|
||||
# Gitea act runner 的 services: container name 為空,導致 CI 失敗
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -142,20 +129,36 @@ jobs:
|
||||
# B5 整合測試 — postgres-test 由 services: 提供,localhost:15432 直連
|
||||
# 2026-04-10 Claude Sonnet 4.6: 用 psql 直連 localhost:15432 初始化 schema
|
||||
# (docker exec 在 act runner 內無法取得 service container name)
|
||||
# B5: Gitea act runner 的 services: 實作與 GitHub Actions 不同
|
||||
# service container 啟動後需直連,但 act 的 container name 可能為空
|
||||
# 2026-04-10 ogt: 改用 docker run 本地啟動取代 services: 宣告
|
||||
- name: Integration Tests (B5 — 真實 DB)
|
||||
run: |
|
||||
cd apps/api
|
||||
# 安裝 psql client (runner 層級持久,首次才裝)
|
||||
# 安裝 psql client
|
||||
if ! command -v psql &>/dev/null; then
|
||||
apt-get install -y -q postgresql-client
|
||||
fi
|
||||
# 初始化 schema — 直連 service container (localhost:15432)
|
||||
# 啟動測試 DB(直接 docker run,避免 services: 容器名稱為空問題)
|
||||
docker run -d --name pg-test-b5 \
|
||||
-e POSTGRES_DB=awoooi_test \
|
||||
-e POSTGRES_USER=awoooi \
|
||||
-e POSTGRES_PASSWORD=awoooi_test_2026 \
|
||||
-p 15433:5432 \
|
||||
pgvector/pgvector:pg16
|
||||
# 等待就緒
|
||||
for i in $(seq 1 20); do
|
||||
PGPASSWORD=awoooi_test_2026 pg_isready -h localhost -p 15433 -U awoooi && break || sleep 2
|
||||
done
|
||||
# 初始化 schema
|
||||
PGPASSWORD=awoooi_test_2026 psql \
|
||||
-h localhost -p 15432 -U awoooi -d awoooi_test \
|
||||
-h localhost -p 15433 -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" \
|
||||
# 跑測試
|
||||
TEST_DATABASE_URL="postgresql+asyncpg://awoooi:awoooi_test_2026@localhost:15433/awoooi_test?ssl=disable" \
|
||||
/opt/api-venv/bin/pytest tests/integration/test_b5_core_flows.py -v --tb=short
|
||||
# 清理
|
||||
docker rm -f pg-test-b5 || true
|
||||
|
||||
- name: Login to Harbor
|
||||
uses: docker/login-action@v3
|
||||
|
||||
Reference in New Issue
Block a user