Skip to content

Prepare for v0.1.1

Prepare for v0.1.1 #46

name: Snapshot Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
issue_comment:
types: [created]
jobs:
# Main snapshot testing job - runs on push and PR
snapshot-tests:
if: github.event_name != 'issue_comment'
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
playwright install chromium --with-deps
- name: Run snapshot tests
run: |
pytest -m "snapshot"
- name: Upload snapshot test results
if: failure()
uses: actions/upload-artifact@v4
id: artifact-upload
with:
name: snapshot-test-results
path: |
tests/playwright/__snapshots__/
tests/playwright/__failures__/
retention-days: 30
- name: Comment on PR with snapshot differences
uses: thollander/actions-comment-pull-request@v3
if: ${{ failure() && github.event_name == 'pull_request' }}
with:
message: |
### 📸 Playwright visual snapshot differences detected
The snapshot tests have detected visual differences. Please review the changes:
📋 **[View test results](${{ steps.artifact-upload.outputs.artifact-url }})** to see the visual differences.
If the visual changes are expected and correct, comment `/approve-snapshots` to update the reference images.
# Update snapshots job - runs on comment trigger
update-snapshots:
if: |
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/approve-snapshots')
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: React to comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ github.event.comment.id }}
reactions: eyes
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
playwright install chromium --with-deps
- name: Update snapshots
continue-on-error: true
run: |
pytest -m "snapshot" --update-snapshots
- name: Commit and push updated snapshots
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Update visual snapshots'
file_pattern: 'tests/playwright/__snapshots__/**'
- name: Comment - Success
uses: thollander/actions-comment-pull-request@v3
with:
message: |
### ✅ Snapshots successfully updated!
The visual reference images have been updated and committed to this branch. The snapshot tests should now pass.