-
Notifications
You must be signed in to change notification settings - Fork 31
137 lines (116 loc) · 4.78 KB
/
visual_regression_test.yml
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
132
133
134
135
136
137
name: Visuelle regresjonstester
on:
pull_request:
branches:
- main
paths:
- utils/**
- .github/workflows/visual_regression_test.yml
- "packages/jokul/src/**/*.spec.ts"
- "packages/jokul/src/**/*.scss"
- "packages/jokul/src/**/!(*.test).tsx"
- "pnpm-lock.yaml"
run-name: Kjør visuelle regresjonstester for ${{ github.event.pull_request.title }}
jobs:
tests:
if: ${{ !contains(github.event.sender.login, 'fremtind-bot') }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
strategy:
fail-fast: false
matrix:
SHARD: [1, 2, 3]
NUM_SHARDS: [3]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.BOT_PUBLISH_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Restore Monorepo Runner Cache
uses: actions/cache/restore@v3
with:
path: .nx
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nx-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Install dependencies
run: pnpm install
- name: Build packages
run: pnpm build
- name: Find Playwright version
shell: bash
run: |
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Playwright binary cache
uses: actions/cache@v3
id: playwright-cache
with:
path: /home/runner/.cache/ms-playwright
key: playwright-${{ env.PLAYWRIGHT_VERSION }}
restore-keys: |
playwright-
- name: Playwright binaries
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps chromium
- name: Run tests
run: pnpm integration:ci --shard ${{ matrix.SHARD }}/${{ matrix.NUM_SHARDS }}
- name: Upload Playwright report on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report-${{ matrix.SHARD }}.tar.gz
path: playwright-report/
- name: Upload Playwright test-results on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.SHARD }}.tar.gz
path: test-results/
- name: Check for new screenshots
id: check
run: |
echo "new-screenshots=$(if [ -z "$(git status --porcelain)" ]; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
- name: Upload screenshots
if: steps.check.outputs.new-screenshots == 'true'
uses: actions/upload-artifact@v4
with:
name: playwright-screenshots-${{ matrix.SHARD }}
path: |
packages/jokul/src/components/**/integration/__screenshots__/*
commit:
needs: [tests]
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.BOT_PUBLISH_TOKEN }}
- name: Download screenshots
uses: actions/download-artifact@v4
with:
pattern: playwright-screenshots-*
path: packages/jokul/src/components
merge-multiple: true
- name: Commit snapshots
run: |
git config user.email "fremtind.designsystem@fremtind.no"
git config user.name "fremtind-bot"
git add **/integration/__screenshots__/* || echo "No updated screenshots, nothing to add!"
git commit -m "chore: update integration screenshots [ci skip playwright]" --no-verify || echo "No updated screenshots, nothing to commit!"
git push