-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (128 loc) · 5.53 KB
/
performance.yml
File metadata and controls
148 lines (128 loc) · 5.53 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
name: Performance Benchmarks
on:
pull_request:
branches: [main, dev]
workflow_dispatch:
inputs:
run-all:
description: 'Run all performance tests (including slow ones)'
required: false
default: 'false'
permissions:
contents: read
pull-requests: write
jobs:
performance:
name: Performance Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
relink-bins: true
- name: Install Playwright browsers
run: pnpm --filter @stackwright/e2e exec playwright install --with-deps chromium
- name: ⚡ Run build time benchmarks
id: build-time
env:
PERF_NO_SERVER: '1'
run: |
pnpm --filter @stackwright/e2e exec playwright test tests/performance/build-time.bench.ts --reporter=list
continue-on-error: true
- name: 📦 Run bundle size benchmarks
id: bundle-size
env:
PERF_NO_SERVER: '1'
run: |
pnpm --filter @stackwright/e2e exec playwright test tests/performance/bundle-size.bench.ts --reporter=list
continue-on-error: true
- name: 🌐 Run runtime vitals benchmarks
id: runtime-vitals
run: |
pnpm --filter @stackwright/e2e exec playwright test tests/performance/runtime-vitals.bench.ts --reporter=list
continue-on-error: true
- name: 📊 Generate performance report
if: always()
run: |
echo "## ⚡ Performance Benchmark Results" > performance-report.md
echo "" >> performance-report.md
if [ "${{ steps.build-time.outcome }}" == "success" ]; then
echo "### ✅ Build Time Benchmarks: PASSED" >> performance-report.md
elif [ "${{ steps.build-time.outcome }}" == "skipped" ]; then
echo "### ⏭️ Build Time Benchmarks: SKIPPED" >> performance-report.md
else
echo "### ❌ Build Time Benchmarks: FAILED" >> performance-report.md
fi
echo "" >> performance-report.md
if [ "${{ steps.bundle-size.outcome }}" == "success" ]; then
echo "### ✅ Bundle Size Benchmarks: PASSED" >> performance-report.md
elif [ "${{ steps.bundle-size.outcome }}" == "skipped" ]; then
echo "### ⏭️ Bundle Size Benchmarks: SKIPPED" >> performance-report.md
else
echo "### ❌ Bundle Size Benchmarks: FAILED" >> performance-report.md
fi
echo "" >> performance-report.md
if [ "${{ steps.runtime-vitals.outcome }}" == "success" ]; then
echo "### ✅ Runtime Vitals Benchmarks: PASSED" >> performance-report.md
elif [ "${{ steps.runtime-vitals.outcome }}" == "skipped" ]; then
echo "### ⏭️ Runtime Vitals Benchmarks: SKIPPED" >> performance-report.md
else
echo "### ❌ Runtime Vitals Benchmarks: FAILED" >> performance-report.md
fi
echo "" >> performance-report.md
echo "📝 **Note:** Detailed results are available in the job logs." >> performance-report.md
echo "" >> performance-report.md
echo "🎯 **Performance Budgets:**" >> performance-report.md
echo "- Build time: <70s total" >> performance-report.md
echo "- First-load JS: <100KB gzipped" >> performance-report.md
echo "- FCP: <1.5s, LCP: <2.5s, TTI: <3s" >> performance-report.md
- name: 💬 Comment PR with results
if: github.event_name == 'pull_request'
uses: actions/github-script@v9
continue-on-error: true
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('performance-report.md', 'utf8');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Performance Benchmark Results')
);
const commentBody = `${report}\n\n---\n*Updated: ${new Date().toISOString()}*`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
- name: 📤 Upload performance results
if: always()
uses: actions/upload-artifact@v4
with:
name: performance-results
path: |
performance-report.md
packages/e2e/test-results/
retention-days: 30
- name: ❌ Fail if performance budgets exceeded
if: steps.build-time.outcome == 'failure' || steps.bundle-size.outcome == 'failure' || steps.runtime-vitals.outcome == 'failure'
run: |
echo "❌ One or more performance benchmarks exceeded their budgets!"
echo "Review the logs and performance-report.md for details."
exit 1