fix: CI Validate改用docker run手动启动PostgreSQL(host模式不支持services)
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 134h32m40s
CI/CD Pipeline / Frontend Lint (push) Failing after 134h33m15s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 134h33m16s

This commit is contained in:
xiaoxia
2026-07-03 22:19:37 +08:00
parent 7c587001a6
commit f766c658a3
Executable → Regular
+35 -15
View File
@@ -19,21 +19,6 @@ jobs:
name: Validate Code Quality And Tests
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: xiaoxia_saas
ports:
- 5433:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql+psycopg://postgres:postgres@127.0.0.1:5433/xiaoxia_saas
USE_IN_MEMORY_DB: "false"
@@ -139,6 +124,34 @@ jobs:
set -eu
PYTHONPATH="$PWD/apps/api:$PWD" python3 -m pytest tests/unit -q
- name: Start PostgreSQL for integration tests
shell: sh
run: |
set -eu
# 清理可能残留的旧容器
docker rm -f ci-pg-validate 2>/dev/null || true
# 启动 PG 容器
docker run -d --name ci-pg-validate \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=xiaoxia_saas \
-p 5433:5432 \
--health-cmd "pg_isready -U postgres" \
--health-interval 5s \
--health-timeout 5s \
--health-retries 12 \
postgres:16
# 等待健康检查通过
for i in $(seq 1 30); do
if docker inspect --format='{{.State.Health.Status}}' ci-pg-validate 2>/dev/null | grep -q healthy; then
echo "PostgreSQL is ready"
break
fi
echo "Waiting for PostgreSQL... ($i/30)"
sleep 2
done
docker inspect --format='{{.State.Health.Status}}' ci-pg-validate | grep -q healthy
- name: Apply migrations for integration tests
shell: sh
run: |
@@ -151,6 +164,13 @@ jobs:
set -eu
PYTHONPATH="$PWD/apps/api:$PWD" python3 -m pytest tests/integration -q --timeout=60 -x
- name: Cleanup PostgreSQL
if: always()
shell: sh
run: |
docker rm -f ci-pg-validate 2>/dev/null || true
echo "PostgreSQL container cleaned up"
- name: Build summary
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
shell: sh