open-design/.github/workflows/visual-pr-verify.yml
Marc Chan c45c5c9764
fix(ci): align visual selectors and nix hashes (#2471)
* fix(ci): align visual selectors and nix hashes

* fix(ci): add strict PR visual verification

* fix(ci): repair visual-home captures

Generated-By: looper 0.8.1 (runner=fixer, agent=opencode)
2026-05-21 10:45:37 +08:00

66 lines
2.3 KiB
YAML

name: visual-pr-verify
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
permissions:
contents: read
concurrency:
group: visual-pr-verify-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
verify:
name: Strict PR visual tests
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Detect visual-relevant changes
id: changes
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
changed_files="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")"
if printf '%s\n' "$changed_files" | grep -Eq '^(apps/web/|\.github/actions/visual-screenshot/|\.github/workflows/visual-.*\.yml$|e2e/package\.json$|e2e/playwright\.visual\.config\.ts$|e2e/lib/playwright/|e2e/scripts/playwright\.ts$|e2e/scripts/visual-report\.ts$|e2e/ui/visual-.*\.test\.ts$|pnpm-lock\.yaml$)'; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "No visual-relevant file changes; skipping strict visual suite."
echo "should_run=false" >> "$GITHUB_OUTPUT"
- name: Prepare visual screenshot environment
if: ${{ steps.changes.outputs.should_run == 'true' }}
uses: ./.github/actions/visual-screenshot
- name: Run strict visual Playwright suite
if: ${{ steps.changes.outputs.should_run == 'true' }}
env:
OD_VISUAL_OUTPUT_DIR: ui/reports/visual-screenshots
run: |
pnpm -C e2e exec tsx scripts/playwright.ts clean
pnpm -C e2e exec playwright test -c playwright.visual.config.ts
- name: Upload visual debug artifact
if: ${{ always() && steps.changes.outputs.should_run == 'true' }}
uses: actions/upload-artifact@v7
with:
name: visual-pr-verify-${{ github.event.pull_request.number }}-${{ github.run_id }}
path: |
e2e/ui/reports/visual-screenshots
e2e/ui/reports/visual-results.json
if-no-files-found: ignore
retention-days: 7