-
Notifications
You must be signed in to change notification settings - Fork 4
153 lines (127 loc) · 4.76 KB
/
performance.yml
File metadata and controls
153 lines (127 loc) · 4.76 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
name: Performance Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lighthouse:
name: Lighthouse CI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Install serve
run: npm install -g serve
- name: Start server
run: |
serve -s dist -p 3000 &
sleep 5
curl -f http://localhost:3000 || exit 1
- name: Run Lighthouse CI
uses: treosh/lighthouse-ci-action@v11
with:
configPath: './.lighthouserc.json'
uploadArtifacts: true
temporaryPublicStorage: true
env:
LHCI_BUILD_CONTEXT__GITHUB_REPO_SLUG: ${{ github.repository }}
LHCI_BUILD_CONTEXT__GITHUB_COMMIT_SHA: ${{ github.sha }}
- name: Generate Performance Report
if: always()
run: |
echo "## 🚀 Performance Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Lighthouse scores:" >> $GITHUB_STEP_SUMMARY
echo "- Performance: Check artifacts for detailed scores" >> $GITHUB_STEP_SUMMARY
echo "- Accessibility: Check artifacts for detailed scores" >> $GITHUB_STEP_SUMMARY
echo "- Best Practices: Check artifacts for detailed scores" >> $GITHUB_STEP_SUMMARY
echo "- SEO: Check artifacts for detailed scores" >> $GITHUB_STEP_SUMMARY
bundle-analysis:
name: Bundle Size Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build and analyze
run: |
npm run build
# Create bundle analysis
echo "## 📦 Bundle Analysis" >> bundle-report.md
echo "" >> bundle-report.md
echo "### JavaScript Bundles" >> bundle-report.md
echo '```' >> bundle-report.md
find dist -name "*.js" -exec du -h {} \; | sort -rh >> bundle-report.md
echo '```' >> bundle-report.md
echo "" >> bundle-report.md
echo "### CSS Bundles" >> bundle-report.md
echo '```' >> bundle-report.md
find dist -name "*.css" -exec du -h {} \; | sort -rh >> bundle-report.md
echo '```' >> bundle-report.md
echo "" >> bundle-report.md
echo "### Total Size" >> bundle-report.md
echo '```' >> bundle-report.md
du -sh dist >> bundle-report.md
echo '```' >> bundle-report.md
cat bundle-report.md >> $GITHUB_STEP_SUMMARY
- name: Check bundle size limits
run: |
# Set size limits (in KB)
MAX_JS_SIZE=1500
MAX_CSS_SIZE=100
# Check JS bundle size
JS_SIZE=$(find dist/assets -name "*.js" -exec du -k {} \; | sort -rn | head -1 | cut -f1)
if [ "$JS_SIZE" -gt "$MAX_JS_SIZE" ]; then
echo "❌ JS bundle exceeds limit: ${JS_SIZE}KB > ${MAX_JS_SIZE}KB"
exit 1
else
echo "✅ JS bundle within limit: ${JS_SIZE}KB <= ${MAX_JS_SIZE}KB"
fi
# Check CSS bundle size
CSS_SIZE=$(find dist/assets -name "*.css" -exec du -k {} \; | sort -rn | head -1 | cut -f1)
if [ "$CSS_SIZE" -gt "$MAX_CSS_SIZE" ]; then
echo "❌ CSS bundle exceeds limit: ${CSS_SIZE}KB > ${MAX_CSS_SIZE}KB"
exit 1
else
echo "✅ CSS bundle within limit: ${CSS_SIZE}KB <= ${MAX_CSS_SIZE}KB"
fi
- name: Upload bundle report
if: always()
uses: actions/upload-artifact@v4
with:
name: bundle-report
path: bundle-report.md
retention-days: 7
memory-leak-detection:
name: Memory Leak Detection
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run memory leak tests
run: |
# Run tests with memory tracking
node --expose-gc --max-old-space-size=4096 node_modules/.bin/vitest --run --reporter=verbose --config vite.config.test.js