generated from shayancoin/aieng-template-mvp
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (87 loc) · 2.59 KB
/
perf-light.yml
File metadata and controls
101 lines (87 loc) · 2.59 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
name: perf-light
on:
pull_request: {}
jobs:
k6:
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: perf-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Install k6
run: |
sudo apt-get update
sudo apt-get install -y k6
- name: Start stack
run: |
cd paform
docker compose --env-file .env.development -f docker-compose.dev.yml up -d --build
- name: Wait for API
run: |
cd paform
for i in {1..60}; do curl -sf http://localhost:8000/healthcheck && break || sleep 2; done
- name: Wait for Frontend
run: |
for i in {1..60}; do curl -sf http://localhost:3000/models/manifest.json && break || sleep 2; done
- name: Seed backend for perf
env:
BASE_URL: http://localhost:8000
run: |
cd paform
python - <<'PY'
import json
import os
import urllib.error
import urllib.request
BASE_URL = os.environ.get("BASE_URL", "http://localhost:8000")
def post(path: str, payload: dict) -> dict:
req = urllib.request.Request(
f"{BASE_URL}{path}",
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(req, timeout=10) as resp:
return json.loads(resp.read().decode("utf-8"))
except urllib.error.HTTPError as exc:
detail = exc.read().decode("utf-8", "ignore")
raise SystemExit(f"Seed request failed ({exc.code}): {detail}")
material = post(
"/api/materials/",
{"name": "Walnut", "texture_url": None, "cost_per_sq_ft": 12.5},
)
material_id = material.get("id")
if not material_id:
raise SystemExit("Material creation failed; missing id")
post(
"/api/modules/",
{
"name": "Base600",
"width": 600.0,
"height": 720.0,
"depth": 580.0,
"base_price": 100.0,
"material_id": material_id,
},
)
PY
- name: Run k6 light profile
env:
BASE_URL: http://localhost:8000
FRONTEND_BASE_URL: http://localhost:3000
run: |
cd paform
k6 run --summary-export k6-summary.json tests/perf/k6-quote-cnc.js
- name: Upload k6 summary
if: always()
uses: actions/upload-artifact@v4
with:
name: k6-summary
path: paform/k6-summary.json
- name: Shutdown stack
if: always()
run: |
cd paform
docker compose --env-file .env.development -f docker-compose.dev.yml down