-
Notifications
You must be signed in to change notification settings - Fork 20
191 lines (167 loc) · 6.21 KB
/
performance-test-pr.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
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
# Этот workflow нельзя запускать параллельно.
# Весь смысл именно запуска в одной сессии, что бы избежать сильного разброса в результатах.
name: Component Performance Testing
on:
pull_request:
branches:
- master
pull_request_target:
branches:
- dev
concurrency:
# New commit on branch cancels running workflows of the same branch
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
authorize:
name: Authorize external pull request
uses: ./.github/workflows/authorize-external-pr.yml
scope:
needs: [authorize]
uses: ./.github/workflows/change-detection.yml
with:
exclude-dependents: true
ref: refs/pull/${{github.event.pull_request.number}}/merge
secrets: inherit
perftest:
needs: [authorize, scope]
if: ${{ needs.scope.outputs.HAS_SCOPE == 'true' }}
runs-on: ubuntu-latest
env:
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
PR_NAME: pr-${{ github.event.number }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: Install s3cmd
run: pip3 install s3cmd
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node modules
id: node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
node-modules-${{ hashFiles('package-lock.json') }}
node-modules-
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ~/.cache
key: cache-${{ hashFiles('package-lock.json') }}
restore-keys: |
cache-${{ hashFiles('package-lock.json') }}
cache-
- name: Setup packages for PR
if: ${{ steps.cache.outputs.cache-hit != 'true' && steps.node_modules.outputs.cache-hit != 'true' }}
run: npm ci --no-progress
- name: Lerna bootstrap for PR
run: >
npx lerna bootstrap
--scope=@salutejs/plasma-{core,hope,new-hope,web,b2c,asdk,ui,icons}
--scope=@salutejs/perftest-helpers
- name: Restore perftool cache
run: >
s3cmd
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }}
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
--host ${{ secrets.AWS_ENDPOINT }}
--host-bucket ${{ secrets.AWS_ENDPOINT }}
--bucket-location ${{ secrets.AWS_REGION }}
--signature-v2
--no-mime-magic
--no-preserve
sync
s3://${{ secrets.AWS_S3_BUCKET_2 }}/perftool-cache/
./.perftool/cache/
- name: Run performance test for PR
run: >
npx perftool
-o perftest/pr-result.json
--baseBranchRef ${{ github.event.pull_request.base.sha }}
--currentBranchRef ${{ github.event.pull_request.head.sha }}
- name: Save perftool cache
run: >
s3cmd
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }}
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
--host ${{ secrets.AWS_ENDPOINT }}
--host-bucket ${{ secrets.AWS_ENDPOINT }}
--bucket-location ${{ secrets.AWS_REGION }}
--signature-v2
--no-mime-magic
--no-preserve
sync
./.perftool/cache/
s3://${{ secrets.AWS_S3_BUCKET_2 }}/perftool-cache/
- uses: actions/checkout@v4
with:
show-progress: false
ref: ${{ github.event.pull_request.base.ref }}
clean: false
- name: Cache node modules
id: node_modules_base
uses: actions/cache/restore@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
node-modules-${{ hashFiles('package-lock.json') }}
node-modules-
- name: Cache dependencies
id: cache_base
uses: actions/cache@v3
with:
path: ~/.cache
key: cache-${{ hashFiles('package-lock.json') }}
restore-keys: |
cache-${{ hashFiles('package-lock.json') }}
cache-
- name: Setup packages for ${{ github.event.pull_request.base.ref }}
if: ${{ steps.cache_base.outputs.cache-hit != 'true' && steps.node_modules_base.outputs.cache-hit != 'true' }}
run: npm ci --no-progress
- name: Lerna bootstrap for ${{ github.event.pull_request.base.ref }}
run: >
npx lerna bootstrap
--scope=@salutejs/plasma-{core,hope,new-hope,web,b2c,asdk,ui,icons}
--scope=@salutejs/perftest-helpers
- name: Run performance test for ${{ github.event.pull_request.base.ref }}
run: >
npx perftool
-o perftest/base-result.json
--currentBranchRef ${{ github.event.pull_request.head.sha }}
- name: Compare test results
run: >
npx perftool-compare
-o perftest/comparison.json
perftest/pr-result.json
perftest/base-result.json
- name: Save comparison result
if: always()
uses: actions/upload-artifact@v2
with:
name: Component performance comparison result
path: /home/runner/work/plasma/plasma/perftest/*.json
- name: Write report comment
uses: ./actions/perftest-helpers/actions/write-comment
with:
token: ${{ secrets.GITHUB_TOKEN }}
reportPath: /home/runner/work/plasma/plasma/perftest/comparison.json
prId: ${{ github.event.number }}
owner: ${{ github.repository_owner }}
repo: plasma
- name: Send report
uses: ./actions/perftest-helpers/actions/send-report
with:
reportPath: /home/runner/work/plasma/plasma/perftest/comparison.json
commitHash: ${{ github.sha }}
subject: packages/plasma
referrer: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}