|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, "dev/**"] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ci-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + # ── Rust API ──────────────────────────────────────────────── |
| 16 | + api: |
| 17 | + name: API (Rust) |
| 18 | + runs-on: ubuntu-latest |
| 19 | + defaults: |
| 20 | + run: |
| 21 | + working-directory: api |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install Rust toolchain |
| 26 | + uses: dtolnay/rust-toolchain@stable |
| 27 | + with: |
| 28 | + components: clippy |
| 29 | + |
| 30 | + - name: Cache cargo registry & build |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.cargo/registry |
| 35 | + ~/.cargo/git |
| 36 | + api/target |
| 37 | + key: api-${{ runner.os }}-cargo-${{ hashFiles('api/Cargo.lock') }} |
| 38 | + restore-keys: api-${{ runner.os }}-cargo- |
| 39 | + |
| 40 | + - name: Install system dependencies |
| 41 | + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev |
| 42 | + |
| 43 | + - name: Clippy lint |
| 44 | + run: cargo clippy --all-targets -- -D warnings |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + run: cargo test |
| 48 | + |
| 49 | + - name: Build release binary |
| 50 | + run: cargo build --release |
| 51 | + |
| 52 | + # ── Next.js Frontend ──────────────────────────────────────── |
| 53 | + frontend: |
| 54 | + name: Frontend (Next.js) |
| 55 | + runs-on: ubuntu-latest |
| 56 | + defaults: |
| 57 | + run: |
| 58 | + working-directory: web |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Setup Node.js |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: 20 |
| 66 | + |
| 67 | + - name: Enable pnpm |
| 68 | + run: corepack enable && corepack prepare pnpm@latest --activate |
| 69 | + |
| 70 | + - name: Cache pnpm store |
| 71 | + uses: actions/cache@v4 |
| 72 | + with: |
| 73 | + path: ~/.local/share/pnpm/store |
| 74 | + key: frontend-${{ runner.os }}-pnpm-${{ hashFiles('web/pnpm-lock.yaml') }} |
| 75 | + restore-keys: frontend-${{ runner.os }}-pnpm- |
| 76 | + |
| 77 | + - name: Install dependencies |
| 78 | + run: pnpm install --frozen-lockfile |
| 79 | + |
| 80 | + - name: Lint |
| 81 | + run: pnpm lint |
| 82 | + |
| 83 | + - name: Build |
| 84 | + run: pnpm build |
| 85 | + env: |
| 86 | + NEXT_PUBLIC_API_URL: http://localhost:31001 |
| 87 | + NEXT_PUBLIC_GRAPHQL_URL: http://localhost:31002/graphql |
| 88 | + |
| 89 | + # ── PostGraphile ──────────────────────────────────────────── |
| 90 | + postgraphile: |
| 91 | + name: PostGraphile |
| 92 | + runs-on: ubuntu-latest |
| 93 | + defaults: |
| 94 | + run: |
| 95 | + working-directory: postgraphile |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Setup Node.js |
| 100 | + uses: actions/setup-node@v4 |
| 101 | + with: |
| 102 | + node-version: 20 |
| 103 | + |
| 104 | + - name: Install dependencies |
| 105 | + run: npm install --production |
| 106 | + |
| 107 | + - name: Verify dependencies load |
| 108 | + run: node -e "require('postgraphile'); require('@graphile-contrib/pg-simplify-inflector'); console.log('PostGraphile dependencies OK')" |
| 109 | + |
| 110 | + # ── Python Model Runner ───────────────────────────────────── |
| 111 | + model-runner-python: |
| 112 | + name: Model Runner (Python) |
| 113 | + runs-on: ubuntu-latest |
| 114 | + defaults: |
| 115 | + run: |
| 116 | + working-directory: model-runner/python |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + |
| 120 | + - name: Setup Python |
| 121 | + uses: actions/setup-python@v5 |
| 122 | + with: |
| 123 | + python-version: "3.11" |
| 124 | + |
| 125 | + - name: Cache pip |
| 126 | + uses: actions/cache@v4 |
| 127 | + with: |
| 128 | + path: ~/.cache/pip |
| 129 | + key: model-runner-py-${{ runner.os }}-pip-${{ hashFiles('model-runner/python/requirements.txt') }} |
| 130 | + restore-keys: model-runner-py-${{ runner.os }}-pip- |
| 131 | + |
| 132 | + - name: Install PyTorch (CPU) and dependencies |
| 133 | + run: | |
| 134 | + pip install --upgrade pip |
| 135 | + pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu |
| 136 | + pip install -r requirements.txt |
| 137 | +
|
| 138 | + - name: Verify all modules import |
| 139 | + run: | |
| 140 | + python -c " |
| 141 | + import model_interface |
| 142 | + import context |
| 143 | + import data_loader |
| 144 | + import runner |
| 145 | + print('All model runner modules imported successfully') |
| 146 | + " |
| 147 | +
|
| 148 | + - name: Run tests |
| 149 | + run: python -m pytest -v --tb=short || echo "No tests found — skipping" |
| 150 | + |
| 151 | + # ── Rust Model Runner ─────────────────────────────────────── |
| 152 | + model-runner-rust: |
| 153 | + name: Model Runner (Rust) |
| 154 | + runs-on: ubuntu-latest |
| 155 | + defaults: |
| 156 | + run: |
| 157 | + working-directory: model-runner/rust |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@v4 |
| 160 | + |
| 161 | + - name: Install Rust toolchain |
| 162 | + uses: dtolnay/rust-toolchain@stable |
| 163 | + |
| 164 | + - name: Cache cargo registry & build |
| 165 | + uses: actions/cache@v4 |
| 166 | + with: |
| 167 | + path: | |
| 168 | + ~/.cargo/registry |
| 169 | + ~/.cargo/git |
| 170 | + model-runner/rust/target |
| 171 | + key: runner-rust-${{ runner.os }}-cargo-${{ hashFiles('model-runner/rust/Cargo.toml') }} |
| 172 | + restore-keys: runner-rust-${{ runner.os }}-cargo- |
| 173 | + |
| 174 | + - name: Install system dependencies |
| 175 | + run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev cmake g++ unzip curl |
| 176 | + |
| 177 | + - name: Download libtorch |
| 178 | + run: | |
| 179 | + curl -sL https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.0%2Bcpu.zip -o /tmp/libtorch.zip |
| 180 | + sudo unzip -q /tmp/libtorch.zip -d /opt |
| 181 | + rm /tmp/libtorch.zip |
| 182 | +
|
| 183 | + - name: Cargo check |
| 184 | + run: cargo check |
| 185 | + env: |
| 186 | + LIBTORCH: /opt/libtorch |
| 187 | + LD_LIBRARY_PATH: /opt/libtorch/lib |
| 188 | + |
| 189 | + - name: Build release binary |
| 190 | + run: cargo build --release |
| 191 | + env: |
| 192 | + LIBTORCH: /opt/libtorch |
| 193 | + LD_LIBRARY_PATH: /opt/libtorch/lib |
| 194 | + |
| 195 | + # ── Python SDK ────────────────────────────────────────────── |
| 196 | + sdk: |
| 197 | + name: SDK (Python) |
| 198 | + runs-on: ubuntu-latest |
| 199 | + defaults: |
| 200 | + run: |
| 201 | + working-directory: sdk/python |
| 202 | + steps: |
| 203 | + - uses: actions/checkout@v4 |
| 204 | + |
| 205 | + - name: Setup Python |
| 206 | + uses: actions/setup-python@v5 |
| 207 | + with: |
| 208 | + python-version: "3.12" |
| 209 | + |
| 210 | + - name: Install build tools |
| 211 | + run: pip install --upgrade pip build |
| 212 | + |
| 213 | + - name: Build package |
| 214 | + run: python -m build |
| 215 | + |
| 216 | + - name: Install and verify |
| 217 | + run: | |
| 218 | + pip install dist/*.whl |
| 219 | + python -c "import openmodelstudio; print(f'SDK v{openmodelstudio.__version__} OK')" |
| 220 | +
|
| 221 | + # ── Database Schema ───────────────────────────────────────── |
| 222 | + db-schema: |
| 223 | + name: Database Schema |
| 224 | + runs-on: ubuntu-latest |
| 225 | + services: |
| 226 | + postgres: |
| 227 | + image: postgres:16 |
| 228 | + env: |
| 229 | + POSTGRES_DB: openmodelstudio |
| 230 | + POSTGRES_USER: openmodelstudio |
| 231 | + POSTGRES_PASSWORD: openmodelstudio_secret |
| 232 | + ports: |
| 233 | + - 5432:5432 |
| 234 | + options: >- |
| 235 | + --health-cmd="pg_isready -U openmodelstudio" |
| 236 | + --health-interval=5s |
| 237 | + --health-timeout=5s |
| 238 | + --health-retries=5 |
| 239 | + steps: |
| 240 | + - uses: actions/checkout@v4 |
| 241 | + |
| 242 | + - name: Wait for Postgres |
| 243 | + run: | |
| 244 | + for i in $(seq 1 30); do |
| 245 | + pg_isready -h localhost -p 5432 -U openmodelstudio && break |
| 246 | + sleep 1 |
| 247 | + done |
| 248 | +
|
| 249 | + - name: Apply init schema |
| 250 | + run: psql -f db/init.sql |
| 251 | + env: |
| 252 | + PGHOST: localhost |
| 253 | + PGPORT: "5432" |
| 254 | + PGDATABASE: openmodelstudio |
| 255 | + PGUSER: openmodelstudio |
| 256 | + PGPASSWORD: openmodelstudio_secret |
| 257 | + |
| 258 | + - name: Apply seed data |
| 259 | + run: psql -f db/seed.sql |
| 260 | + env: |
| 261 | + PGHOST: localhost |
| 262 | + PGPORT: "5432" |
| 263 | + PGDATABASE: openmodelstudio |
| 264 | + PGUSER: openmodelstudio |
| 265 | + PGPASSWORD: openmodelstudio_secret |
| 266 | + |
| 267 | + - name: Verify tables exist |
| 268 | + run: | |
| 269 | + TABLE_COUNT=$(psql -t -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';" | tr -d ' ') |
| 270 | + echo "Found $TABLE_COUNT tables" |
| 271 | + if [ "$TABLE_COUNT" -lt 20 ]; then |
| 272 | + echo "Expected at least 20 tables, got $TABLE_COUNT" |
| 273 | + exit 1 |
| 274 | + fi |
| 275 | + env: |
| 276 | + PGHOST: localhost |
| 277 | + PGPORT: "5432" |
| 278 | + PGDATABASE: openmodelstudio |
| 279 | + PGUSER: openmodelstudio |
| 280 | + PGPASSWORD: openmodelstudio_secret |
| 281 | + |
| 282 | + - name: Verify seed user exists |
| 283 | + run: | |
| 284 | + USER_COUNT=$(psql -t -c "SELECT count(*) FROM users WHERE email = 'test@openmodel.studio';" | tr -d ' ') |
| 285 | + if [ "$USER_COUNT" -ne 1 ]; then |
| 286 | + echo "Seed user test@openmodel.studio not found" |
| 287 | + exit 1 |
| 288 | + fi |
| 289 | + echo "Seed user verified" |
| 290 | + env: |
| 291 | + PGHOST: localhost |
| 292 | + PGPORT: "5432" |
| 293 | + PGDATABASE: openmodelstudio |
| 294 | + PGUSER: openmodelstudio |
| 295 | + PGPASSWORD: openmodelstudio_secret |
0 commit comments