-
Notifications
You must be signed in to change notification settings - Fork 58
82 lines (70 loc) · 2.25 KB
/
Copy pathload-test.yml
File metadata and controls
82 lines (70 loc) · 2.25 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
name: Load Test
on:
workflow_dispatch: # Manual trigger
pull_request:
paths:
- 'src/**'
- 'scripts/load/**'
- '.github/workflows/load-test.yml'
jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Start server
env:
PORT: '3000'
# 10 VUs × 3 endpoints over ~2 min exceeds the production defaults
# (100 req/min general, 10 req/min evaluate) and turns the smoke
# into a rate-limit test. CI needs the paths themselves to pass.
RATE_LIMIT_MAX_REQUESTS: '100000'
RATE_LIMIT_MAX_EVALUATE: '100000'
run: |
npm start &
echo $! > server.pid
sleep 5 # Wait for server to be ready
- name: Wait for server health
run: |
for i in {1..30}; do
if curl -f http://localhost:3000/health; then
echo "Server is ready"
exit 0
fi
echo "Waiting for server... ($i/30)"
sleep 2
done
echo "Server failed to start"
exit 1
- name: Run smoke test
run: npm run load:smoke
- name: Stop server
if: always()
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
fi
- name: Upload k6 results
if: always()
uses: actions/upload-artifact@v4
with:
name: k6-smoke-results
path: |
scripts/load/*.js
retention-days: 7