-
Notifications
You must be signed in to change notification settings - Fork 186
142 lines (120 loc) · 4.46 KB
/
update_screens.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
138
139
140
141
142
name: 'Update screenshots'
on:
workflow_dispatch:
push:
branches:
- '*-stable'
run-name: Update screenshots for ${{ github.ref_name }}
jobs:
get_playwright_docker_image:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.result.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/get-playwright-docker-image
id: result
update_screens:
needs: get_playwright_docker_image
if: success()
runs-on: ubuntu-latest
container:
image: ${{ needs.get_playwright_docker_image.outputs.image }}
options: --ipc=host
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
name: 'Run e2e tests for (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})'
steps:
- name: Checkout
uses: actions/checkout@v4
# см. https://github.com/actions/checkout/issues/1169
- name: Set safe directory
run: git config --global --add safe.directory /__w/VKUI/VKUI
# см. https://github.com/microsoft/playwright/issues/21920
- name: Install git lfs
run: |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
apt-get install -y git-lfs
- name: Install rsync
run: |
apt-get install -y rsync
- name: Install zip
run: |
apt-get install -y zip
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v4
with:
path: .git/lfs
key: lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Checkout LFS objects
run: git lfs pull
- name: Node setup
uses: ./.github/actions/node-setup
- name: Update screenshots
# Почему HOME=/root см. https://github.com/microsoft/playwright/issues/6500
run: HOME=/root yarn run test:e2e-update:ci --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Zip changed screenshots
id: zip-screenshots
run: |
git add ./**/*.png
mkdir screenshots
rsync -R $(git diff --name-only --cached --relative) screenshots
if [ -d screenshots/components ]; then
echo "needUpload=true" >> $GITHUB_OUTPUT
cd screenshots
zip -q -r ../../screenshots-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}.zip components
fi
shell: bash
working-directory: ./packages/vkui/src
- name: Upload archive
if: steps.zip-screenshots.outputs.needUpload == 'true'
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
path: packages/vkui/screenshots-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}.zip
collect_all_chnages_and_push:
runs-on: ubuntu-latest
needs: [update_screens]
name: 'Collect updated screenshots and push changes'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
id: artifacts
uses: actions/download-artifact@v4
with:
path: packages/vkui/artifacts
- name: Unzip archives
id: unzip
run: |
if [ -d artifacts ]; then
echo "found=true" >> $GITHUB_OUTPUT
cd artifacts
find . -type f -name 'screenshots-*.zip' -exec unzip -q -o -d ../src {} \;
fi
shell: bash
working-directory: ./packages/vkui
- name: Set Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Push updated screenshots
if: ${{ steps.unzip.outputs.found == 'true' && github.event_name != 'push' }}
uses: VKCOM/gh-actions/VKUI/push-screenshots@main
- name: Create pull request with updated screenshots
if: ${{ steps.unzip.outputs.found == 'true' && github.event_name == 'push' }}
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: 'ci(e2e): Update screenshots for ${{ github.ref_name }}'
branch: ${{ github.ref_name }}-screenshots-updates
commit-message: 'chore(e2e): update screenshots'
body: Automated screenshots updates
add-paths: |
**/*.png