Files
full-stack-fastapi/.gitea/workflows/playwright.yml
魏风 30fd56f86e
Some checks failed
Deploy to Production / deploy (push) Successful in 34s
Test Backend / test-backend (push) Failing after 3m16s
Test Docker Compose / test-docker-compose (push) Failing after 1h4m50s
Playwright Tests / test-playwright (push) Failing after 36m21s
ci(gitea): install uv via venv to avoid PEP 668 on runners
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 10:59:34 +08:00

101 lines
3.4 KiB
YAML

name: Playwright Tests
on:
push:
branches:
- main
- bt
pull_request:
types:
- opened
- synchronize
workflow_dispatch:
jobs:
test-playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout
run: |
set -euo pipefail
git clone "http://172.17.0.1:3000/${{ github.repository }}.git" .
git checkout "${{ github.sha }}"
- name: Detect relevant file changes
id: changes
run: |
set -euo pipefail
CHANGED=false
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="${{ github.base_ref }}"
git fetch origin "+refs/heads/${BASE}:refs/remotes/origin/${BASE}" --depth=200 2>/dev/null \
|| git fetch origin --depth=200
if git rev-parse "origin/${BASE}" >/dev/null 2>&1; then
FILES=$(git diff --name-only "origin/${BASE}...HEAD" || true)
else
FILES=$(git show --name-only --pretty=format: HEAD)
fi
else
BEFORE="${{ github.event.before }}"
if [ -z "${BEFORE}" ] || [ "${BEFORE}" = "0000000000000000000000000000000000000000" ]; then
FILES=$(git show --name-only --pretty=format: HEAD)
else
FILES=$(git diff --name-only "${BEFORE}" "${{ github.sha }}" || true)
fi
fi
while IFS= read -r line; do
[ -z "${line}" ] && continue
case "${line}" in
backend/*|frontend/*|.env|compose*|.gitea/workflows/playwright.yml|.github/workflows/playwright.yml)
CHANGED=true
break
;;
esac
done <<< "${FILES}"
echo "changed=${CHANGED}" >> "${GITHUB_OUTPUT}"
echo "Relevant changes for Playwright: ${CHANGED}"
- name: Skip Playwright (no relevant changes)
if: steps.changes.outputs.changed != 'true'
run: echo "Skipping Playwright — no changes under backend/, frontend/, compose, .env, or playwright workflows."
- name: Install uv and Bun
if: steps.changes.outputs.changed == 'true'
run: |
set -euo pipefail
export PATH="${HOME}/.bun/bin:${PATH}"
export UV_PYTHON_DOWNLOADS=automatic
sudo apt-get update -qq
sudo apt-get install -y python3 python3-venv curl unzip ca-certificates
python3 -m venv /tmp/gitea-ci-venv
/tmp/gitea-ci-venv/bin/pip install --upgrade pip
/tmp/gitea-ci-venv/bin/pip install "uv>=0.4"
export PATH="/tmp/gitea-ci-venv/bin:${PATH}"
# Official Bun installer (not GitHub Actions)
curl -fsSL https://bun.sh/install | bash
- name: Generate client, build images, run Playwright
if: steps.changes.outputs.changed == 'true'
run: |
set -euo pipefail
export PATH="/tmp/gitea-ci-venv/bin:${HOME}/.bun/bin:${PATH}"
export BUN_INSTALL="${HOME}/.bun"
(cd backend && uv sync)
bun ci
bash scripts/generate-client.sh
docker compose build
docker compose down -v --remove-orphans || true
docker compose run --rm playwright bunx playwright test \
--fail-on-flaky-tests \
--trace=retain-on-failure
docker compose down -v --remove-orphans || true