-
-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (106 loc) · 3.65 KB
/
vrt-regression.yaml
File metadata and controls
131 lines (106 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: VRT regression
on:
workflow_call:
inputs:
skip:
description: 'if true, Skipping VRT'
required: false
default: false
type: boolean
workflow_dispatch:
inputs:
skip:
description: 'if true, Skipping VRT'
required: false
default: false
type: boolean
jobs:
vrt-regression-test:
name: Visual Regression Testing
runs-on: ubuntu-latest
permissions:
actions: read
steps:
- uses: actions/checkout@v4
if: ${{ !inputs.skip }}
with:
fetch-depth: 0
filter: blob:none
- name: Get changed contents
if: ${{ !inputs.skip }}
id: changed-files
uses: tj-actions/changed-files@da093c1609db0edd0a037ce9664e135f74bf30d9 # v40.2.0
with:
files_yaml: |
contents:
- src/content/posts/**
- public/assets/**.json
- name: Print changed files
if: ${{ !inputs.skip }}
run: |
echo ${{ steps.changed-files.outputs.contents_all_changed_and_modified_files }}
- uses: actions/setup-node@v4
if: ${{ !inputs.skip }}
with:
node-version-file: '.tool-versions'
cache: 'npm'
- name: Install dependencies
if: ${{ !inputs.skip }}
id: npm-install
run: |
npm ci
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
- name: Cache playwright binaries
if: ${{ !inputs.skip }}
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ steps.npm-install.outputs.PLAYWRIGHT_VERSION }}
restore-keys: playwright-
- name: Install playwright
if: ${{ !inputs.skip }}
run: npx playwright install chromium --with-deps
- name: Cache VRT snapshots
if: ${{ !inputs.skip }}
uses: actions/cache@v3
id: vrt-cache
with:
path: src/tests/vrt/snapshots
key: vrt-${{ vars.RECENT_ARTIFACTS_SHA256 }}
- name: Check snapshot exists
if: ${{ !inputs.skip }}
run: |
if [[ -z "$(ls -A src/tests/vrt/snapshots)" ]]; then
echo "### ⚠️ No snapshot exists" >> $GITHUB_STEP_SUMMARY
npm run vrt:init
else
echo "### ✅ Snapshot exists" >> $GITHUB_STEP_SUMMARY
fi
- name: Visual regression testing
if: ${{ !inputs.skip }}
run: |
if [[ -z "${{ steps.changed-files.outputs.contents_all_changed_and_modified_files }}" ]]; then
# コンテンツの変更がない
npm run vrt:regression -- --retries=3 --grep="update dependencies"
else
# コンテンツの変更がある
npm run vrt:regression -- --retries=3 --grep="add contents"
fi
- name: Upload failed screenshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: vrt-failed-screenshots-${{ github.sha }}
path: test-results
- name: Test Summary
if: ${{ !inputs.skip && always() }}
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2.1
with:
paths: "test-results/vrt.xml"
- uses: Kesin11/actions-timeline@baa62e018ca5504e2d617502ce1eacf9171e757a # v2.0.1
if: ${{ !inputs.skip && github.event.workflow == '.github/workflows/vrt-regression.yaml' }}
- name: Skipped
if: inputs.skip
run: echo "Skipped"