Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 60 additions & 11 deletions .github/actions/upload-screenshots/action.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,72 @@
---
name: 'Upload screenshots for debug'
description: 'To reproduce the issue locally, download the screenshots from the failed test'
name: 'Upload SnapDiff screenshots'
description: 'Upload screenshot diffs and HTML report as CI artifacts'
inputs:
name:
description: 'Customize the name of the artifact'
description: 'Artifact name prefix'
required: true
report-path:
description: 'Path to the HTML report directory'
default: 'tmp/snap_diff'
retention-days:
description: 'Number of days to retain artifacts'
default: '2'
outputs:
report-url:
description: 'Direct URL to the inline HTML report artifact'
value: ${{ steps.upload-report.outputs.artifact-url }}
report-full-url:
description: 'Direct URL to the full report artifact (with images)'
value: ${{ steps.upload-report-full.outputs.artifact-url }}
runs:
using: 'composite'
steps:
- uses: actions/upload-artifact@v6
- name: Upload screenshot diffs
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.name }}-diffs
retention-days: 1
path: |
test/fixtures/app/doc/screenshots/
retention-days: ${{ inputs.retention-days }}
path: test/fixtures/app/doc/screenshots/
if-no-files-found: ignore

- uses: actions/upload-artifact@v6
- name: Upload Capybara failure screenshots
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.name }}-capybara-fails
retention-days: 1
path: |
tmp/capybara/screenshots-diffs/
retention-days: ${{ inputs.retention-days }}
path: tmp/capybara/screenshots-diffs/
if-no-files-found: ignore

- name: Check for HTML report
id: check-report
shell: bash
run: |
if [ -f "${{ inputs.report-path }}/index.html" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Prepare HTML report for inline preview
if: steps.check-report.outputs.exists == 'true'
shell: bash
run: cp "${{ inputs.report-path }}/index.html" "${{ inputs.report-path }}/${{ inputs.name }}-snap_diff-report.html"

- name: Upload HTML report (inline preview)
id: upload-report
if: steps.check-report.outputs.exists == 'true'
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.name }}-snap_diff-report
retention-days: ${{ inputs.retention-days }}
path: ${{ inputs.report-path }}/${{ inputs.name }}-snap_diff-report.html
archive: false

- name: Upload HTML report with images (full download)
id: upload-report-full
if: steps.check-report.outputs.exists == 'true'
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.name }}-report-full
retention-days: ${{ inputs.retention-days }}
path: ${{ inputs.report-path }}/
73 changes: 71 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ name: Test
on:
push:
branches: [ master ]
paths:
- '**.gemfile'
- '**.rb'
- '.github/workflows/**'
- '.github/actions/**'
- 'Gemfile*'
- '!bin/**'
pull_request:
type: [ opened, synchronize, reopened, review_requested ]
types: [ opened, synchronize, reopened, review_requested ]
paths:
- '**.gemfile'
- '**.rb'
- '.github/workflows/**'
- '.github/actions/**'
- 'Gemfile*'
- '!bin/**'
workflow_dispatch:

Expand Down Expand Up @@ -52,6 +61,9 @@ jobs:
name: Functional Test
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
Expand All @@ -70,9 +82,46 @@ jobs:

- uses: ./.github/actions/upload-screenshots
if: failure()
id: upload-screenshots
with:
name: base-screenshots

- name: Find existing report comment
if: always() && github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Screenshot diffs'

- name: Comment PR with report link
if: failure() && github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
### Screenshot diffs detected

| Artifact | Link |
|----------|------|
| HTML report (inline preview) | ${{ steps.upload-screenshots.outputs.report-url || 'N/A' }} |
| Full report with images | ${{ steps.upload-screenshots.outputs.report-full-url || 'N/A' }} |
| [All artifacts](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts) | Browse all |

- name: Update comment on success
if: success() && github.event_name == 'pull_request' && steps.find-comment.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
### Screenshot diffs resolved

All screenshots match their baselines. Previous diffs have been fixed.

- name: Uploading Coverage Report
uses: actions/upload-artifact@v7
with:
Expand Down Expand Up @@ -170,6 +219,26 @@ jobs:
SCREENSHOT_DRIVER: ${{ matrix.screenshot-driver }}

- uses: ./.github/actions/upload-screenshots
if: always()
if: failure()
with:
name: screenshots-${{ matrix.capybara-driver }}-${{ matrix.screenshot-driver }}

test-report-upload:
name: Test Report Upload
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/setup-ruby-and-dependencies
with:
ruby-version: "4.0"
cache-apt-packages: true

- name: Generate sample report
run: bin/rake 'report:sample[embed]'

- uses: ./.github/actions/upload-screenshots
with:
name: test-report
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*.base.webp
.ruby-version
.ai/
.qwen/
.claude/
.specs/
.emdash.json
CLAUDE.md
Expand Down
Loading
Loading