984e05d8a0
- Add package.json to Storybook cache key (dep version changes invalidate cache) - Add res.ok check before parsing Storybook index JSON - Remove duplicate maxDiffPixelRatio (already in playwright.config.ts) - Use parseInt for PLAYWRIGHT_WORKERS to handle non-numeric values
104 lines
3.2 KiB
YAML
104 lines
3.2 KiB
YAML
name: Visual Regression Tests
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "packages/kilo-ui/**"
|
|
- "packages/ui/**"
|
|
- "packages/util/**"
|
|
- "packages/sdk/js/**"
|
|
- ".github/workflows/visual-regression.yml"
|
|
|
|
jobs:
|
|
visual-regression:
|
|
name: Visual Regression (kilo-ui)
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
ref: ${{ github.head_ref }}
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Cache Bun modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: bun-${{ hashFiles('bun.lock') }}
|
|
|
|
- name: Install dependencies
|
|
run: bun install
|
|
|
|
- name: Cache Playwright browsers
|
|
id: playwright-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ hashFiles('packages/kilo-ui/package.json') }}
|
|
|
|
- name: Install Playwright browsers
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
run: bunx playwright install chromium
|
|
working-directory: packages/kilo-ui
|
|
|
|
- name: Install Playwright system deps
|
|
run: bunx playwright install-deps chromium
|
|
working-directory: packages/kilo-ui
|
|
|
|
- name: Cache Storybook build
|
|
id: storybook-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: packages/kilo-ui/storybook-static
|
|
key: storybook-${{ hashFiles('packages/kilo-ui/src/**', 'packages/kilo-ui/.storybook/**', 'packages/ui/src/**', 'packages/kilo-ui/package.json') }}
|
|
|
|
- name: Build Storybook
|
|
if: steps.storybook-cache.outputs.cache-hit != 'true'
|
|
run: bun run build-storybook
|
|
working-directory: packages/kilo-ui
|
|
|
|
- name: Generate baselines for new/missing stories
|
|
run: bun run test:visual:update
|
|
working-directory: packages/kilo-ui
|
|
env:
|
|
CI: true
|
|
PLAYWRIGHT_WORKERS: "4"
|
|
|
|
- name: Commit and push new baselines (if any)
|
|
id: commit-baselines
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add packages/kilo-ui/tests/visual-regression.spec.ts-snapshots/
|
|
if git diff --cached --quiet; then
|
|
echo "No new baselines — nothing to commit."
|
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
git commit -m "chore: update visual regression baselines"
|
|
git lfs push --all origin
|
|
git push
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Fail if baselines changed
|
|
if: steps.commit-baselines.outputs.changed == 'true'
|
|
run: |
|
|
echo "::error::Visual regression baselines changed. New baselines have been committed to the branch. Please pull and review."
|
|
exit 1
|
|
|
|
- name: Upload test results on failure
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: visual-regression-results
|
|
path: packages/kilo-ui/test-results/
|
|
retention-days: 7
|