-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (133 loc) · 4.89 KB
/
Copy pathperformance-regression.yml
File metadata and controls
162 lines (133 loc) · 4.89 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
name: Performance Regression Check
concurrency:
group: performance-regression-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
pull_request:
paths:
- 'src/**'
- 'package.json'
- 'pnpm-lock.yaml'
push:
branches:
- main
permissions:
contents: read
jobs:
regression:
if: github.event_name == 'pull_request' && contains(join(github.event.pull_request.labels.*.name, ','), 'test-regression')
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: '24'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm build
- name: Restore main baseline
run: |
git fetch origin main --depth=1
git checkout origin/main -- bench/.baseline/performance-baseline.json || true
- name: Check for regressions
id: regression-check
run: |
if node bench/check-regression.js; then
echo "regression_detected=false" >> $GITHUB_OUTPUT
else
echo "regression_detected=true" >> $GITHUB_OUTPUT
fi
- name: Upload regression report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: regression-report
path: bench/.results/regression-report.md
if-no-files-found: ignore
- name: Comment PR with results
if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const fs = require('fs');
const path = require('path');
const reportPath = path.join(process.env.GITHUB_WORKSPACE, 'bench', '.results', 'regression-report.md');
if (!fs.existsSync(reportPath)) {
return;
}
const report = fs.readFileSync(reportPath, 'utf8');
const body = `🤖 **Performance Check Results**
${report}`;
const response = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const comments = response.data;
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Performance Check Results')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
- name: Fail if regression detected
if: steps.regression-check.outputs.regression_detected == 'true'
run: |
echo "❌ Performance regression detected! See report above."
exit 1
update-baseline:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: '24'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm build
- name: Capture baseline
run: node bench/capture-baseline.js
- name: Commit baseline updates
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add bench/.baseline/performance-baseline.json
git diff --staged --quiet || git commit -m "chore: update performance baseline [skip ci]"
git push || true