|
| 1 | +name: Chat API OpenRouter smoke |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize, reopened, ready_for_review] |
| 7 | + paths: |
| 8 | + - 'apps/chat-api/**' |
| 9 | + - 'packages/chat-engine/**' |
| 10 | + - 'packages/prisma/**' |
| 11 | + - 'packages/prisma-data/**' |
| 12 | + - 'pnpm-lock.yaml' |
| 13 | + - '.github/workflows/chat-api-openrouter-smoke.yml' |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + smoke: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | + services: |
| 26 | + postgres: |
| 27 | + image: postgres:15 |
| 28 | + env: |
| 29 | + POSTGRES_USER: klicker |
| 30 | + POSTGRES_DB: klicker-prod |
| 31 | + POSTGRES_HOST_AUTH_METHOD: trust |
| 32 | + options: >- |
| 33 | + --health-cmd pg_isready |
| 34 | + --health-interval 10s |
| 35 | + --health-timeout 5s |
| 36 | + --health-retries 5 |
| 37 | + ports: |
| 38 | + - 5432:5432 |
| 39 | + |
| 40 | + env: |
| 41 | + APP_SECRET: local-dev-only |
| 42 | + CHAT_MODEL_REGISTRY_JSON: >- |
| 43 | + [{"id":"deepseek-v4-flash","deploymentId":"deepseek/deepseek-v4-flash","name":"DeepSeek V4 Flash","description":"OpenRouter smoke test model","fallback":true,"supportsReasoning":false,"supportsImageAttachments":false,"maxOutputTokens":256,"cost":{"input":0.27,"output":0.41}}] |
| 44 | + CHAT_OPENAI_STORE_RESPONSES: 'false' |
| 45 | + CHAT_SMOKE_API_BASE_URL: http://127.0.0.1:3305 |
| 46 | + CHAT_SMOKE_TIMEOUT_MS: '120000' |
| 47 | + DATABASE_URL: postgresql://klicker@localhost:5432/klicker-prod?sslmode=disable |
| 48 | + FALLBACK_MODEL_ID: deepseek/deepseek-v4-flash |
| 49 | + OPENAI_API_KEY: ${{ secrets.OPENROUTER_API_KEY || 'ci-placeholder' }} |
| 50 | + OPENAI_BASE_URL: https://openrouter.ai/api/v1 |
| 51 | + PORT: '3305' |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout repository |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - uses: pnpm/action-setup@v4 |
| 58 | + with: |
| 59 | + version: 10.15.0 |
| 60 | + |
| 61 | + - uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version: 20.19.4 |
| 64 | + cache: pnpm |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: pnpm install --frozen-lockfile |
| 68 | + |
| 69 | + - name: Build smoke dependencies |
| 70 | + run: | |
| 71 | + pnpm --filter @klicker-uzh/prisma build |
| 72 | + pnpm --filter @klicker-uzh/types build |
| 73 | + pnpm --filter @klicker-uzh/grading build |
| 74 | + pnpm --filter @klicker-uzh/util build |
| 75 | + pnpm --filter @klicker-uzh/chat-engine build |
| 76 | +
|
| 77 | + - name: Prepare seeded database |
| 78 | + run: | |
| 79 | + pnpm --filter @klicker-uzh/prisma prisma:push:raw |
| 80 | + pnpm --filter @klicker-uzh/prisma-data seed:raw |
| 81 | +
|
| 82 | + - name: Typecheck chat-api |
| 83 | + run: pnpm --filter @klicker-uzh/chat-api check |
| 84 | + |
| 85 | + - name: Start chat-api |
| 86 | + run: | |
| 87 | + pnpm --filter @klicker-uzh/chat-api exec tsx src/index.ts > /tmp/chat-api-openrouter-smoke.log 2>&1 & |
| 88 | + echo "$!" > /tmp/chat-api-openrouter-smoke.pid |
| 89 | +
|
| 90 | + for attempt in {1..30}; do |
| 91 | + if curl -fsS "http://127.0.0.1:${PORT}/health" >/dev/null; then |
| 92 | + exit 0 |
| 93 | + fi |
| 94 | + sleep 2 |
| 95 | + done |
| 96 | +
|
| 97 | + cat /tmp/chat-api-openrouter-smoke.log |
| 98 | + exit 1 |
| 99 | +
|
| 100 | + - name: Run OpenRouter DeepSeek V4 Flash smoke |
| 101 | + continue-on-error: true |
| 102 | + run: pnpm --filter @klicker-uzh/chat-api smoke:openrouter |
| 103 | + |
| 104 | + - name: Publish smoke status note |
| 105 | + if: always() |
| 106 | + run: | |
| 107 | + { |
| 108 | + echo '### Chat API OpenRouter smoke' |
| 109 | + echo |
| 110 | + echo 'This workflow executes the real chat-api OpenRouter smoke path against DeepSeek V4 Flash.' |
| 111 | + echo |
| 112 | + echo 'The smoke step is currently non-blocking because the workflow falls back to an invalid placeholder when `OPENROUTER_API_KEY` is not configured as a repository secret.' |
| 113 | + } >> "$GITHUB_STEP_SUMMARY" |
| 114 | +
|
| 115 | + - name: Print chat-api logs |
| 116 | + if: always() |
| 117 | + run: | |
| 118 | + if [[ -f /tmp/chat-api-openrouter-smoke.log ]]; then |
| 119 | + cat /tmp/chat-api-openrouter-smoke.log |
| 120 | + fi |
| 121 | +
|
| 122 | + - name: Stop chat-api |
| 123 | + if: always() |
| 124 | + run: | |
| 125 | + if [[ -f /tmp/chat-api-openrouter-smoke.pid ]]; then |
| 126 | + kill "$(cat /tmp/chat-api-openrouter-smoke.pid)" >/dev/null 2>&1 || true |
| 127 | + fi |
0 commit comments