shinkan-jinkendo/.gitea/workflows/test.yml
Lars 50b8ff12cd
Some checks failed
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Failing after 10s
feat: enhance Playwright configuration and CI workflow for E2E testing
- Updated playwright.config.js to allow dynamic base URL configuration via environment variables, improving flexibility for different environments.
- Modified .gitea/workflows/test.yml to include steps for starting a development stack, seeding test data, and stopping the stack after tests, enhancing the CI process for end-to-end testing.
- Refactored login test in dev-smoke-test.spec.js to use a dedicated function for submitting the login form, improving code clarity and maintainability.
2026-04-29 12:35:30 +02:00

123 lines
4.0 KiB
YAML

name: Test Suite
on:
push:
branches: [main, develop]
workflow_run:
workflows: ["Deploy Development", "Deploy Production"]
types: [completed]
jobs:
lint-backend:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Check backend syntax
run: |
EVENT_NAME="${{ github.event_name }}"
REF_NAME="${{ github.ref_name }}"
RUN_WORKFLOW="${{ github.event.workflow_run.name }}"
APP_DIR="/home/lars/docker/shinkan"
if [ "$EVENT_NAME" = "workflow_run" ]; then
if [ "$RUN_WORKFLOW" = "Deploy Development" ]; then
APP_DIR="/home/lars/docker/shinkan-dev"
fi
elif [ "$REF_NAME" = "develop" ]; then
APP_DIR="/home/lars/docker/shinkan-dev"
fi
python3 -m py_compile "$APP_DIR/backend/main.py"
echo "✓ Backend syntax OK"
build-frontend:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Build frontend
run: |
EVENT_NAME="${{ github.event_name }}"
REF_NAME="${{ github.ref_name }}"
RUN_WORKFLOW="${{ github.event.workflow_run.name }}"
APP_DIR="/home/lars/docker/shinkan"
if [ "$EVENT_NAME" = "workflow_run" ]; then
if [ "$RUN_WORKFLOW" = "Deploy Development" ]; then
APP_DIR="/home/lars/docker/shinkan-dev"
fi
elif [ "$REF_NAME" = "develop" ]; then
APP_DIR="/home/lars/docker/shinkan-dev"
fi
cd "$APP_DIR/frontend"
npm install
npm run build
echo "✓ Frontend build OK"
playwright-tests:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Start dev stack for E2E
env:
DEV_ALLOWED_ORIGINS: http://127.0.0.1:3098,http://localhost:3098,http://host.docker.internal:3098,https://dev.shinkan.jinkendo.de
run: |
docker compose -f docker-compose.dev-env.yml up -d --build
echo "Warte auf Frontend + API (/health) …"
for i in $(seq 1 90); do
if curl -sf http://127.0.0.1:3098/health >/dev/null 2>&1; then
echo "Health OK (Versuch $i)"
exit 0
fi
sleep 2
done
echo "Timeout: /health nicht erreichbar"
curl -v http://127.0.0.1:3098/health || true
docker compose -f docker-compose.dev-env.yml logs --tail=120
exit 1
- name: Seed E2E test user (erste Registrierung in frischer DB)
env:
TEST_EMAIL: lars@stommer.com
TEST_PASSWORD: 12345678
run: |
curl -sf -X POST "http://127.0.0.1:3098/api/auth/register" \
-H "Content-Type: application/json" \
-d "{\"email\":\"${TEST_EMAIL}\",\"password\":\"${TEST_PASSWORD}\",\"name\":\"Playwright CI\"}" \
|| echo "(Registrierung übersprungen — Nutzer existiert evtl. schon)"
- name: Install Playwright
run: |
npm ci || npm install
npx playwright install --with-deps chromium
- name: Run Playwright tests
env:
PLAYWRIGHT_BASE_URL: http://127.0.0.1:3098
TEST_EMAIL: lars@stommer.com
TEST_PASSWORD: 12345678
run: |
mkdir -p screenshots
npx playwright test
echo "✓ Playwright tests passed"
- name: Stop dev stack
if: always()
run: docker compose -f docker-compose.dev-env.yml down
- name: Upload test screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-screenshots
path: screenshots/
retention-days: 7