ci(gitea): add offline-friendly test workflows and deploy on bt
Some checks failed
Deploy to Production / deploy (push) Failing after 2m57s
Playwright Tests / test-playwright (push) Failing after 22s
Test Backend / test-backend (push) Failing after 14s
Test Docker Compose / test-docker-compose (push) Has been cancelled

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
魏风
2026-05-11 10:33:38 +08:00
parent 3c9a0343e9
commit 5d50401d40
4 changed files with 174 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ on:
push: push:
branches: branches:
- main - main
- bt
jobs: jobs:
deploy: deploy:

View File

@@ -0,0 +1,98 @@
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}/.local/bin:${HOME}/.bun/bin:${PATH}"
export UV_PYTHON_DOWNLOADS=automatic
sudo apt-get update -qq
sudo apt-get install -y python3 python3-pip python3-venv curl unzip ca-certificates
python3 -m pip install --user --upgrade pip
python3 -m pip install --user "uv>=0.4"
# 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="${HOME}/.local/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

View File

@@ -0,0 +1,44 @@
name: Test Backend
on:
push:
branches:
- main
- bt
pull_request:
types:
- opened
- synchronize
jobs:
test-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout and run backend tests
run: |
set -euo pipefail
export PATH="${HOME}/.local/bin:${PATH}"
export UV_PYTHON_DOWNLOADS=automatic
git clone "http://172.17.0.1:3000/${{ github.repository }}.git" .
git checkout "${{ github.sha }}"
sudo apt-get update -qq
sudo apt-get install -y python3 python3-pip python3-venv ca-certificates
python3 -m pip install --user --upgrade pip
python3 -m pip install --user "uv>=0.4"
docker compose down -v --remove-orphans || true
docker compose up -d db mailcatcher
(cd backend && uv run bash scripts/prestart.sh)
(cd backend && uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}")
docker compose down -v --remove-orphans || true
if [ -d backend/htmlcov ]; then
echo "Coverage HTML generated under backend/htmlcov (view on runner if needed)."
fi
(cd backend && uv run coverage report --fail-under=90)

View File

@@ -0,0 +1,31 @@
name: Test Docker Compose
on:
push:
branches:
- main
- bt
pull_request:
types:
- opened
- synchronize
jobs:
test-docker-compose:
runs-on: ubuntu-latest
steps:
- name: Checkout and verify compose stack
run: |
set -euo pipefail
git clone "http://172.17.0.1:3000/${{ github.repository }}.git" .
git checkout "${{ github.sha }}"
docker compose build
docker compose down -v --remove-orphans || true
docker compose up -d --wait backend frontend adminer
curl -fsS http://localhost:8000/api/v1/utils/health-check
curl -fsS http://localhost:5173
docker compose down -v --remove-orphans || true