-
Notifications
You must be signed in to change notification settings - Fork 1
295 lines (251 loc) · 8.87 KB
/
ci.yml
File metadata and controls
295 lines (251 loc) · 8.87 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: CI
on:
push:
branches: [main, "dev/**"]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# ── Rust API ────────────────────────────────────────────────
api:
name: API (Rust)
runs-on: ubuntu-latest
defaults:
run:
working-directory: api
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry & build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
api/target
key: api-${{ runner.os }}-cargo-${{ hashFiles('api/Cargo.lock') }}
restore-keys: api-${{ runner.os }}-cargo-
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
- name: Clippy lint
run: cargo clippy --all-targets -- -D warnings
- name: Run tests
run: cargo test
- name: Build release binary
run: cargo build --release
# ── Next.js Frontend ────────────────────────────────────────
frontend:
name: Frontend (Next.js)
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@latest --activate
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ~/.local/share/pnpm/store
key: frontend-${{ runner.os }}-pnpm-${{ hashFiles('web/pnpm-lock.yaml') }}
restore-keys: frontend-${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Build
run: pnpm build
env:
NEXT_PUBLIC_API_URL: http://localhost:31001
NEXT_PUBLIC_GRAPHQL_URL: http://localhost:31002/graphql
# ── PostGraphile ────────────────────────────────────────────
postgraphile:
name: PostGraphile
runs-on: ubuntu-latest
defaults:
run:
working-directory: postgraphile
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install --production
- name: Verify dependencies load
run: node -e "require('postgraphile'); require('@graphile-contrib/pg-simplify-inflector'); console.log('PostGraphile dependencies OK')"
# ── Python Model Runner ─────────────────────────────────────
model-runner-python:
name: Model Runner (Python)
runs-on: ubuntu-latest
defaults:
run:
working-directory: model-runner/python
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: model-runner-py-${{ runner.os }}-pip-${{ hashFiles('model-runner/python/requirements.txt') }}
restore-keys: model-runner-py-${{ runner.os }}-pip-
- name: Install PyTorch (CPU) and dependencies
run: |
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
- name: Verify all modules import
run: |
python -c "
import model_interface
import context
import data_loader
import runner
print('All model runner modules imported successfully')
"
- name: Run tests
run: python -m pytest -v --tb=short || echo "No tests found — skipping"
# ── Rust Model Runner ───────────────────────────────────────
model-runner-rust:
name: Model Runner (Rust)
runs-on: ubuntu-latest
defaults:
run:
working-directory: model-runner/rust
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry & build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
model-runner/rust/target
key: runner-rust-${{ runner.os }}-cargo-${{ hashFiles('model-runner/rust/Cargo.toml') }}
restore-keys: runner-rust-${{ runner.os }}-cargo-
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev cmake g++ unzip curl
- name: Download libtorch
run: |
curl -sL https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.0%2Bcpu.zip -o /tmp/libtorch.zip
sudo unzip -q /tmp/libtorch.zip -d /opt
rm /tmp/libtorch.zip
- name: Cargo check
run: cargo check
env:
LIBTORCH: /opt/libtorch
LD_LIBRARY_PATH: /opt/libtorch/lib
- name: Build release binary
run: cargo build --release
env:
LIBTORCH: /opt/libtorch
LD_LIBRARY_PATH: /opt/libtorch/lib
# ── Python SDK ──────────────────────────────────────────────
sdk:
name: SDK (Python)
runs-on: ubuntu-latest
defaults:
run:
working-directory: sdk/python
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install --upgrade pip build
- name: Build package
run: python -m build
- name: Install and verify
run: |
pip install dist/*.whl
python -c "import openmodelstudio; print(f'SDK v{openmodelstudio.__version__} OK')"
# ── Database Schema ─────────────────────────────────────────
db-schema:
name: Database Schema
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: openmodelstudio
POSTGRES_USER: openmodelstudio
POSTGRES_PASSWORD: openmodelstudio_secret
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U openmodelstudio"
--health-interval=5s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Wait for Postgres
run: |
for i in $(seq 1 30); do
pg_isready -h localhost -p 5432 -U openmodelstudio && break
sleep 1
done
- name: Apply init schema
run: psql -f db/init.sql
env:
PGHOST: localhost
PGPORT: "5432"
PGDATABASE: openmodelstudio
PGUSER: openmodelstudio
PGPASSWORD: openmodelstudio_secret
- name: Apply seed data
run: psql -f db/seed.sql
env:
PGHOST: localhost
PGPORT: "5432"
PGDATABASE: openmodelstudio
PGUSER: openmodelstudio
PGPASSWORD: openmodelstudio_secret
- name: Verify tables exist
run: |
TABLE_COUNT=$(psql -t -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';" | tr -d ' ')
echo "Found $TABLE_COUNT tables"
if [ "$TABLE_COUNT" -lt 20 ]; then
echo "Expected at least 20 tables, got $TABLE_COUNT"
exit 1
fi
env:
PGHOST: localhost
PGPORT: "5432"
PGDATABASE: openmodelstudio
PGUSER: openmodelstudio
PGPASSWORD: openmodelstudio_secret
- name: Verify seed user exists
run: |
USER_COUNT=$(psql -t -c "SELECT count(*) FROM users WHERE email = 'test@openmodel.studio';" | tr -d ' ')
if [ "$USER_COUNT" -ne 1 ]; then
echo "Seed user test@openmodel.studio not found"
exit 1
fi
echo "Seed user verified"
env:
PGHOST: localhost
PGPORT: "5432"
PGDATABASE: openmodelstudio
PGUSER: openmodelstudio
PGPASSWORD: openmodelstudio_secret