Repository navigation
368 lines (311 loc) · 11.3 KB
/
Copy pathpull_request_packages.yml
File metadata and controls
368 lines (311 loc) · 11.3 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
name: 'Pull Request / Packages'
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- '.husky/**'
- '.github/**'
- '!.github/actions/**'
- '.github/actions/**/*.yml'
- '**/*.md'
- '**/__image_snapshots__/*.webp'
concurrency:
group: pr-packages-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
changed_files:
runs-on: ubuntu-slim
name: Detect what files changed
permissions:
contents: read
pull-requests: read
outputs:
package_vkui: ${{ steps.changes.outputs.package_vkui }}
docs_storybook: ${{ steps.changes.outputs.docs_storybook }}
docs_website: ${{ steps.changes.outputs.docs_website }}
dependencies: ${{ steps.changes.outputs.dependencies }}
dot_github: ${{ steps.changes.outputs.dot_github }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Find changes
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: .github/file-filters.yml
linters:
runs-on: ubuntu-latest
name: Run linters
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup
uses: ./.github/actions/node-setup
- parallel:
- name: Run Biome format
run: node --run lint:format
- name: Run Stylelint
run: node --run lint:style
- name: Run types checking
run: node --run lint:types
- name: Run ESLint
run: node --run lint:es:ci
- name: Check if the generated files have been updated
run: node --run lint:generated-files
- name: Report lint results
if: ${{ !cancelled() }}
uses: VKCOM/gh-actions/VKUI/reporter@main
test:
name: Call reusable workflow
uses: ./.github/workflows/reusable_workflow_test.yml
test_report:
if: ${{ !cancelled() && (success() || failure()) }}
needs: test
runs-on: ubuntu-slim
name: Report unit test results
permissions:
contents: read
code-quality: write
steps:
- name: Download artifact
id: artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: test-output
- name: Report
uses: VKCOM/gh-actions/VKUI/reporter@main
- name: Upload coverage to GitHub
if: ${{ steps.artifact.outputs.found_artifact == 'true' }}
uses: actions/upload-code-coverage@2b21a77928be8d5168c2b9581a67f2adbebacc52 # v1.4.4
with:
file: .nyc_output/cobertura-coverage.xml
language: TypeScript
label: code-coverage/vitest
test_e2e:
if: ${{ needs.changed_files.outputs.package_vkui == 'true' }}
needs: changed_files
name: Call reusable workflow
permissions:
contents: read
id-token: write
code-quality: write
uses: ./.github/workflows/reusable_workflow_test_e2e.yml
test_e2e_prepare_and_upload_report:
if: ${{ !cancelled() && (success() || failure()) }}
needs: test_e2e
name: Prepare and upload e2e's HTML report artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup
uses: ./.github/actions/node-setup
- name: Download Playwright blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: packages/vkui/artifacts
- name: Prepare downloaded Playwright blob reports for merging
run: |
mkdir all-blob-reports
if [ -d packages/vkui/artifacts ]; then
for i in {1..10}
do
mv "packages/vkui/artifacts/all-blob-reports-${i}-10"/* all-blob-reports/
done
fi
rm -r packages/vkui/artifacts
shell: bash
- name: Merge Playwright blob reports into HTML Report
run: node --run playwright:cmd:merge-reports -- --reporter html ./all-blob-reports
- name: Upload Playwright HTML report to GitHub Actions Artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-report
path: playwright-report
retention-days: 30
build_package:
if: ${{ needs.changed_files.outputs.package_vkui == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
name: Build package
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup
uses: ./.github/actions/node-setup
- name: Generate archive
run: yarn workspace @vkontakte/vkui pack --out ../../out/_pkg.tgz
shell: bash
- name: Upload dist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package
path: out
analyze_bundle_size:
if: ${{ needs.changed_files.outputs.package_vkui == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
name: Analyze bundle size
env:
CI_JOB_NUMBER: 1
# Для Dependabot
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup
uses: ./.github/actions/node-setup
- uses: andresz1/size-limit-action@94bc357df29c36c8f8d50ea497c3e225c3c95d1d # v1.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: packages/vkui/
package_manager: yarn
# only affects current branch
skip_step: install
build_script: 'size:ci'
script: yarn run -T size-limit --json"
diff_build:
if: ${{ needs.changed_files.outputs.package_vkui == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
name: Generate Diff
steps:
- name: Checkout PR branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup (pr)
uses: ./.github/actions/node-setup
- name: Build vkui PR (pr)
working-directory: packages/vkui
run: |
node --run build
yarn exec biome format --write --config-path=diff.biome.json
- name: Checkout target
env:
BASE_REF: ${{ github.base_ref }}
run: |
git fetch origin "$BASE_REF" --depth=1
git checkout -f "$BASE_REF"
- name: Node setup (target)
uses: ./.github/actions/node-setup
- name: Rename dist folder from pr
working-directory: packages/vkui
run: |
mv dist pr_dist
- name: Build vkui (target)
working-directory: packages/vkui
run: |
node --run build
yarn exec biome format --write --config-path=diff.biome.json
- name: Generate diff
id: generate-diff
run: |
git diff --no-index packages/vkui/dist/ packages/vkui/pr_dist/ > code_diff.dif || true
if [ -s code_diff.dif ]; then
echo "has_diff=true" >> "$GITHUB_OUTPUT"
else
echo "has_diff=false" >> "$GITHUB_OUTPUT"
fi
- name: Generate HTML report
if: steps.generate-diff.outputs.has_diff == 'true'
run: |
mkdir diff
yarn run diff2html -i file -F diff/diff-report.html --summary open --title "VKUI Bundle Diff" --style side -- code_diff.dif
- name: Upload report
if: steps.generate-diff.outputs.has_diff == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: diff-report
path: diff/
docs_storybook_upload:
if: ${{ needs.changed_files.outputs.docs_storybook == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
name: Upload docs dist artifact (storybook)
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup
uses: ./.github/actions/node-setup
- name: Build
run: node --run docs:storybook:build
- name: Upload dist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: storybook-dist
path: packages/vkui/storybook-static
docs_website_upload:
if: ${{ needs.changed_files.outputs.docs_website == 'true' }}
needs: changed_files
runs-on: ubuntu-latest
name: Upload docs dist artifact
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Node setup
uses: ./.github/actions/node-setup
- name: Build VKUI
run: node --run build:vkui
- name: Build
run: node --run docs:website:build
env:
NEXT_PUBLIC_VKUI_DOCS_BASE_PATH: /pull/${{ github.event.pull_request.number }}/${{ github.event.pull_request.head.sha }}
- name: Upload dist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: docs-website-dist
path: website/out
upload_pr_workflow_payload:
# Дожидаемся выгрузки артефактов, на случай если вокрфлоу будет отменён или перезапушен
needs: [test, test_e2e_prepare_and_upload_report, docs_storybook_upload]
# Не используем always(), т.к. он не учитывает отмену воркфлоу
# см. https://github.com/orgs/community/discussions/26303
if: ${{ !cancelled() }}
name: Call reusable workflow
permissions:
actions: read
contents: read
uses: ./.github/workflows/reusable_workflow_pr_worfklow_payload.yml
with:
action: upload
check_dependencies:
if: ${{ needs.changed_files.outputs.dependencies == 'true' }}
needs: changed_files
runs-on: ubuntu-slim
name: Check dependencies
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Enable Corepack
run: corepack enable
shell: bash
- name: Setup NodeJS
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
run: YARN_ENABLE_SCRIPTS=false yarn install --immutable --check-cache --check-resolutions
pinact:
if: ${{ needs.changed_files.outputs.dot_github == 'true' }}
needs: changed_files
name: Check actions pin
runs-on: ubuntu-slim
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Pin actions
uses: suzuki-shunsuke/pinact-action@b1a1f46bb10f2908950d95f626ca8cc109e2cf7d # v3.1.0
with:
review: "true"
skip_push: "true"
github_token: ${{secrets.GITHUB_TOKEN}}