Skip to content

Commit 436e9ff

Browse files
author
Rúben Carvalho
authored
feat: Enable GH visual regression test action (#12)
1 parent 29a7754 commit 436e9ff

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Visual Regressions
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
env:
12+
VISUAL_REGRESSION_SNAPSHOT_DIRECTORY: "__image_snapshots__"
13+
14+
jobs:
15+
test:
16+
name: Run Tests
17+
runs-on: ubuntu-latest
18+
if: github.event.ref != 'refs/heads/main'
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: 18
24+
cache: "npm"
25+
- name: "Download artifacts"
26+
# Turns out you can not use artifacts from a previous workflow run.
27+
# I'm reluctant to check in the resulting screenshots into the repository,
28+
# which is why we use the following hack, until it's solved on Github side:
29+
# https://github.com/actions/download-artifact/issues/3
30+
run: |
31+
RUN_ID=`gh run --repo $GITHUB_REPOSITORY --branch main list --workflow "Visual Regressions" --json databaseId --jq .[0].databaseId`
32+
echo "Downloading snapshots created in run ${RUN_ID}"
33+
gh run --repo $GITHUB_REPOSITORY download ${RUN_ID} -n "visual-regression-snapshots" -D ${{ env.VISUAL_REGRESSION_SNAPSHOT_DIRECTORY }}
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- run: npm install
37+
- run: npm run build
38+
- run: npm run test:visual
39+
- uses: actions/upload-artifact@v3
40+
if: always()
41+
with:
42+
name: visual-regression-snapshots-results
43+
path: ${{ env.VISUAL_REGRESSION_SNAPSHOT_DIRECTORY }}
44+
update:
45+
name: Update Snapshots
46+
runs-on: ubuntu-latest
47+
if: github.event.ref == 'refs/heads/main'
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: actions/setup-node@v3
51+
with:
52+
node-version: 18
53+
cache: "npm"
54+
- run: npm install
55+
- run: npm run build
56+
- run: npm run test:visual:update
57+
- uses: actions/upload-artifact@v3
58+
with:
59+
name: visual-regression-snapshots
60+
path: ${{ env.VISUAL_REGRESSION_SNAPSHOT_DIRECTORY }}

vite.e2e-visual.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import process from "node:process";
44
import { defineConfig } from "vite";
5-
import base from "./vite.config.js";
5+
import base from "./vite.config.mjs";
66

77
// https://vitejs.dev/config/
88
export default defineConfig({

0 commit comments

Comments
 (0)