generated from lightspeedwp/block-theme-scaffold
-
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (146 loc) · 5.8 KB
/
performance.yml
File metadata and controls
177 lines (146 loc) · 5.8 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Performance Monitoring
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
schedule:
- cron: '0 2 * * 1' # Weekly on Monday at 2 AM
jobs:
lighthouse:
name: Lighthouse CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build theme assets
run: npm run build
- name: Setup WordPress test environment
run: |
docker run -d --name wordpress \
-p 8888:80 \
-e WORDPRESS_DB_HOST=mysql \
-e WORDPRESS_DB_USER=wordpress \
-e WORDPRESS_DB_PASSWORD=wordpress \
-e WORDPRESS_DB_NAME=wordpress \
wordpress:latest
docker run -d --name mysql \
-e MYSQL_ROOT_PASSWORD=rootpass \
-e MYSQL_DATABASE=wordpress \
-e MYSQL_USER=wordpress \
-e MYSQL_PASSWORD=wordpress \
mysql:8.0
- name: Wait for WordPress
run: |
timeout 60 bash -c 'until curl -f http://localhost:8888; do sleep 2; done'
- name: Activate theme
run: |
docker exec wordpress wp theme activate block-theme-scaffold --allow-root
- name: Create sample content
run: |
docker exec wordpress wp post create \
--post_title="Sample Post" \
--post_content="Sample content for testing" \
--post_status=publish \
--allow-root
- name: Run Lighthouse CI
run: npx @lhci/cli@0.13.x autorun
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
- name: Upload Lighthouse reports
uses: actions/upload-artifact@v4
if: always()
with:
name: lighthouse-reports
path: lighthouse-reports/
retention-days: 30
bundle-size:
name: Bundle Size Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build for production
run: npm run build
- name: Check bundle size
run: npm run size-limit
- name: Analyze bundle
run: npm run analyze-bundle
continue-on-error: true
- name: Upload bundle analysis
uses: actions/upload-artifact@v4
if: always()
with:
name: webpack-bundle-report
path: build/bundle-report.html
retention-days: 30
performance-budget:
name: Performance Budget Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build theme
run: npm run build
- name: Check file sizes
run: |
echo "## Theme Asset Sizes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| File | Size | Gzipped |" >> $GITHUB_STEP_SUMMARY
echo "|------|------|---------|" >> $GITHUB_STEP_SUMMARY
for file in build/*.js build/*.css; do
if [ -f "$file" ]; then
size=$(wc -c < "$file" | numfmt --to=iec-i --suffix=B)
gzip_size=$(gzip -c "$file" | wc -c | numfmt --to=iec-i --suffix=B)
echo "| $(basename $file) | $size | $gzip_size |" >> $GITHUB_STEP_SUMMARY
fi
done
- name: Fail if size limits exceeded
run: npm run size-limit
core-web-vitals:
name: Core Web Vitals Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build theme
run: npm run build
- name: Analyze Core Web Vitals
run: |
echo "## Core Web Vitals Targets" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Target | Budget |" >> $GITHUB_STEP_SUMMARY
echo "|--------|--------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| First Contentful Paint (FCP) | ≤ 1.8s | Good |" >> $GITHUB_STEP_SUMMARY
echo "| Largest Contentful Paint (LCP) | ≤ 2.5s | Good |" >> $GITHUB_STEP_SUMMARY
echo "| Cumulative Layout Shift (CLS) | ≤ 0.1 | Good |" >> $GITHUB_STEP_SUMMARY
echo "| Total Blocking Time (TBT) | ≤ 200ms | Good |" >> $GITHUB_STEP_SUMMARY
echo "| Speed Index | ≤ 3.4s | Good |" >> $GITHUB_STEP_SUMMARY