From 9f1f2dea0e5ab225fa91fbb928dd7c2c1e34c5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=B5=E5=BA=94?= Date: Wed, 8 Jul 2026 17:20:11 +0800 Subject: [PATCH] =?UTF-8?q?ci(e2e):=20=E9=87=8D=E6=9E=84staging-e2e?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E7=94=A8playwright=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=B7=91=EF=BC=8C=E5=8E=BB=E6=8E=89SSH?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci-cd.yml | 48 ++++++++------------------------------ 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 7eb1eb01e..ae28fd604 100755 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -400,52 +400,24 @@ jobs: staging-e2e: name: Staging E2E Tests runs-on: saas + container: mcr.microsoft.com/playwright:v1.45.0-jammy if: github.ref_name == 'develop' || github.ref_name == 'main' needs: deploy-staging steps: - - name: Install SSH client - shell: sh - run: | - set -eu - apt-get update -qq && apt-get install -y -qq openssh-client >/dev/null 2>&1 - echo "openssh-client installed" + - name: Checkout + uses: actions/checkout@v4 - - name: Run Playwright E2E on staging server - shell: sh + - name: Run Playwright E2E on staging + working-directory: apps/web env: - STAGING_SSH_HOST: ${{ secrets.STAGING_SSH_HOST }} - STAGING_SSH_USER: ${{ secrets.STAGING_SSH_USER }} - STAGING_SSH_KEY: ${{ secrets.STAGING_SSH_KEY }} + E2E_BASE_URL: https://staging.xiaoxiajianji.com + E2E_API_BASE: https://staging-api.xiaoxiajianji.com/api/v1 + E2E_BROWSER_CHANNEL: chromium run: | set -eu - staging_host="${STAGING_SSH_HOST:-47.98.113.167}" - staging_user="${STAGING_SSH_USER:-root}" - if [ -f /root/.ssh/xiaoxia_runtime_builder ]; then - key_path="/root/.ssh/xiaoxia_runtime_builder" - elif [ -n "${STAGING_SSH_KEY:-}" ]; then - key_path="$HOME/.ssh/id_ed25519" - printf '%s\n' "$STAGING_SSH_KEY" > "$key_path" - chmod 600 "$key_path" - else - echo "ERROR: No SSH key available" - exit 1 - fi - ssh-keyscan -H "$staging_host" >> ~/.ssh/known_hosts - - # 在业务服务器上跑 Playwright E2E(用 host 网络访问 staging 3001/8000 端口) - ssh -i "$key_path" "$staging_user@$staging_host" ' - cd /var/lib/xiaoxia-saas-staging/repo - docker run --rm \ - -e E2E_BASE_URL=http://127.0.0.1:3001 \ - -e E2E_API_BASE=http://127.0.0.1:8000/api/v1 \ - -e E2E_BROWSER_CHANNEL=chromium \ - -v "$PWD:/workspace" \ - -w /workspace/apps/web \ - --network host \ - mcr.microsoft.com/playwright:v1.45.0-jammy \ - sh -lc "npm ci && npx playwright test --reporter=line --project=chromium" - ' + npm ci + npx playwright test --reporter=line --project=chromium build-production-runtime-images: name: Build Production Runtime Images