-
Notifications
You must be signed in to change notification settings - Fork 203
133 lines (115 loc) · 4.37 KB
/
Copy pathupdate_screens.yml
File metadata and controls
133 lines (115 loc) · 4.37 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
132
133
name: 'Update screenshots'
on:
workflow_dispatch:
push:
branches:
- v6
- v7
- '*-stable'
run-name: Update screenshots for ${{ github.ref_name }}
jobs:
get_playwright_docker_image:
runs-on: ubuntu-slim
outputs:
image: ${{ steps.result.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
# Создаем кэш для ветки один раз
- name: Checkout LFS objects
uses: ./.github/actions/lfs
with:
apt_mirror: ${{ vars.APT_MIRROR }}
- 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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Checkout LFS objects
uses: ./.github/actions/lfs
with:
apt_mirror: ${{ vars.APT_MIRROR }}
sudo_cmd: ''
- name: Install rsync && zip
run: |
apt-get install -y rsync zip
- 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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: screenshots-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
path: packages/vkui/screenshots-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}.zip
collect_all_chnages_and_push:
runs-on: ubuntu-slim
permissions:
pull-requests: write
contents: write
needs: [update_screens]
name: 'Collect updated screenshots and push changes'
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Download artifacts
id: artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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 "actions@github.com"
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@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
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