Skip to content

Commit 958a1e6

Browse files
authored
Update update_visual_snapshots.yml (#1198)
1 parent 4dfb1d3 commit 958a1e6

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

.github/workflows/update_visual_snapshots.yml

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,14 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
update:
12+
update-snapshots-runner:
1313
if: ${{ github.event.label.name == 'update snapshots' }}
14-
name: 'Update snapshots'
15-
runs-on:
16-
labels: ubuntu-latest-16-cores
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
shard: [1, 2, 3, 4]
1718
steps:
18-
- name: Generate token
19-
id: generate_token
20-
uses: actions/create-github-app-token@v1
21-
with:
22-
app-id: ${{ secrets.VRT_APP_ID }}
23-
private-key: ${{ secrets.VRT_PRIVATE_KEY }}
24-
- name: Checkout repository
25-
uses: actions/checkout@v4
26-
with:
27-
repository: ${{ github.event.pull_request.head.repo.full_name }}
28-
ref: ${{ github.head_ref }}
29-
token: ${{ steps.generate_token.outputs.token }}
19+
- uses: actions/checkout@v4
3020
- name: Set up Node
3121
uses: actions/setup-node@v4
3222
with:
@@ -52,9 +42,48 @@ jobs:
5242
sleep 5
5343
working-directory: docs/storybook
5444
- name: Run Visual Regression Tests
55-
run: npx playwright test --update-snapshots
45+
run: npx playwright test --update-snapshots --shard="${{ matrix.shard }}/${{ strategy.job-total }}"
5646
- name: Stop storybook
5747
run: kill ${{ steps.storybook.outputs.pid }}
48+
- name: Create snapshots.zip
49+
run: |
50+
if [[ ! -z $(git ls-files --others --exclude-standard --modified) ]]; then
51+
git ls-files --others --exclude-standard --modified | zip snapshots -@
52+
fi
53+
- name: Upload snapshots
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: snapshots-${{ matrix.shard }}
57+
path: snapshots.zip
58+
retention-days: 1
59+
if-no-files-found: ignore
60+
61+
update:
62+
name: 'Update snapshots'
63+
needs: update-snapshots-runner
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Generate token
67+
id: generate_token
68+
uses: actions/create-github-app-token@v1
69+
with:
70+
app-id: ${{ secrets.VRT_APP_ID }}
71+
private-key: ${{ secrets.VRT_PRIVATE_KEY }}
72+
- name: Checkout repository
73+
uses: actions/checkout@v4
74+
with:
75+
repository: ${{ github.event.pull_request.head.repo.full_name }}
76+
ref: ${{ github.head_ref }}
77+
token: ${{ steps.generate_token.outputs.token }}
78+
- uses: actions/download-artifact@v4
79+
with:
80+
path: snapshots
81+
pattern: snapshots-*
82+
- run: |
83+
for snapshots in snapshots/*/*.zip; do
84+
unzip -o "$snapshots" -d .
85+
done
86+
rm -rf snapshots
5887
- uses: stefanzweifel/git-auto-commit-action@v5
5988
with:
6089
commit_message: github-actions[bot] Regenerated snapshots

0 commit comments

Comments
 (0)