ci(e2e): 重构staging-e2e,改用playwright容器直接跑,去掉SSH依赖
CI/CD Pipeline / Build Production Runtime Images (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Failing after 19h31m20s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (push) Failing after 19h33m22s
CI/CD Pipeline / Frontend Lint (push) Failing after 19h34m18s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 19h34m18s

This commit is contained in:
灵应
2026-07-08 17:20:11 +08:00
parent 82ac0533bd
commit 9f1f2dea0e
+10 -38
View File
@@ -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