From b382c4e3eeab3c7f1d4f1d4d210f03b81b853583 Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Mon, 2 Mar 2026 15:09:40 +0100 Subject: [PATCH] fix: fail CI when visual regression baselines change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The workflow now: 1. Runs --update-snapshots to write new/changed baselines 2. Commits any changes back to the branch 3. Fails the job if baselines changed, so the PR author is notified This avoids silently accepting visual changes — the author must pull and review the updated baselines. --- .github/workflows/visual-regression.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/visual-regression.yml b/.github/workflows/visual-regression.yml index ae9f759a1de..8780f47d9e1 100644 --- a/.github/workflows/visual-regression.yml +++ b/.github/workflows/visual-regression.yml @@ -65,32 +65,35 @@ jobs: run: bun run build-storybook working-directory: packages/kilo-ui - - name: Generate missing baselines and run visual regression tests - run: | - # Write any missing platform-specific baselines (new stories, first run on linux, etc.) - bun run test:visual:update - # Compare — runs against the files now on disk; will pass if rendering is stable - bun run test:visual + - 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) - # Run even if tests fail so we can inspect what changed - if: always() + 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: add visual regression baselines for $(uname -s | tr '[:upper:]' '[:lower:]')" + 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