From 7ca0014da2adcc18498ecd8258a23cdb8a0759b8 Mon Sep 17 00:00:00 2001 From: XiaoXia Bot Date: Thu, 16 Jul 2026 15:12:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20Validate=20job=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=8B=AC=E7=AB=8BPG=E5=AE=B9=E5=99=A8=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dalembic=E8=BF=81=E7=A7=BB=E6=A3=80=E6=9F=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5\n\n=E6=A0=B9=E5=9B=A0=EF=BC=9Aalembic=20upgrade=20hea?= =?UTF-8?q?d=20--sql=E9=9C=80=E8=A6=81=E8=BF=9E=E6=8E=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=AF=BB=E5=8F=96alembic=5Fversion=E8=A1=A8=EF=BC=8C\?= =?UTF-8?q?n=E4=BD=86Validate=20job=E6=B2=A1=E6=9C=89=E5=90=AF=E5=8A=A8Pos?= =?UTF-8?q?tgreSQL=E5=AE=B9=E5=99=A8=EF=BC=8CDATABASE=5FURL=E6=8C=87?= =?UTF-8?q?=E5=90=91=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E3=80=82\n\n=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=9C=A8Validate=20Ale?= =?UTF-8?q?mbic=20migrations=E6=AD=A5=E9=AA=A4=E5=89=8D=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=8B=AC=E7=AB=8BPG=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=EF=BC=8C\n=E7=94=A8=E9=9A=8F=E6=9C=BA=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=98=A0=E5=B0=84=EF=BC=8C=E9=80=9A=E8=BF=87GITHUB=5FENV?= =?UTF-8?q?=E6=9B=B4=E6=96=B0DATABASE=5FURL=E3=80=82\n=E6=AD=A5=E9=AA=A4?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E5=90=8E=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=EF=BC=88always()=E7=A1=AE=E4=BF=9D=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=B9=9F=E6=B8=85=E7=90=86=EF=BC=89=E3=80=82\n\n?= =?UTF-8?q?=E5=8F=82=E8=80=83PR=20#399=E7=9A=84=E5=AE=9E=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E6=9C=80=E5=B0=8F=E6=94=B9=E5=8A=A8=E7=89=88=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E6=8B=86=E5=88=86job=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci-cd.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 421d63385..d915f7f52 100755 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -129,6 +129,10 @@ jobs: bash -n scripts/init_production_env.sh ' + - name: Start PostgreSQL for validate (isolated container) + shell: sh + run: "set -eu\nPG_CONTAINER=\"ci-pg-validate-${GITHUB_RUN_ID:-$$}\"\necho \"PG_CONTAINER=$PG_CONTAINER\" >> \"$GITHUB_ENV\"\ndocker rm -f \"$PG_CONTAINER\" 2>/dev/null || true\ndocker run -d --name \"$PG_CONTAINER\" \\\n --shm-size=256m \\\n -e POSTGRES_USER=postgres \\\n -e POSTGRES_PASSWORD=postgres \\\n -e POSTGRES_DB=xiaoxia_saas \\\n -P \\\n --health-cmd \"pg_isready -U postgres\" \\\n --health-interval 3s \\\n --health-timeout 3s \\\n --health-retries 20 \\\n postgres:16-alpine\nPG_PORT=$(docker port \"$PG_CONTAINER\" 5432/tcp | cut -d: -f2)\necho \"PostgreSQL port: $PG_PORT\"\necho \"DATABASE_URL=postgresql+psycopg://postgres:postgres@127.0.0.1:$PG_PORT/xiaoxia_saas\" >> \"$GITHUB_ENV\"\nfor i in $(seq 1 30); do\n if docker inspect --format='{{.State.Health.Status}}' \"$PG_CONTAINER\" 2>/dev/null | grep -q healthy; then\n echo \"PostgreSQL is ready on port $PG_PORT\"\n break\n fi\n echo \"Waiting for PostgreSQL... ($i/30)\"\n sleep 2\ndone\ndocker inspect --format='{{.State.Health.Status}}' \"$PG_CONTAINER\" | grep -q healthy\n" + - name: Validate Alembic migrations shell: sh run: 'set -eu @@ -147,6 +151,14 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} run: "set -eu\npython3 scripts/check_migration_safety.py --allow-medium-risk --diff-against origin/develop\n" + - name: Cleanup PostgreSQL (validate) + if: always() + shell: sh + run: 'set +e + docker rm -f "${PG_CONTAINER:-ci-pg-validate}" 2>/dev/null || true + echo "PostgreSQL container cleaned up" + ' + - name: Job duration summary if: always() shell: sh