-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (127 loc) · 4.06 KB
/
ci.yml
File metadata and controls
152 lines (127 loc) · 4.06 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
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
python-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -e core -e planners -e worldmodels -e agents -e server
- name: Ruff
run: |
python -m ruff check .
python -m ruff format --check .
- name: Pytest
run: python -m pytest
web-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
run: npm ci
- name: Build Next.js app
env:
NEXT_PUBLIC_API_BASE: http://localhost:8000
run: npm run build
web-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -e core -e planners -e worldmodels -e agents -e server
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
working-directory: web
run: npm ci
- name: Install Playwright browser
working-directory: web
run: npx playwright install --with-deps chromium
- name: Start API server
run: |
mkdir -p .tmp
WMG_DB_URL=sqlite:///./.tmp/e2e.db \
WMG_STORAGE_DIR=./.tmp/e2e-storage \
WMG_UPLOAD_TOKEN=e2e-token \
WMG_AUTO_MIGRATE=true \
WMG_ENABLE_METRICS=false \
WMG_SEED_DEMO_DATA=true \
python -m uvicorn worldmodel_server.main:app --host 127.0.0.1 --port 8100 > .tmp/e2e-api.log 2>&1 &
echo $! > .tmp/e2e-api.pid
- name: Start web server
run: |
mkdir -p .tmp
cd web
INTERNAL_API_BASE=http://127.0.0.1:8100 \
NEXT_PUBLIC_API_BASE=http://127.0.0.1:8100 \
npm run dev -- --hostname 127.0.0.1 --port 3100 > ../.tmp/e2e-web.log 2>&1 &
echo $! > ../.tmp/e2e-web.pid
- name: Wait for local services
run: |
python - <<'PY'
import sys
import time
from urllib.request import urlopen
targets = [
"http://127.0.0.1:8100/healthz",
"http://127.0.0.1:3100",
]
deadline = time.time() + 120
pending = set(targets)
while pending and time.time() < deadline:
for target in list(pending):
try:
with urlopen(target, timeout=2) as response:
if response.status < 500:
pending.remove(target)
except Exception:
pass
if pending:
time.sleep(2)
if pending:
raise SystemExit(f"Services did not start in time: {sorted(pending)}")
PY
- name: Run Playwright smoke tests
working-directory: web
env:
PLAYWRIGHT_DISABLE_WEBSERVER: "1"
run: npm run test:e2e
- name: Dump server logs on failure
if: failure()
run: |
echo "===== API LOG ====="
cat .tmp/e2e-api.log || true
echo "===== WEB LOG ====="
cat .tmp/e2e-web.log || true
- name: Stop background services
if: always()
run: |
kill $(cat .tmp/e2e-api.pid) 2>/dev/null || true
kill $(cat .tmp/e2e-web.pid) 2>/dev/null || true