Add Playwright UI tests and before/after screenshots to CI
Lint / UI screenshots (before/after) (push) Skipped
Lint / JS (eslint) (push) Successful in 16s
Lint / PHP (phpcs PSR-12) (push) Successful in 30s
Lint / PHP requirements (version + extensions) (push) Successful in 50s
Lint / UI (playwright) (push) Successful in 3m29s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped
Security / PHP Security (semgrep) (push) Successful in 2m59s
Lint / JS (eslint) (pull_request) Successful in 16s
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 33s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 32s
Lint / UI (playwright) (pull_request) Successful in 2m23s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (pull_request) Successful in 1m32s
Lint / UI screenshots (before/after) (pull_request) Successful in 4m14s

New UI (playwright) job: PHP and MariaDB inside the Playwright image, a
seeded instance (tests/ui/stack.sh, synthetic data only) and 21 tests:
every main page loads with no page errors, console errors or failed
requests, description and comment markdown render safely (#114), and
pages fit a phone screen. Deploys now wait for it.

New UI screenshots (before/after) job: for PRs that change assets/ or
views/, runs the base branch and the PR side by side with the same data
and uploads one side-by-side PNG per page and view (dark, light, phone).
Modelled on Pulse's ui and ui-screenshots jobs.

Fixes found while building it:
- migrate.php split statements on semicolons inside -- comments, so 001
  and 003 failed on a fresh database.
- API endpoints applied rate limiting before loading config, so
  RATE_LIMIT_DEFAULT/RATE_LIMIT_API from .env and TRUSTED_PROXIES were
  ignored there: every user behind the proxy shared one per-IP bucket.
  The limiter now loads config itself; the per-IP limits are configurable
  (RATE_LIMIT_IP, RATE_LIMIT_IP_API) with unchanged defaults.
- The avatar error fallback was registered in the footer, after the
  header avatar, so a fast 404 left a broken image instead of initials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 19:06:52 -05:00
1 parent bdc6028572
commit f1decca31f
22 files changed
+777 -8

No files matched your search

+82 -2
View File
@@ -52,10 +52,90 @@ jobs:
- name: Verify runtime requirements
run: php scripts/check_requirements.php
ui:
name: UI (playwright)
runs-on: ubuntu-latest
timeout-minutes: 30
# Official image with Chromium and its system libraries; its version must
# match @playwright/test in tests/ui/package.json.
container: mcr.microsoft.com/playwright:v1.64.1-noble@sha256:2f05f8a734509a7b3f26a912639488ee08f58a7b292d14d62271bcff9038768f
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false # no job pushes; keep the token out of .git/config
- name: Install PHP and MariaDB
run: tests/ui/setup.sh
- name: Start Tinker Tickets (port 8400, seeded test data)
run: tests/ui/stack.sh . 8400 tinker_ui
- name: Install Playwright (lockfile only)
working-directory: tests/ui
run: npm ci
- name: Run Playwright (desktop and mobile)
working-directory: tests/ui
run: npx playwright test
- name: Server log
if: always()
run: tail -n 200 .ui-stack/server.log || true
- name: Upload report, traces and screenshots
if: failure()
uses: actions/upload-artifact@c6a3b2bd78b3985e4b2f15397fec357f0fd808de # v3.2.2-node20 (v4 is unsupported on Gitea)
with:
name: playwright-report
path: |
tests/ui/playwright-report/
tests/ui/test-results/
retention-days: 14
ui-screenshots:
name: UI screenshots (before/after)
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event_name == 'pull_request'
container: mcr.microsoft.com/playwright:v1.64.1-noble@sha256:2f05f8a734509a7b3f26a912639488ee08f58a7b292d14d62271bcff9038768f
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false # no job pushes; keep the token out of .git/config
fetch-depth: 0
- name: Did this PR change the UI?
id: ui
run: |
git config --global --add safe.directory "$PWD"
if git diff --quiet "$BASE_SHA" HEAD -- assets/ views/; then
echo "No UI files changed; no screenshots needed."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Install PHP and MariaDB
if: steps.ui.outputs.changed == 'true'
run: tests/ui/setup.sh
- name: Start this PR's Tinker Tickets (port 8400)
if: steps.ui.outputs.changed == 'true'
run: tests/ui/stack.sh . 8400 tinker_ui
- name: Start the base branch's Tinker Tickets (port 8401)
if: steps.ui.outputs.changed == 'true'
run: |
git worktree add /tmp/base "$BASE_SHA"
tests/ui/stack.sh /tmp/base 8401 tinker_ui_base
- name: Capture before/after screenshots
if: steps.ui.outputs.changed == 'true'
run: |
(cd tests/ui && npm ci)
node tests/ui/screenshots.js ui-screenshots before=http://127.0.0.1:8401 after=http://127.0.0.1:8400
- name: Upload screenshots
if: steps.ui.outputs.changed == 'true'
uses: actions/upload-artifact@c6a3b2bd78b3985e4b2f15397fec357f0fd808de # v3.2.2-node20 (v4 is unsupported on Gitea)
with:
name: ui-screenshots
path: ui-screenshots/
retention-days: 30
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [php-lint, js-lint, requirements]
needs: [php-lint, js-lint, requirements, ui]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development')
permissions:
contents: write
@@ -94,7 +174,7 @@ jobs:
notify-failure:
name: Notify on failure
runs-on: ubuntu-latest
needs: [php-lint, js-lint, requirements]
needs: [php-lint, js-lint, requirements, ui]
if: failure() && github.event_name == 'push'
steps:
- name: Send Matrix alert