|
27 | 27 | description: The runner label to use. Defaults to `depot-ubuntu-latest` |
28 | 28 | required: false |
29 | 29 | default: depot-ubuntu-latest |
| 30 | + visual-regression: |
| 31 | + type: boolean |
| 32 | + description: Enable visual regression screenshot comparison |
| 33 | + required: false |
| 34 | + default: false |
| 35 | + visual-regression-update: |
| 36 | + type: boolean |
| 37 | + description: Update visual regression baselines (use on main branch) |
| 38 | + required: false |
| 39 | + default: false |
30 | 40 | secrets: |
31 | 41 | GCR_TOKEN: |
32 | 42 | description: A token to use for logging into Github Container Registry. If not provided, login does not occur. |
|
78 | 88 | - name: Login to Depot Registry |
79 | 89 | run: depot pull-token | docker login -u x-token --password-stdin registry.depot.dev |
80 | 90 |
|
| 91 | + - name: Prepare visual regression snapshots directory |
| 92 | + if: inputs.visual-regression |
| 93 | + working-directory: frontend |
| 94 | + run: mkdir -p e2e/visual-regression-snapshots |
| 95 | + |
| 96 | + - name: Download visual regression baselines |
| 97 | + if: inputs.visual-regression |
| 98 | + id: download-baseline |
| 99 | + continue-on-error: true |
| 100 | + uses: dawidd6/action-download-artifact@v6 |
| 101 | + with: |
| 102 | + github_token: ${{ secrets.GCR_TOKEN }} |
| 103 | + workflow: platform-docker-build-test-publish.yml |
| 104 | + branch: main |
| 105 | + name: visual-regression-baselines |
| 106 | + path: frontend/e2e/visual-regression-snapshots/ |
| 107 | + if_no_artifact_found: warn |
| 108 | + |
81 | 109 | - name: Run tests on dockerised frontend |
82 | 110 | working-directory: frontend |
83 | 111 | run: make test |
|
87 | 115 | E2E_IMAGE: ${{ inputs.e2e-image }} |
88 | 116 | E2E_CONCURRENCY: ${{ inputs.concurrency }} |
89 | 117 | E2E_RETRIES: 2 |
| 118 | + VISUAL_REGRESSION: ${{ inputs.visual-regression && '1' || '' }} |
| 119 | + VISUAL_REGRESSION_ARGS: ${{ inputs.visual-regression-update && '--update-snapshots' || '' }} |
90 | 120 | SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} |
91 | 121 | GITHUB_ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
92 | 122 | timeout-minutes: 20 |
@@ -165,3 +195,48 @@ jobs: |
165 | 195 | header: playwright-e2e-results |
166 | 196 | append: true |
167 | 197 | message: ${{ steps.report-summary-success.outputs.summary || steps.report-summary-failure.outputs.summary }} |
| 198 | + |
| 199 | + # Visual regression: after all E2E retries, run comparison and upload results |
| 200 | + - name: Upload visual regression baselines (main branch) |
| 201 | + if: always() && inputs.visual-regression-update |
| 202 | + uses: actions/upload-artifact@v4 |
| 203 | + with: |
| 204 | + name: visual-regression-baselines |
| 205 | + path: frontend/e2e/visual-regression-screenshots/ |
| 206 | + retention-days: 90 |
| 207 | + overwrite: true |
| 208 | + |
| 209 | + - name: Upload visual regression report |
| 210 | + if: always() && inputs.visual-regression && !inputs.visual-regression-update |
| 211 | + uses: actions/upload-artifact@v4 |
| 212 | + with: |
| 213 | + name: visual-regression-report-${{ github.run_id }}-${{ strategy.job-index }} |
| 214 | + path: frontend/e2e/visual-regression-report/ |
| 215 | + retention-days: 30 |
| 216 | + |
| 217 | + - name: Generate visual regression summary |
| 218 | + if: always() && inputs.visual-regression && !inputs.visual-regression-update && github.event_name == 'pull_request' |
| 219 | + id: visual-regression-summary |
| 220 | + shell: bash |
| 221 | + run: | |
| 222 | + if [ "${{ steps.download-baseline.outcome }}" != "success" ]; then |
| 223 | + echo "message=No baseline found — first run. Baselines will be generated after merge to main." >> $GITHUB_OUTPUT |
| 224 | + else |
| 225 | + SCREENSHOT_COUNT=$(find frontend/e2e/visual-regression-screenshots -name "*.png" 2>/dev/null | wc -l | tr -d ' ') |
| 226 | + REPORT_EXISTS=$(test -d frontend/e2e/visual-regression-report && echo "true" || echo "false") |
| 227 | + if [ "$REPORT_EXISTS" = "true" ]; then |
| 228 | + echo "message=$SCREENSHOT_COUNT screenshots compared. See report for details." >> $GITHUB_OUTPUT |
| 229 | + else |
| 230 | + echo "message=$SCREENSHOT_COUNT screenshots captured but comparison did not run." >> $GITHUB_OUTPUT |
| 231 | + fi |
| 232 | + fi |
| 233 | +
|
| 234 | + - name: Comment PR with visual regression results |
| 235 | + if: always() && inputs.visual-regression && !inputs.visual-regression-update && github.event_name == 'pull_request' && steps.visual-regression-summary.outputs.message |
| 236 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 237 | + with: |
| 238 | + header: visual-regression-results |
| 239 | + message: | |
| 240 | + ## Visual Regression |
| 241 | + ${{ steps.visual-regression-summary.outputs.message }} |
| 242 | + [View full report](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts) |
0 commit comments