forked from salute-developers/plasma
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (109 loc) · 3.73 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
name: Component Performance Testing
on:
pull_request:
branches:
- rc
- master
jobs:
perftest:
runs-on: ubuntu-latest
env:
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
PR_NAME: pr-${{ github.event.number }}
ICONS_PUBLIC_URL: /icons
steps:
- uses: actions/checkout@v2
with:
ref: master
- name: Prepare repository for master
run: git fetch --unshallow --tags
- name: Setup Node.js for master
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Cache node modules for master
uses: actions/cache@v1
with:
path: node_modules
key: npm-deps-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-deps-${{ hashFiles('package-lock.json') }}
- name: Setup packages for master
run: |
npm install [email protected] -g
npm ci
npx lerna bootstrap
- name: Use Node.js 16.15.x for master
uses: actions/setup-node@v1
with:
node-version: 16.15.x
- name: Run performance test for master
run: |
(cd ./packages/plasma-ui && npx perftool)
- name: Copy master report result
run: |
cp ./packages/plasma-ui/perftest/result.json master-result.json
- uses: actions/checkout@v2
with:
clean: false
- name: Setup Node.js for PR
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Cache node modules for PR
uses: actions/cache@v1
with:
path: node_modules
key: npm-deps-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-deps-${{ hashFiles('package-lock.json') }}
- name: Setup packages for PR
run: |
npm install [email protected] -g
npm ci
npx lerna bootstrap
- name: Use Node.js 16.15.x for PR
uses: actions/setup-node@v1
with:
node-version: 16.15.x
- name: Run performance test for PR
run: |
(cd ./packages/plasma-ui && npx perftool)
- name: Copy master report to PR report directory
run: |
cp master-result.json ./packages/plasma-ui/perftest/master-result.json
- name: Compare test results
run: |
(cd ./packages/plasma-ui && npx perftool-compare ./perftest/result.json ./perftest/master-result.json)
- name: Save comparison result
uses: actions/upload-artifact@v2
with:
name: Component performance comparison result
path: /home/runner/work/plasma/plasma/packages/plasma-ui/perftest/*.json
- name: Post result comment
if: always()
uses: actions/github-script@v3
with:
github-token: ${{secrets.GH_TOKEN}}
script: |
let report = require('/home/runner/work/plasma/plasma/packages/plasma-ui/perftest/comparison.json');
let result = report.hasSignificantNegativeChanges
? '🔴 Fail'
: '🟢 Success'
const commentBody = `
**Component performance testing**
Result: **${result}**
Check out report in job artifacts!
`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody,
})
- name: Send report
run: |
./scripts/perftool-send-report.js \
--reportPath /home/runner/work/plasma/plasma/packages/plasma-ui/perftest/comparison.json
env:
GITHUB_SHA: ${{ github.sha }}