-
Notifications
You must be signed in to change notification settings - Fork 20
178 lines (157 loc) · 7.22 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
# Этот 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
state:
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, state ]
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.state.outputs.STATE).HAS_PACKAGES_DS_CHANGES }}
env:
PR_NAME: pr-${{ github.event.number }}
steps:
- name: Install s3cmd
run: pip3 install s3cmd
- uses: actions/checkout@v4
with:
path: current
show-progress: false
ref: refs/pull/${{github.event.pull_request.number}}/merge
- uses: actions/checkout@v4
with:
path: baseline
show-progress: false
ref: ${{ github.event.pull_request.base.ref }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: 'current/.nvmrc'
cache: 'npm'
cache-dependency-path: 'current/package-lock.json'
- name: Cache node modules
id: node_modules_current
uses: actions/cache@v3
with:
path: current/node_modules
key: node-modules-${{ hashFiles('current/package-lock.json') }}
restore-keys: |
node-modules-${{ hashFiles('current/package-lock.json') }}
node-modules-
- name: Cache node modules
id: node_modules_base
uses: actions/cache/restore@v3
with:
path: baseline/node_modules
key: node-modules-${{ hashFiles('baseline/package-lock.json') }}
restore-keys: |
node-modules-${{ hashFiles('baseline/package-lock.json') }}
node-modules-
- name: Cache dependencies
id: cache_deps
uses: actions/cache@v3
with:
path: ~/.cache
key: cache-${{ hashFiles('current/package-lock.json') }}
restore-keys: |
cache-${{ hashFiles('current/package-lock.json') }}
cache-
- name: Setup packages for PR
if: ${{ steps.cache_deps.outputs.cache-hit != 'true' || steps.node_modules_current.outputs.cache-hit != 'true' }}
run: |
cd current
npm ci --no-progress
- name: Lerna bootstrap for PR
run: |
cd current
npx lerna bootstrap --scope=@salutejs/plasma-{core,hope,new-hope,web,b2c,asdk,ui,icons} --scope=@salutejs/perftest-helpers
- name: Setup packages for ${{ github.event.pull_request.base.ref }}
if: ${{ steps.cache_deps.outputs.cache-hit != 'true' || steps.node_modules_base.outputs.cache-hit != 'true' }}
run: |
cd baseline
npm ci --no-progress
- name: Lerna bootstrap for ${{ github.event.pull_request.base.ref }}
run: |
cd baseline
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/
./current/.perftool/cache/
- name: Run performance test
run: >
cd current &&
npx perftool
--baselineRefDir ../baseline
-o perftest/pr-result.json
--baselineOutputPath perftest/base-result.json
--compareOutputPath perftest/comparison.json
--visualReportPath perftest/report.html
--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
./current/.perftool/cache/
s3://${{ secrets.AWS_S3_BUCKET_2 }}/perftool-cache/
- name: Save comparison result
if: always()
uses: actions/upload-artifact@v2
with:
name: Component performance comparison result
path: ${{ github.workspace }}/current/perftest/*
- name: Write report comment
if: always()
uses: ./current/actions/perftest-helpers/actions/write-comment
with:
token: ${{ secrets.GITHUB_TOKEN }}
reportPath: ${{ github.workspace }}/current/perftest/comparison.json
prId: ${{ github.event.number }}
owner: ${{ github.repository_owner }}
repo: plasma
- name: Send report
if: always()
uses: ./current/actions/perftest-helpers/actions/send-report
with:
reportPath: ${{ github.workspace }}/current/perftest/comparison.json
commitHash: ${{ github.sha }}
subject: packages/plasma
referrer: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}